Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add Fortran examples for smpi+dvfs.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 6 Nov 2013 23:12:25 +0000 (00:12 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 7 Nov 2013 08:28:22 +0000 (09:28 +0100)
(cherry picked from commit 28ec59bf4a9e4b04c1af121616b72bd846772fa5)

buildtools/Cmake/AddTests.cmake
buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/MakeExe.cmake
examples/smpi/energy/f77/CMakeLists.txt [new file with mode: 0644]
examples/smpi/energy/f77/energy.tesh [new file with mode: 0644]
examples/smpi/energy/f77/sef.f [new file with mode: 0644]
examples/smpi/energy/f90/CMakeLists.txt [new file with mode: 0644]
examples/smpi/energy/f90/energy.tesh [new file with mode: 0644]
examples/smpi/energy/f90/sef90.f90 [new file with mode: 0644]

index 5120a58..6de5b22 100644 (file)
@@ -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)
     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)
 
     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)
index cde8b9f..7747b9c 100644 (file)
@@ -902,6 +902,8 @@ set(EXAMPLES_CMAKEFILES_TXT
   examples/smpi/CMakeLists.txt
   examples/smpi/MM/CMakeLists.txt
   examples/smpi/energy/CMakeLists.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
   )
 
   examples/xbt/CMakeLists.txt
   )
 
index bb7735d..4c6d9d2 100644 (file)
@@ -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)
 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)
 
 
 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 (file)
index 0000000..52709c2
--- /dev/null
@@ -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 (file)
index 0000000..86ceca6
--- /dev/null
@@ -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 (file)
index 0000000..a1588be
--- /dev/null
@@ -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 (file)
index 0000000..03d1288
--- /dev/null
@@ -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 (file)
index 0000000..fe1859b
--- /dev/null
@@ -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 (file)
index 0000000..59b3fbf
--- /dev/null
@@ -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