From 2de79bc865dabba07eab819a75ed61b7860d999a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 7 Nov 2013 00:12:25 +0100 Subject: [PATCH] Add Fortran examples for smpi+dvfs. (cherry picked from commit 28ec59bf4a9e4b04c1af121616b72bd846772fa5) --- buildtools/Cmake/AddTests.cmake | 4 +++ buildtools/Cmake/DefinePackages.cmake | 2 ++ buildtools/Cmake/MakeExe.cmake | 2 ++ examples/smpi/energy/f77/CMakeLists.txt | 33 +++++++++++++++++++ examples/smpi/energy/f77/energy.tesh | 21 +++++++++++++ examples/smpi/energy/f77/sef.f | 42 +++++++++++++++++++++++++ examples/smpi/energy/f90/CMakeLists.txt | 33 +++++++++++++++++++ examples/smpi/energy/f90/energy.tesh | 21 +++++++++++++ examples/smpi/energy/f90/sef90.f90 | 38 ++++++++++++++++++++++ 9 files changed, 196 insertions(+) create mode 100644 examples/smpi/energy/f77/CMakeLists.txt create mode 100644 examples/smpi/energy/f77/energy.tesh create mode 100644 examples/smpi/energy/f77/sef.f create mode 100644 examples/smpi/energy/f90/CMakeLists.txt create mode 100644 examples/smpi/energy/f90/energy.tesh create mode 100644 examples/smpi/energy/f90/sef90.f90 diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 5120a58cdd..6de5b22032 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -436,6 +436,10 @@ if(NOT enable_memcheck) 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(SMPI_F2C) + ADD_TEST(smpi-energy-f77 ${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/f77/energy.tesh) + ADD_TEST(smpi-energy-f90 ${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/f90/energy.tesh) + endif() 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) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index cde8b9f80e..7747b9cfd5 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -902,6 +902,8 @@ set(EXAMPLES_CMAKEFILES_TXT examples/smpi/CMakeLists.txt examples/smpi/MM/CMakeLists.txt examples/smpi/energy/CMakeLists.txt + examples/smpi/energy/f77/CMakeLists.txt + examples/smpi/energy/f90/CMakeLists.txt examples/xbt/CMakeLists.txt ) diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index bb7735d32e..4c6d9d2b06 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -70,6 +70,8 @@ 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/smpi/energy/f77) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/xbt) diff --git a/examples/smpi/energy/f77/CMakeLists.txt b/examples/smpi/energy/f77/CMakeLists.txt new file mode 100644 index 0000000000..52709c2f45 --- /dev/null +++ b/examples/smpi/energy/f77/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 2.6) + +if(enable_smpi AND SMPI_F2C) + set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff") + + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + + add_executable(sef sef.f) + target_link_libraries(sef simgrid) +endif() + +set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/energy.tesh + PARENT_SCOPE + ) +set(xml_files + ${xml_files} + PARENT_SCOPE + ) +set(examples_src + ${examples_src} + ${CMAKE_CURRENT_SOURCE_DIR}/sef.f + PARENT_SCOPE + ) +set(bin_files + ${bin_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + PARENT_SCOPE + ) diff --git a/examples/smpi/energy/f77/energy.tesh b/examples/smpi/energy/f77/energy.tesh new file mode 100644 index 0000000000..86ceca6c50 --- /dev/null +++ b/examples/smpi/energy/f77/energy.tesh @@ -0,0 +1,21 @@ +p Test smpi bindings for dvfs functions (Fortran 77 example) +$ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/f77/sef +> [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.] [rank 0] 3pstates available +> [ 0.] [rank 1] 1pstates available +> [ 0.] [rank 0] Power: 100000000. +> [ 0.] [rank 1] Power: 100000000. +> [ 0.] [rank 0] Power: 50000000. +> [ 0.] [rank 0] Power: 20000000. +> [ 0.] [rank 1] Current pstate: 0; Current power: 100000000. +> [ 0.] [rank 0] Current pstate: 0; Current power: 100000000. +> [ 10.] [rank 1]Energy consumed (Joules): 2000. +> [ 10.] [rank 0]Energy consumed (Joules): 2000. +> [ 10.] [rank 0] Current pstate: 1; Current power: 50000000. +> [ 30.] [rank 0]Energy consumed (Joules): 5400. +> [ 30.] [rank 0] Current pstate: 2; Current power: 20000000. +> [ 80.] [rank 0]Energy consumed (Joules): 12900. diff --git a/examples/smpi/energy/f77/sef.f b/examples/smpi/energy/f77/sef.f new file mode 100644 index 0000000000..a1588bef20 --- /dev/null +++ b/examples/smpi/energy/f77/sef.f @@ -0,0 +1,42 @@ + program main + include 'mpif.h' + + integer ierr + integer rank, pstates + integer i + double precision p, t, e + + call MPI_Init(ierr) + call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) + + pstates = smpi_get_host_nb_pstates() + + t = MPI_Wtime() + + print *, '[', t, '] [rank ', rank, ']', + & pstates, 'pstates available' + + do i = 0, pstates - 1 + p = smpi_get_host_power_peak_at(i) + print *, '[', t, '] [rank ', rank, '] Power: ', p + end do + + do i = 0, pstates - 1 + call smpi_set_host_power_peak_at(i) + t = MPI_Wtime() + p = smpi_get_host_current_power_peak() + print *, '[', t, '] [rank ', rank, '] Current pstate: ', i, + & '; Current power: ', p + + e = 1e9 + call smpi_execute_flops(e) + + t = MPI_Wtime() + e = smpi_get_host_consumed_energy() + print *, '[', t, '] [rank ', rank, ']', + & 'Energy consumed (Joules): ', e + end do + + call MPI_Finalize(ierr) + + end program main diff --git a/examples/smpi/energy/f90/CMakeLists.txt b/examples/smpi/energy/f90/CMakeLists.txt new file mode 100644 index 0000000000..03d1288e23 --- /dev/null +++ b/examples/smpi/energy/f90/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 2.6) + +if(enable_smpi AND SMPI_F2C) + set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90") + + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + + add_executable(sef90 sef90.f90) + target_link_libraries(sef90 simgrid) +endif() + +set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/energy.tesh + PARENT_SCOPE + ) +set(xml_files + ${xml_files} + PARENT_SCOPE + ) +set(examples_src + ${examples_src} + ${CMAKE_CURRENT_SOURCE_DIR}/sef90.f90 + PARENT_SCOPE + ) +set(bin_files + ${bin_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + PARENT_SCOPE + ) diff --git a/examples/smpi/energy/f90/energy.tesh b/examples/smpi/energy/f90/energy.tesh new file mode 100644 index 0000000000..fe1859b01b --- /dev/null +++ b/examples/smpi/energy/f90/energy.tesh @@ -0,0 +1,21 @@ +p Test smpi bindings for dvfs functions (Fortran 90 example) +$ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/f90/sef90 +> [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.0000000000000000 ] [rank 0 ] 3 pstates available +> [ 0.0000000000000000 ] [rank 1 ] 1 pstates available +> [ 0.0000000000000000 ] [rank 0 ] Power: 100000000.00000000 +> [ 0.0000000000000000 ] [rank 1 ] Power: 100000000.00000000 +> [ 0.0000000000000000 ] [rank 0 ] Power: 50000000.000000000 +> [ 0.0000000000000000 ] [rank 0 ] Power: 20000000.000000000 +> [ 0.0000000000000000 ] [rank 1 ] Current pstate: 0 ; Current power: 100000000.00000000 +> [ 0.0000000000000000 ] [rank 0 ] Current pstate: 0 ; Current power: 100000000.00000000 +> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 2000.0000000000000 +> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 2000.0000000000000 +> [ 10.000000000000000 ] [rank 0 ] Current pstate: 1 ; Current power: 50000000.000000000 +> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 5400.0000000000000 +> [ 30.000000000000000 ] [rank 0 ] Current pstate: 2 ; Current power: 20000000.000000000 +> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 12900.000000000000 diff --git a/examples/smpi/energy/f90/sef90.f90 b/examples/smpi/energy/f90/sef90.f90 new file mode 100644 index 0000000000..59b3fbfb61 --- /dev/null +++ b/examples/smpi/energy/f90/sef90.f90 @@ -0,0 +1,38 @@ +program main + use mpi + + integer ierr + integer rank, pstates + integer i + double precision p, t, e + + call MPI_Init(ierr) + call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) + + pstates = smpi_get_host_nb_pstates() + + t = MPI_Wtime() + + print *, '[', t, '] [rank ', rank, ']', pstates, 'pstates available' + do i = 0, pstates - 1 + p = smpi_get_host_power_peak_at(i) + print *, '[', t, '] [rank ', rank, '] Power: ', p + end do + + do i = 0, pstates - 1 + call smpi_set_host_power_peak_at(i) + t = MPI_Wtime() + p = smpi_get_host_current_power_peak() + print *, '[', t, '] [rank ', rank, '] Current pstate: ', i, '; Current power: ', p + + e = 1e9 + call smpi_execute_flops(e) + + t = MPI_Wtime() + e = smpi_get_host_consumed_energy() + print *, '[', t, '] [rank ', rank, '] Energy consumed (Joules): ', e + end do + + call MPI_Finalize(ierr) + +end program main -- 2.20.1