X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7e0b698c2cc09a28687fd9eb216a8ba1dc8aad74..b4f5f7b99f3d61a9b5fc838e514179290b213548:/src/smpi/smpi_replay.c diff --git a/src/smpi/smpi_replay.c b/src/smpi/smpi_replay.c index 1e26cc249b..7214b99498 100644 --- a/src/smpi/smpi_replay.c +++ b/src/smpi/smpi_replay.c @@ -39,8 +39,6 @@ static void action_init(const char *const *action) smpi_process_set_user_data((void*) globals); - /* be sure that everyone has initiated the counters before proceeding */ - smpi_mpi_barrier(MPI_COMM_WORLD); /* start a simulated timer */ smpi_process_simulated_start(); } @@ -62,7 +60,8 @@ static void action_finalize(const char *const *action) sim_time = smpi_process_simulated_elapsed(); if (!smpi_process_index()) XBT_INFO("Simulation time %g", sim_time); - + smpi_process_finalize(); + smpi_process_destroy(); } static void action_comm_size(const char *const *action) @@ -71,8 +70,11 @@ static void action_comm_size(const char *const *action) communicator_size = parse_double(action[2]); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } @@ -81,8 +83,11 @@ static void action_compute(const char *const *action) double clock = smpi_process_simulated_elapsed(); smpi_execute_flops(parse_double(action[2])); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_send(const char *const *action) @@ -90,10 +95,27 @@ static void action_send(const char *const *action) int to = atoi(action[2]); double size=parse_double(action[3]); double clock = smpi_process_simulated_elapsed(); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__); + TRACE_smpi_send(rank, rank, dst_traced); +#endif smpi_mpi_send(NULL, size, MPI_BYTE, to , 0, MPI_COMM_WORLD); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } + + #ifdef HAVE_TRACING + TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); + TRACE_smpi_computing_in(rank); +#endif + } static void action_Isend(const char *const *action) @@ -103,15 +125,30 @@ static void action_Isend(const char *const *action) double clock = smpi_process_simulated_elapsed(); smpi_replay_globals_t globals = (smpi_replay_globals_t) smpi_process_get_user_data(); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__); + TRACE_smpi_send(rank, rank, dst_traced); +#endif MPI_Request request = smpi_mpi_isend(NULL, size, MPI_BYTE, to, 0, MPI_COMM_WORLD); +#ifdef HAVE_TRACING + TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); + request->send = 1; + TRACE_smpi_computing_in(rank); +#endif xbt_dynar_push(globals->isends,&request); //TODO do the asynchronous cleanup - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_recv(const char *const *action) { @@ -119,10 +156,27 @@ static void action_recv(const char *const *action) { double size=parse_double(action[3]); double clock = smpi_process_simulated_elapsed(); MPI_Status status; +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from); + TRACE_smpi_computing_out(rank); + + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__); +#endif smpi_mpi_recv(NULL, size, MPI_BYTE, from, 0, MPI_COMM_WORLD, &status); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + +#ifdef HAVE_TRACING + TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); + TRACE_smpi_recv(rank, src_traced, rank); + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_Irecv(const char *const *action) @@ -134,15 +188,25 @@ static void action_Irecv(const char *const *action) smpi_replay_globals_t globals = (smpi_replay_globals_t) smpi_process_get_user_data(); - XBT_DEBUG("Asynchronous receive of %.0f from rank%d (%s)",size, from, - action[2]); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__); +#endif request = smpi_mpi_irecv(NULL, size, MPI_BYTE, from, 0, MPI_COMM_WORLD); +#ifdef HAVE_TRACING + TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); + request->recv = 1; +#endif xbt_dynar_push(globals->irecvs,&request); //TODO do the asynchronous cleanup - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_wait(const char *const *action){ @@ -156,73 +220,149 @@ static void action_wait(const char *const *action){ "action wait not preceded by any irecv: %s", xbt_str_join_array(action," ")); request = xbt_dynar_pop_as(globals->irecvs,MPI_Request); +#ifdef HAVE_TRACING + int rank = request && request->comm != MPI_COMM_NULL + ? smpi_comm_rank(request->comm) + : -1; + TRACE_smpi_computing_out(rank); + + MPI_Group group = smpi_comm_group(request->comm); + int src_traced = smpi_group_rank(group, request->src); + int dst_traced = smpi_group_rank(group, request->dst); + int is_wait_for_receive = request->recv; + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__); +#endif smpi_mpi_wait(&request, &status); - XBT_DEBUG("MPI_Wait Status is : (source=%d tag=%d error=%d count=%d)", - status.MPI_SOURCE, status.MPI_TAG, status.MPI_ERROR, status.count); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); +#ifdef HAVE_TRACING + TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__); + if (is_wait_for_receive) { + TRACE_smpi_recv(rank, src_traced, dst_traced); + } + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_barrier(const char *const *action){ double clock = smpi_process_simulated_elapsed(); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__); +#endif smpi_mpi_barrier(MPI_COMM_WORLD); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); +#ifdef HAVE_TRACING + TRACE_smpi_collective_out(rank, -1, __FUNCTION__); + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_bcast(const char *const *action) { double size = parse_double(action[2]); double clock = smpi_process_simulated_elapsed(); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), 0); + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__); +#endif smpi_mpi_bcast(NULL, size, MPI_BYTE, 0, MPI_COMM_WORLD); - - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); +#ifdef HAVE_TRACING + TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__); + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_reduce(const char *const *action) { double size = parse_double(action[2]); double clock = smpi_process_simulated_elapsed(); - smpi_mpi_reduce(NULL, NULL, size, MPI_BYTE, MPI_OP_NULL, 0, MPI_COMM_WORLD); - - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), 0); + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__); +#endif + smpi_mpi_reduce(NULL, NULL, size, MPI_BYTE, MPI_OP_NULL, 0, MPI_COMM_WORLD); +#ifdef HAVE_TRACING + TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__); + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } static void action_allReduce(const char *const *action) { double comm_size = parse_double(action[2]); double comp_size = parse_double(action[3]); double clock = smpi_process_simulated_elapsed(); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + TRACE_smpi_computing_out(rank); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__); +#endif smpi_mpi_reduce(NULL, NULL, comm_size, MPI_BYTE, MPI_OP_NULL, 0, MPI_COMM_WORLD); smpi_execute_flops(comp_size); smpi_mpi_bcast(NULL, comm_size, MPI_BYTE, 0, MPI_COMM_WORLD); - XBT_VERB("%s %f", xbt_str_join_array(action, " "), - smpi_process_simulated_elapsed()-clock); +#ifdef HAVE_TRACING + TRACE_smpi_collective_out(rank, -1, __FUNCTION__); + TRACE_smpi_computing_in(rank); +#endif + + if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ + char *name = xbt_str_join_array(action, " "); + XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock); + free(name); + } } void smpi_replay_init(int *argc, char***argv){ PMPI_Init(argc, argv); - _xbt_replay_action_init(); - - xbt_replay_action_register("init", action_init); - xbt_replay_action_register("finalize", action_finalize); - xbt_replay_action_register("comm_size",action_comm_size); - xbt_replay_action_register("send", action_send); - xbt_replay_action_register("Isend", action_Isend); - xbt_replay_action_register("recv", action_recv); - xbt_replay_action_register("Irecv", action_Irecv); - xbt_replay_action_register("wait", action_wait); - xbt_replay_action_register("barrier", action_barrier); - xbt_replay_action_register("bcast", action_bcast); - xbt_replay_action_register("reduce", action_reduce); - xbt_replay_action_register("allReduce",action_allReduce); - xbt_replay_action_register("compute", action_compute); + if (!smpi_process_index()){ + _xbt_replay_action_init(); + xbt_replay_action_register("init", action_init); + xbt_replay_action_register("finalize", action_finalize); + xbt_replay_action_register("comm_size",action_comm_size); + xbt_replay_action_register("send", action_send); + xbt_replay_action_register("Isend", action_Isend); + xbt_replay_action_register("recv", action_recv); + xbt_replay_action_register("Irecv", action_Irecv); + xbt_replay_action_register("wait", action_wait); + xbt_replay_action_register("barrier", action_barrier); + xbt_replay_action_register("bcast", action_bcast); + xbt_replay_action_register("reduce", action_reduce); + xbt_replay_action_register("allReduce",action_allReduce); + xbt_replay_action_register("compute", action_compute); + } xbt_replay_action_runner(*argc, *argv); } int smpi_replay_finalize(){ + if(!smpi_process_index()) + _xbt_replay_action_exit(); return PMPI_Finalize(); }