Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add example for smpi+dvfs.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 6 Nov 2013 17:37:25 +0000 (18:37 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 7 Nov 2013 08:21:32 +0000 (09:21 +0100)
ChangeLog
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/MakeExe.cmake
examples/smpi/energy/CMakeLists.txt [new file with mode: 0644]
examples/smpi/energy/energy.tesh [new file with mode: 0644]
examples/smpi/energy/hostfile [new file with mode: 0644]
examples/smpi/energy/platform.xml [new file with mode: 0644]
examples/smpi/energy/se.c [new file with mode: 0644]

index 61c1e65..ad4fb21 100644 (file)
--- 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)
    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
 
  Model-Checking;
  * Verification of liveness properties is now available for SMPI applications
index 40bd948..5120a58 100644 (file)
@@ -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-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)
     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)
index abc3963..8e3cb25 100644 (file)
@@ -900,6 +900,7 @@ set(EXAMPLES_CMAKEFILES_TXT
   examples/simdag/scheduling/CMakeLists.txt
   examples/smpi/CMakeLists.txt
   examples/smpi/MM/CMakeLists.txt
   examples/simdag/scheduling/CMakeLists.txt
   examples/smpi/CMakeLists.txt
   examples/smpi/MM/CMakeLists.txt
+  examples/smpi/energy/CMakeLists.txt
   examples/xbt/CMakeLists.txt
   )
 
   examples/xbt/CMakeLists.txt
   )
 
index 51fb860..bb7735d 100644 (file)
@@ -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)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/MM)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/energy)
 
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/xbt)
 
 
 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 (file)
index 0000000..76ddc39
--- /dev/null
@@ -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 (file)
index 0000000..aac0673
--- /dev/null
@@ -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 (file)
index 0000000..4b0f37f
--- /dev/null
@@ -0,0 +1,2 @@
+MyHost1
+MyHost2
diff --git a/examples/smpi/energy/platform.xml b/examples/smpi/energy/platform.xml
new file mode 100644 (file)
index 0000000..ad57cca
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS  id="AS0"  routing="Full">
+  <!-- Multiple pstate processor capacities can be defined as a list of powers specified for a given host -->
+  <!-- The enabled pstate can be set through the "pstate" attribute (lowest pstate corresponds to the highest processor power) -->
+  <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf" pstate="0" >
+        <!--  List of min_power:max_power pairs (in Watts) corresponding to the power consumed when the processor is idle and when it is fully loaded -->
+        <!--  The list must contain one power pair for each previously defined pstate-->
+        <prop id="power_per_state" value="95.0:200.0, 93.0:170.0, 90.0:150.0" />
+  </host>
+  <host id="MyHost2" power="100.0Mf" >
+        <prop id="power_per_state" value="95.0:200.0" />
+  </host>
+</AS>
+</platform>
diff --git a/examples/smpi/energy/se.c b/examples/smpi/energy/se.c
new file mode 100644 (file)
index 0000000..6632e3d
--- /dev/null
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include <smpi/smpi.h>
+
+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();
+}