X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b531f578ec2baa41a140c677217934de645723f8..762107b960e67cbb9713d0750147372d2178ccbd:/src/smpi/smpi_replay.c diff --git a/src/smpi/smpi_replay.c b/src/smpi/smpi_replay.c index 11f9d1846b..6cbe6ae2d7 100644 --- a/src/smpi/smpi_replay.c +++ b/src/smpi/smpi_replay.c @@ -18,6 +18,11 @@ xbt_dynar_t *reqq = NULL; MPI_Datatype MPI_DEFAULT_TYPE; MPI_Datatype MPI_CURRENT_TYPE; +static int sendbuffer_size=0; +char* sendbuffer=NULL; +static int recvbuffer_size=0; +char* recvbuffer=NULL; + static void log_timed_action (const char *const *action, double clock){ if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ char *name = xbt_str_join_array(action, " "); @@ -26,6 +31,32 @@ static void log_timed_action (const char *const *action, double clock){ } } +//allocate a single buffer for all sends, growing it if needed +void* smpi_get_tmp_sendbuffer(int size){ + if (!smpi_process_get_replaying()) + return xbt_malloc(size); + if (sendbuffer_sizetype=TRACING_TEST; TRACE_smpi_testing_in(rank, extra); #endif - flag = smpi_mpi_test(&request, &status); + + flag = smpi_mpi_test(&request, &status); + XBT_DEBUG("MPI_Test result: %d", flag); /* push back request in dynar to be caught by a subsequent wait. if the test * did succeed, the request is now NULL. @@ -338,7 +373,7 @@ static void action_test(const char *const *action){ #ifdef HAVE_TRACING TRACE_smpi_testing_out(rank); #endif - + } log_timed_action (action, clock); } @@ -452,7 +487,9 @@ static void action_waitall(const char *const *action){ xbt_dynar_free(&recvs); #endif - xbt_dynar_free_container(&(reqq[smpi_process_index()])); + int freedrank=smpi_process_index(); + xbt_dynar_free_container(&(reqq[freedrank])); + reqq[freedrank]=xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref); } log_timed_action (action, clock); } @@ -504,12 +541,11 @@ static void action_bcast(const char *const *action) TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra); #endif - - mpi_coll_bcast_fun(NULL, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD); + void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE)); + mpi_coll_bcast_fun(sendbuf, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD); #ifdef HAVE_TRACING TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__); #endif - log_timed_action (action, clock); } @@ -527,6 +563,8 @@ static void action_reduce(const char *const *action) MPI_CURRENT_TYPE=decode_datatype(action[5]); } } + + #ifdef HAVE_TRACING int rank = smpi_process_index(); @@ -540,12 +578,13 @@ static void action_reduce(const char *const *action) TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); #endif - mpi_coll_reduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD); + void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + mpi_coll_reduce_fun(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD); smpi_execute_flops(comp_size); #ifdef HAVE_TRACING TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__); #endif - log_timed_action (action, clock); } @@ -567,12 +606,13 @@ static void action_allReduce(const char *const *action) { TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif - mpi_coll_allreduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD); + void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + mpi_coll_allreduce_fun(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD); smpi_execute_flops(comp_size); #ifdef HAVE_TRACING TRACE_smpi_collective_out(rank, -1, __FUNCTION__); #endif - log_timed_action (action, clock); } @@ -591,8 +631,8 @@ static void action_allToAll(const char *const *action) { MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE; MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE; } - void *send = xbt_malloc(send_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); - void *recv = xbt_malloc(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2)); + void *send = smpi_get_tmp_sendbuffer(send_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2)); #ifdef HAVE_TRACING int rank = smpi_process_index(); @@ -611,10 +651,8 @@ static void action_allToAll(const char *const *action) { #ifdef HAVE_TRACING TRACE_smpi_collective_out(rank, -1, __FUNCTION__); #endif - log_timed_action (action, clock); - xbt_free(send); - xbt_free(recv); + } @@ -643,14 +681,15 @@ static void action_gather(const char *const *action) { MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE; MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE; } - void *send = xbt_malloc(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); void *recv = NULL; - - int root=atoi(action[4]); - int rank = smpi_process_index(); + int root=0; + if(action[4]) + root=atoi(action[4]); + int rank = smpi_comm_rank(MPI_COMM_WORLD); if(rank==root) - recv = xbt_malloc(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2)); + recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2)); #ifdef HAVE_TRACING instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); @@ -661,19 +700,17 @@ static void action_gather(const char *const *action) { extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); - TRACE_smpi_collective_in(rank, root, __FUNCTION__, extra); + TRACE_smpi_collective_in(smpi_process_index(), root, __FUNCTION__, extra); #endif mpi_coll_gather_fun(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD); #ifdef HAVE_TRACING - TRACE_smpi_collective_out(rank, -1, __FUNCTION__); + TRACE_smpi_collective_out(smpi_process_index(), -1, __FUNCTION__); #endif - log_timed_action (action, clock); - xbt_free(send); - xbt_free(recv); + } @@ -706,7 +743,7 @@ static void action_gatherv(const char *const *action) { MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE; MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE; } - void *send = xbt_malloc(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); void *recv = NULL; for(i=0;idatatype1 = encode_datatype(MPI_CURRENT_TYPE); extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); - TRACE_smpi_collective_in(rank, root, __FUNCTION__, extra); + TRACE_smpi_collective_in(smpi_process_index(), root, __FUNCTION__, extra); #endif smpi_mpi_gatherv(send, send_size, MPI_CURRENT_TYPE, recv, recvcounts, disps, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD); #ifdef HAVE_TRACING - TRACE_smpi_collective_out(rank, -1, __FUNCTION__); + TRACE_smpi_collective_out(smpi_process_index(), -1, __FUNCTION__); #endif log_timed_action (action, clock); xbt_free(recvcounts); - xbt_free(send); - xbt_free(recv); xbt_free(disps); - } static void action_reducescatter(const char *const *action) { @@ -773,7 +807,7 @@ static void action_reducescatter(const char *const *action) { int *disps = xbt_new0(int, comm_size); int i=0; int rank = smpi_process_index(); - + int size = 0; if(action[3+comm_size]) MPI_CURRENT_TYPE=decode_datatype(action[3+comm_size]); else @@ -782,6 +816,7 @@ static void action_reducescatter(const char *const *action) { for(i=0;icomp_size = comp_size; extra->num_processes = comm_size; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif - mpi_coll_reduce_scatter_fun(NULL, NULL, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL, + void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *recvbuf = smpi_get_tmp_recvbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE)); + + mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD); smpi_execute_flops(comp_size); @@ -844,13 +881,13 @@ static void action_allgatherv(const char *const *action) { MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE; MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE; } - void *sendbuf = xbt_malloc(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE)); + void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE)); for(i=0;i2){ + char *endptr; + double value = strtod((*argv)[2], &endptr); + if (*endptr != '\0') + THROWF(unknown_error, 0, "%s is not a double", (*argv)[2]); + XBT_VERB("Delayed start for instance - Sleeping for %f flops ",value ); + smpi_execute_flops(value); + } xbt_replay_action_runner(*argc, *argv); } @@ -1023,18 +1066,25 @@ int smpi_replay_finalize(){ active_processes--; } - xbt_dynar_free_container(&(reqq[smpi_process_index()])); - if(!active_processes){ /* Last process alive speaking */ /* end the simulated timer */ sim_time = smpi_process_simulated_elapsed(); + } + + + xbt_dynar_free_container(&(reqq[smpi_process_index()])); + + if(!active_processes){ XBT_INFO("Simulation time %f", sim_time); _xbt_replay_action_exit(); + xbt_free(sendbuffer); + xbt_free(recvbuffer); xbt_free(reqq); reqq = NULL; } - mpi_coll_barrier_fun(MPI_COMM_WORLD); + + #ifdef HAVE_TRACING int rank = smpi_process_index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);