X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/48eccb2c1532e35819830ca56fad7cf89887359f..3fab894cbce7d5bdd43a6fc9aa647b3809d63507:/src/smpi/smpi_base.cpp diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index 62699a1bc0..eeaada79e5 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "private.h" #include "xbt/virtu.h" #include "mc/mc.h" @@ -15,6 +17,8 @@ #include "simgrid/sg_config.h" #include "colls/colls.h" +#include "src/simix/SynchroComm.hpp" + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)"); static int match_recv(void* a, void* b, smx_synchro_t ignored) { @@ -68,13 +72,17 @@ typedef struct s_smpi_factor_multival { // FIXME: this should be merged (dedupli int nb_values; double values[4];//arbitrary set to 4 } s_smpi_factor_multival_t; + xbt_dynar_t smpi_os_values = NULL; xbt_dynar_t smpi_or_values = NULL; xbt_dynar_t smpi_ois_values = NULL; -double smpi_wtime_sleep = 0.0; -double smpi_iprobe_sleep = 1e-4; -double smpi_test_sleep = 1e-4; +static simgrid::config::Flag smpi_wtime_sleep( + "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0); +static simgrid::config::Flag smpi_iprobe_sleep( + "smpi/iprobe", "Minimum time to inject inside a call to MPI_Iprobe", 1e-4); +static simgrid::config::Flag smpi_test_sleep( + "smpi/test", "Minimum time to inject inside a call to MPI_Test", 1e-4); static int factor_cmp(const void *pa, const void *pb) { @@ -687,10 +695,11 @@ static void finish_wait(MPI_Request * request, MPI_Status * status) if(req->flags & RECV) subtype->unserialize(req->buf, req->old_buf, req->real_size/smpi_datatype_size(datatype) , datatype->substruct, req->op); - if(req->detached == 0) free(req->buf); + xbt_free(req->buf); }else if(req->flags & RECV){//apply op on contiguous buffer for accumulate int n =req->real_size/smpi_datatype_size(datatype); smpi_op_apply(req->op, req->buf, req->old_buf, &n, &datatype); + xbt_free(req->buf); } } } @@ -847,7 +856,8 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* } if (request->action){ - MPI_Request req = (MPI_Request)SIMIX_comm_get_src_data(request->action); + simgrid::simix::Comm *sync_comm = static_cast(request->action); + MPI_Request req = (MPI_Request)sync_comm->src_data; *flag = 1; if(status != MPI_STATUS_IGNORE && !(req->flags & PREPARED)) { status->MPI_SOURCE = smpi_group_rank(smpi_comm_group(comm), req->src); @@ -874,14 +884,10 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status) return; } - if ((*request)->action != NULL) { // this is not a detached send + if ((*request)->action != NULL) + // this is not a detached send simcall_comm_wait((*request)->action, -1.0); - if((MC_is_active() || MC_record_replay_is_active()) && (*request)->action) - (*request)->action->comm.dst_data = NULL; // dangling pointer : dst_data is freed with a wait, need to set it to - // NULL for system state comparison - } - finish_wait(request, status); if (*request != MPI_REQUEST_NULL && ((*request)->flags & NON_PERSISTENT)) *request = MPI_REQUEST_NULL; @@ -1305,10 +1311,7 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat void **tmpbufs; char* sendtmpbuf = (char*) sendbuf; - if( sendbuf == MPI_IN_PLACE ) { - sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype)); - smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype); - } + rank = smpi_comm_rank(comm); size = smpi_comm_size(comm); @@ -1317,6 +1320,11 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count, datatype, op, root, comm); return; } + + if( sendbuf == MPI_IN_PLACE ) { + sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype)); + smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype); + } if(rank != root) { // Send buffer to root @@ -1364,9 +1372,9 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat xbt_free(tmpbufs); xbt_free(requests); - if( sendbuf == MPI_IN_PLACE ) { - smpi_free_tmp_buffer(sendtmpbuf); - } + } + if( sendbuf == MPI_IN_PLACE ) { + smpi_free_tmp_buffer(sendtmpbuf); } }