From: Millian Poquet Date: Tue, 20 Nov 2018 08:49:05 +0000 (+0100) Subject: [smpi] add smpireplayrun binary X-Git-Tag: v3_22~781^2^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/92e4eb1c61e62840aa7cc4be72aad837d0fe8249 [smpi] add smpireplayrun binary 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bd1bca7bd0..daab600043 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) +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 @@ -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) +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) diff --git a/src/smpi/smpi_replay_main.cpp b/src/smpi/smpi_replay_main.cpp new file mode 100644 index 0000000000..72898c5ca7 --- /dev/null +++ b/src/smpi/smpi_replay_main.cpp @@ -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; +} diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 46987ff0ba..754f638558 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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/smpi_replay_main.cpp src/surf/cpu_cas01.hpp src/surf/cpu_interface.hpp src/surf/cpu_ti.hpp diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index aa7aeac67f..d7f1ade087 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -88,6 +88,7 @@ if(enable_smpi) 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 @@ -95,6 +96,14 @@ if(enable_smpi) 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")