Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[smpi] add smpireplayrun binary
authorMillian Poquet <millian.poquet@inria.fr>
Tue, 20 Nov 2018 08:49:05 +0000 (09:49 +0100)
committerMillian Poquet <millian.poquet@inria.fr>
Wed, 21 Nov 2018 14:24:14 +0000 (15:24 +0100)
This program is a simple variant of the good old smpi-replay example.

The goal here is to generate a dedicated binary in SimGrid's
installation so users can simply use smpirun -replay instead of
compiling and executing a dedicated example.

CMakeLists.txt
src/smpi/smpi_replay_main.cpp [new file with mode: 0644]
tools/cmake/DefinePackages.cmake
tools/cmake/MakeLib.cmake

index bd1bca7..daab600 100644 (file)
@@ -617,6 +617,7 @@ if(NS3_LIBRARY_PATH)
 endif()
 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
 set(SMPIMAIN ${libdir}/simgrid/smpimain)
 endif()
 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
 set(SMPIMAIN ${libdir}/simgrid/smpimain)
+set(SMPIREPLAYMAIN ${libdir}/simgrid/smpireplaymain)
 
 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/mpif.h @ONLY)
 #configure mpif.f90 to build mpi.mod
 
 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/mpif.h @ONLY)
 #configure mpif.f90 to build mpi.mod
@@ -645,6 +646,7 @@ if(NS3_LIBRARY_PATH)
 endif()
 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
 set(SMPIMAIN ${CMAKE_BINARY_DIR}/lib/simgrid/smpimain)
 endif()
 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
 set(SMPIMAIN ${CMAKE_BINARY_DIR}/lib/simgrid/smpimain)
+set(SMPIREPLAYMAIN ${CMAKE_BINARY_DIR}/lib/simgrid/smpireplaymain)
 
 foreach(script cc cxx ff f90 run)
   configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpi${script}.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpi${script} @ONLY)
 
 foreach(script cc cxx ff f90 run)
   configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpi${script}.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpi${script} @ONLY)
diff --git a/src/smpi/smpi_replay_main.cpp b/src/smpi/smpi_replay_main.cpp
new file mode 100644 (file)
index 0000000..72898c5
--- /dev/null
@@ -0,0 +1,40 @@
+#include "simgrid/s4u.hpp"
+#include "smpi/smpi.h"
+#include "xbt/asserts.h"
+#include "xbt/replay.hpp"
+#include "xbt/str.h"
+
+int main(int argc, char* argv[])
+{
+  if (simgrid::s4u::Actor::self().get() == nullptr) {
+    printf("smpireplaymain should not be called directly. Please use smpirun -replay instead.\n");
+    return 1;
+  }
+
+  auto properties = simgrid::s4u::Actor::self()->get_properties();
+  if (properties->find("smpi_replay") == properties->end()) {
+    printf("invalid smpireplaymain execution. Please use smpirun -replay instead.\n");
+    return 1;
+  }
+
+  const char* instance_id    = properties->at("instance_id").c_str();
+  const int rank             = xbt_str_parse_int(properties->at("rank").c_str(), "Cannot parse rank");
+  const char* trace_filename = argv[1];
+  double start_delay_flops   = 0;
+
+  if (argc > 2) {
+    start_delay_flops = xbt_str_parse_double(argv[2], "Cannot parse start_delay_flops");
+  }
+
+  /* Setup things and register default actions */
+  smpi_replay_init(instance_id, rank, start_delay_flops);
+
+  /* A small check, just to make sure SMPI ranks are consistent with input arguments */
+  int new_rank;
+  MPI_Comm_rank(MPI_COMM_WORLD, &new_rank);
+  xbt_assert(new_rank == rank, "Rank inconsistency. Got %d, expected %d", new_rank, rank);
+
+  /* The regular run of the replayer */
+  smpi_replay_main(rank, trace_filename);
+  return 0;
+}
index 46987ff..754f638 100644 (file)
@@ -33,6 +33,7 @@ set(EXTRA_DIST
   src/smpi/include/private.hpp
   src/smpi/include/smpi_utils.hpp
   src/smpi/smpi_main.c
   src/smpi/include/private.hpp
   src/smpi/include/smpi_utils.hpp
   src/smpi/smpi_main.c
+  src/smpi/smpi_replay_main.cpp
   src/surf/cpu_cas01.hpp
   src/surf/cpu_interface.hpp
   src/surf/cpu_ti.hpp
   src/surf/cpu_cas01.hpp
   src/surf/cpu_interface.hpp
   src/surf/cpu_ti.hpp
index aa7aeac..d7f1ade 100644 (file)
@@ -88,6 +88,7 @@ if(enable_smpi)
   if(NOT ${DL_LIBRARY} STREQUAL "")
     set(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}") # for privatization
   endif()
   if(NOT ${DL_LIBRARY} STREQUAL "")
     set(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}") # for privatization
   endif()
+
   add_executable(smpimain src/smpi/smpi_main.c)
   target_link_libraries(smpimain simgrid)
   set_target_properties(smpimain
   add_executable(smpimain src/smpi/smpi_main.c)
   target_link_libraries(smpimain simgrid)
   set_target_properties(smpimain
@@ -95,6 +96,14 @@ if(enable_smpi)
   install(TARGETS smpimain # install that binary without breaking the rpath on Mac
     RUNTIME DESTINATION lib/simgrid)
 
   install(TARGETS smpimain # install that binary without breaking the rpath on Mac
     RUNTIME DESTINATION lib/simgrid)
 
+  add_executable(smpireplaymain src/smpi/smpi_replay_main.cpp)
+  target_compile_options(smpireplaymain PRIVATE -fpic)
+  target_link_libraries(smpireplaymain simgrid -shared)
+  set_target_properties(smpireplaymain
+    PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/simgrid)
+  install(TARGETS smpireplaymain # install that binary without breaking the rpath on Mac
+    RUNTIME DESTINATION lib/simgrid)
+
   if(SMPI_FORTRAN)
     if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
       SET(SIMGRID_DEP "${SIMGRID_DEP} -lgfortran")
   if(SMPI_FORTRAN)
     if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
       SET(SIMGRID_DEP "${SIMGRID_DEP} -lgfortran")