X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d6d03a0a88c2673c9e5c604d63912b77bc17fdd4..0dda9bcd2d7df2c8141a8170a7cb8fe20746b4a9:/src/smpi/smpi_replay.cpp diff --git a/src/smpi/smpi_replay.cpp b/src/smpi/smpi_replay.cpp index cda83f963e..9ba7295206 100644 --- a/src/smpi/smpi_replay.cpp +++ b/src/smpi/smpi_replay.cpp @@ -52,7 +52,7 @@ static void set_reqq_self(std::vector *mpi_request) //allocate a single buffer for all sends, growing it if needed void* smpi_get_tmp_sendbuffer(int size) { - if (!smpi_process()->replaying()) + if (not smpi_process()->replaying()) return xbt_malloc(size); if (sendbuffer_size(xbt_realloc(sendbuffer,size)); @@ -63,7 +63,7 @@ void* smpi_get_tmp_sendbuffer(int size) //allocate a single buffer for all recv void* smpi_get_tmp_recvbuffer(int size){ - if (!smpi_process()->replaying()) + if (not smpi_process()->replaying()) return xbt_malloc(size); if (recvbuffer_size(xbt_realloc(recvbuffer,size)); @@ -73,7 +73,7 @@ void* smpi_get_tmp_recvbuffer(int size){ } void smpi_free_tmp_buffer(void* buf){ - if (!smpi_process()->replaying()) + if (not smpi_process()->replaying()) xbt_free(buf); } @@ -113,6 +113,7 @@ static MPI_Datatype decode_datatype(const char *const action) break; default: MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE; + break; } return MPI_CURRENT_TYPE; } @@ -163,8 +164,8 @@ static void action_init(const char *const *action) { XBT_DEBUG("Initialize the counters"); CHECK_ACTION_PARAMS(action, 0, 1) - if(action[2]) - MPI_DEFAULT_TYPE=MPI_DOUBLE; // default MPE dataype + if(action[2]) + MPI_DEFAULT_TYPE=MPI_DOUBLE; // default MPE dataype else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype /* start a simulated timer */ @@ -235,7 +236,7 @@ static void action_send(const char *const *action) extra->dst = dst_traced; extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); - if (!TRACE_smpi_view_internals()) + if (not TRACE_smpi_view_internals()) TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size()); Request::send(nullptr, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD); @@ -252,9 +253,9 @@ static void action_Isend(const char *const *action) double size=parse_double(action[3]); double clock = smpi_process()->simulated_elapsed(); - if(action[4]) + if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]); - else + else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE; int rank = smpi_process()->index(); @@ -266,7 +267,7 @@ static void action_Isend(const char *const *action) extra->dst = dst_traced; extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); - if (!TRACE_smpi_view_internals()) + if (not TRACE_smpi_view_internals()) TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size()); MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD); @@ -285,9 +286,9 @@ static void action_recv(const char *const *action) { double clock = smpi_process()->simulated_elapsed(); MPI_Status status; - if(action[4]) + if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]); - else + else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE; int rank = smpi_process()->index(); @@ -310,7 +311,7 @@ static void action_recv(const char *const *action) { Request::recv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status); TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); - if (!TRACE_smpi_view_internals()) { + if (not TRACE_smpi_view_internals()) { TRACE_smpi_recv(rank, src_traced, rank, 0); } @@ -324,9 +325,9 @@ static void action_Irecv(const char *const *action) double size=parse_double(action[3]); double clock = smpi_process()->simulated_elapsed(); - if(action[4]) + if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]); - else + else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE; int rank = smpi_process()->index(); @@ -360,8 +361,8 @@ static void action_test(const char *const *action){ MPI_Request request = get_reqq_self()->back(); get_reqq_self()->pop_back(); - //if request is null here, this may mean that a previous test has succeeded - //Different times in traced application and replayed version may lead to this + //if request is null here, this may mean that a previous test has succeeded + //Different times in traced application and replayed version may lead to this //In this case, ignore the extra calls. if(request!=nullptr){ int rank = smpi_process()->index(); @@ -468,12 +469,12 @@ static void action_bcast(const char *const *action) double clock = smpi_process()->simulated_elapsed(); int root=0; /* Initialize MPI_CURRENT_TYPE in order to decrease the number of the checks */ - MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE; + MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE; if(action[3]) { root= atoi(action[3]); if(action[4]) - MPI_CURRENT_TYPE=decode_datatype(action[4]); + MPI_CURRENT_TYPE=decode_datatype(action[4]); } int rank = smpi_process()->index(); @@ -754,8 +755,8 @@ static void action_allgather(const char *const *action) { double clock = smpi_process()->simulated_elapsed(); CHECK_ACTION_PARAMS(action, 2, 2) - int sendcount=atoi(action[2]); - int recvcount=atoi(action[3]); + int sendcount=atoi(action[2]); + int recvcount=atoi(action[3]); MPI_Datatype MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE; @@ -904,8 +905,9 @@ static void action_allToAllv(const char *const *action) { }} // namespace simgrid::smpi -void smpi_replay_run(int *argc, char***argv){ - /* First initializes everything */ +/** @brief Only initialize the replay, don't do it for real */ +void smpi_replay_init(int* argc, char*** argv) +{ simgrid::smpi::Process::init(argc, argv); smpi_process()->mark_as_initialized(); smpi_process()->set_replaying(true); @@ -915,10 +917,8 @@ void smpi_replay_run(int *argc, char***argv){ TRACE_smpi_computing_init(rank); instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_INIT; - char *operation =bprintf("%s_init",__FUNCTION__); - TRACE_smpi_collective_in(rank, -1, operation, extra); - TRACE_smpi_collective_out(rank, -1, operation); - xbt_free(operation); + TRACE_smpi_collective_in(rank, -1, "smpi_replay_run_init", extra); + TRACE_smpi_collective_out(rank, -1, "smpi_replay_run_init"); xbt_replay_action_register("init", simgrid::smpi::action_init); xbt_replay_action_register("finalize", simgrid::smpi::action_finalize); xbt_replay_action_register("comm_size", simgrid::smpi::action_comm_size); @@ -946,10 +946,7 @@ void smpi_replay_run(int *argc, char***argv){ //if we have a delayed start, sleep here. if(*argc>2){ - char *endptr; - double value = strtod((*argv)[2], &endptr); - if (*endptr != '\0') - THROWF(unknown_error, 0, "%s is not a double", (*argv)[2]); + double value = xbt_str_parse_double((*argv)[2], "%s is not a double"); XBT_VERB("Delayed start for instance - Sleeping for %f flops ",value ); smpi_execute_flops(value); } else { @@ -957,14 +954,17 @@ void smpi_replay_run(int *argc, char***argv){ XBT_DEBUG("Force context switch by smpi_execute_flops - Sleeping for 0.0 flops "); smpi_execute_flops(0.0); } +} - /* Actually run the replay */ +/** @brief actually run the replay after initialization */ +void smpi_replay_main(int* argc, char*** argv) +{ simgrid::xbt::replay_runner(*argc, *argv); /* and now, finalize everything */ /* One active process will stop. Decrease the counter*/ XBT_DEBUG("There are %zu elements in reqq[*]", get_reqq_self()->size()); - if (!get_reqq_self()->empty()){ + if (not get_reqq_self()->empty()) { unsigned int count_requests=get_reqq_self()->size(); MPI_Request requests[count_requests]; MPI_Status status[count_requests]; @@ -988,12 +988,17 @@ void smpi_replay_run(int *argc, char***argv){ instr_extra_data extra_fin = xbt_new0(s_instr_extra_data_t,1); extra_fin->type = TRACING_FINALIZE; - operation =bprintf("%s_finalize",__FUNCTION__); - TRACE_smpi_collective_in(rank, -1, operation, extra_fin); + TRACE_smpi_collective_in(smpi_process()->index(), -1, "smpi_replay_run_finalize", extra_fin); smpi_process()->finalize(); - TRACE_smpi_collective_out(rank, -1, operation); + TRACE_smpi_collective_out(smpi_process()->index(), -1, "smpi_replay_run_finalize"); TRACE_smpi_finalize(smpi_process()->index()); - xbt_free(operation); +} + +/** @brief chain a replay initialization and a replay start */ +void smpi_replay_run(int* argc, char*** argv) +{ + smpi_replay_init(argc, argv); + smpi_replay_main(argc, argv); }