From: Arnaud Giersch Date: Wed, 6 Nov 2013 17:37:25 +0000 (+0100) Subject: Add example for smpi+dvfs. X-Git-Tag: v3_11_beta~365 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/40f9c3e861f4b651dc2dd63b79271e735931a1a7 Add example for smpi+dvfs. --- diff --git a/ChangeLog b/ChangeLog index 61c1e65b1a..ad4fb21143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,6 +56,7 @@ SimGrid (3.10-rc1) unstable; urgency=low enable_smpi_MPICH3_testsuite flag in cmake. Run with ctest. * Add all missing Fortran bindings, SMPI should work with Fortran 90 (no privatization of global variables yet) + * Preliminary DVFS support (see examples/smpi/energy/ for details) Model-Checking; * Verification of liveness properties is now available for SMPI applications diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 40bd94895d..5120a58cdd 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -434,6 +434,9 @@ if(NOT enable_memcheck) ADD_TEST(smpi-shared-raw ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared.tesh) endif() endif() + + ADD_TEST(smpi-energy ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/energy.tesh) + if(HAVE_TRACING) ADD_TEST(smpi-tracing-ptp ${TESH_COMMAND} ${TESH_OPTION} --cd ${CMAKE_BINARY_DIR}/examples/smpi ${CMAKE_HOME_DIRECTORY}/examples/smpi/tracing/smpi_traced.tesh) ADD_TEST(smpi-replay ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi --cd ${CMAKE_BINARY_DIR}/examples/smpi ${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/smpi_replay.tesh) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index abc3963962..8e3cb25a08 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -900,6 +900,7 @@ set(EXAMPLES_CMAKEFILES_TXT examples/simdag/scheduling/CMakeLists.txt examples/smpi/CMakeLists.txt examples/smpi/MM/CMakeLists.txt + examples/smpi/energy/CMakeLists.txt examples/xbt/CMakeLists.txt ) diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 51fb860084..bb7735d32e 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -69,6 +69,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/scheduling) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/MM) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/energy) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/xbt) diff --git a/examples/smpi/energy/CMakeLists.txt b/examples/smpi/energy/CMakeLists.txt new file mode 100644 index 0000000000..76ddc39a15 --- /dev/null +++ b/examples/smpi/energy/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 2.6) + +if(enable_smpi) + if(WIN32) + set(CMAKE_C_FLAGS "-include ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_main.h") + else() + set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc") + endif() + + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi") + + add_executable(se se.c) + target_link_libraries(se simgrid) +endif() + +set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/energy.tesh + PARENT_SCOPE + ) +set(xml_files + ${xml_files} + ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml + PARENT_SCOPE + ) +set(examples_src + ${examples_src} + ${CMAKE_CURRENT_SOURCE_DIR}/se.c + PARENT_SCOPE + ) +set(bin_files + ${bin_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + ${CMAKE_CURRENT_SOURCE_DIR}/hostfile + PARENT_SCOPE + ) diff --git a/examples/smpi/energy/energy.tesh b/examples/smpi/energy/energy.tesh new file mode 100644 index 0000000000..aac06731a5 --- /dev/null +++ b/examples/smpi/energy/energy.tesh @@ -0,0 +1,17 @@ +p Test smpi bindings for dvfs functions (C example) +$ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/se +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu_threshold' to '-1' +> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) +> [0.000000] [rank 1] Pstates: 1; Powers: 100000000 +> [0.000000] [rank 0] Pstates: 3; Powers: 100000000, 50000000, 20000000 +> [0.000000] [rank 1] Current pstate: 0; Current power: 100000000 +> [0.000000] [rank 0] Current pstate: 0; Current power: 100000000 +> [10.000000] [rank 1] Energy consumed: 2000 Joules. +> [10.000000] [rank 0] Energy consumed: 2000 Joules. +> [10.000000] [rank 0] Current pstate: 1; Current power: 50000000 +> [30.000000] [rank 0] Energy consumed: 5400 Joules. +> [30.000000] [rank 0] Current pstate: 2; Current power: 20000000 +> [80.000000] [rank 0] Energy consumed: 12900 Joules. diff --git a/examples/smpi/energy/hostfile b/examples/smpi/energy/hostfile new file mode 100644 index 0000000000..4b0f37fb55 --- /dev/null +++ b/examples/smpi/energy/hostfile @@ -0,0 +1,2 @@ +MyHost1 +MyHost2 diff --git a/examples/smpi/energy/platform.xml b/examples/smpi/energy/platform.xml new file mode 100644 index 0000000000..ad57ccaf10 --- /dev/null +++ b/examples/smpi/energy/platform.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/examples/smpi/energy/se.c b/examples/smpi/energy/se.c new file mode 100644 index 0000000000..6632e3d880 --- /dev/null +++ b/examples/smpi/energy/se.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int rank, pstates; + int i; + char buf[1024]; + char *s; + size_t sz, x; + + if (MPI_Init(&argc, &argv) != MPI_SUCCESS) { + printf("MPI initialization failed!\n"); + exit(EXIT_FAILURE); + } + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get id of this process */ + + pstates = smpi_get_host_nb_pstates(); + + s = buf; + sz = sizeof buf; + x = snprintf(s, sz, + "[%.6f] [rank %d] Pstates: %d; Powers: %.0f", + MPI_Wtime(), rank, pstates, smpi_get_host_power_peak_at(0)); + if (x < sz) { + s += x; + sz -= x; + } else + sz = 0; + for (i = 1; i < pstates; i++) { + x = snprintf(s, sz, ", %.0f", smpi_get_host_power_peak_at(i)); + if (x < sz) { + s += x; + sz -= x; + } else + sz = 0; + } + printf("%s%s\n", buf, (sz ? "" : " [...]")); + + for (i = 0; i < pstates; i++) { + smpi_set_host_power_peak_at(i); + printf("[%.6f] [rank %d] Current pstate: %d; Current power: %.0f\n", + MPI_Wtime(), rank, i, smpi_get_host_current_power_peak()); + + SMPI_SAMPLE_FLOPS(1e9) { + /* imagine here some code running for 1e9 flops... */ + } + + printf("[%.6f] [rank %d] Energy consumed: %g Joules.\n", + MPI_Wtime(), rank, smpi_get_host_consumed_energy()); + } + + return MPI_Finalize(); +}