X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/418017e9c1ea8822a5d5e981ebda05d0bfbae0d4..06a801de9f0c069a4198d071d57fcaf408e6f1e3:/src/smpi/smpi_base.cpp diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index c0ac9935de..fc2a0b0260 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -279,15 +279,14 @@ static MPI_Request build_request(void *buf, int count, MPI_Datatype datatype, in request->tag = tag; request->comm = comm; smpi_comm_use(request->comm); - request->action = NULL; + request->action = nullptr; request->flags = flags; request->detached = 0; - request->detached_sender = NULL; + request->detached_sender = nullptr; request->real_src = 0; - - request->truncated = 0; - request->real_size = 0; - request->real_tag = 0; + request->truncated = 0; + request->real_size = 0; + request->real_tag = 0; if (flags & PERSISTENT) request->refcount = 1; else @@ -348,7 +347,7 @@ void smpi_mpi_start(MPI_Request request) { smx_mailbox_t mailbox; - xbt_assert(!request->action, "Cannot (re)start a non-finished communication"); + xbt_assert(request->action == nullptr, "Cannot (re-)start unfinished communication"); request->flags &= ~PREPARED; request->flags &= ~FINISHED; request->refcount++; @@ -364,33 +363,37 @@ void smpi_mpi_start(MPI_Request request) if (async_small_thresh == 0 && (request->flags & RMA) == 0 ) { mailbox = smpi_process_mailbox(); - } else if (((request->flags & RMA) != 0) || static_cast(request->size) < async_small_thresh){ - //We have to check both mailboxes (because SSEND messages are sent to the large mbox). - //begin with the more appropriate one : the small one. + } + else if (((request->flags & RMA) != 0) || static_cast(request->size) < async_small_thresh) { + //We have to check both mailboxes (because SSEND messages are sent to the large mbox). + //begin with the more appropriate one : the small one. mailbox = smpi_process_mailbox_small(); XBT_DEBUG("Is there a corresponding send already posted in the small mailbox %p (in case of SSEND)?", mailbox); smx_synchro_t action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, static_cast(request)); - if(action == nullptr){ + if (action == nullptr) { mailbox = smpi_process_mailbox(); XBT_DEBUG("No, nothing in the small mailbox test the other one : %p", mailbox); action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, static_cast(request)); - if(action == nullptr){ + if (action == nullptr) { XBT_DEBUG("Still nothing, switch back to the small mailbox : %p", mailbox); mailbox = smpi_process_mailbox_small(); - } - }else{ + } + } + else { XBT_DEBUG("yes there was something for us in the large mailbox"); } - }else{ + } + else { mailbox = smpi_process_mailbox_small(); XBT_DEBUG("Is there a corresponding send already posted the small mailbox?"); - smx_synchro_t action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, (void*)request); + smx_synchro_t action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, (void*)request); - if(action == nullptr){ + if (action == nullptr) { XBT_DEBUG("No, nothing in the permanent receive mailbox"); mailbox = smpi_process_mailbox(); - }else{ + } + else { XBT_DEBUG("yes there was something for us in the small mailbox"); } } @@ -420,17 +423,40 @@ void smpi_mpi_start(MPI_Request request) } print_request("New send", request); + void* buf = request->buf; + if ( (request->flags & SSEND) == 0 + && ( (request->flags & RMA) != 0 || static_cast(request->size) < xbt_cfg_get_int("smpi/send-is-detached-thresh") ) ) { + void *oldbuf = NULL; + request->detached = 1; + XBT_DEBUG("Send request %p is detached", request); + request->refcount++; + if(request->old_type->sizeof_substruct == 0){ + oldbuf = request->buf; + if (!smpi_process_get_replaying() && oldbuf != NULL && request->size!=0){ + if((smpi_privatize_global_variables != 0) + && (static_cast(request->buf) >= smpi_start_data_exe) + && (static_cast(request->buf) < smpi_start_data_exe + smpi_size_data_exe )){ + XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment "); + smpi_switch_data_segment(request->src); + } + buf = xbt_malloc(request->size); + memcpy(buf,oldbuf,request->size); + XBT_DEBUG("buf %p copied into %p",oldbuf,buf); + } + } + } + //if we are giving back the control to the user without waiting for completion, we have to inject timings double sleeptime = 0.0; if(request->detached != 0 || ((request->flags & (ISEND|SSEND)) != 0)){// issend should be treated as isend //isend and send timings may be different - sleeptime = ((request->flags & ISEND) != 0)? smpi_ois(request->size) : smpi_os(request->size); + sleeptime = ((request->flags & ISEND) != 0) ? smpi_ois(request->size) : smpi_os(request->size); } if(sleeptime > 0.0){ simcall_process_sleep(sleeptime); - XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size)); - } + XBT_DEBUG("sending size of %zu : sleep %f ", request->size, sleeptime); + } int async_small_thresh = xbt_cfg_get_int("smpi/async-small-thresh"); @@ -446,50 +472,30 @@ void smpi_mpi_start(MPI_Request request) mailbox = smpi_process_remote_mailbox(receiver); XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %p?", mailbox); smx_synchro_t action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, static_cast(request)); - if(action == nullptr){ - if ((request->flags & SSEND) == 0){ - mailbox = smpi_process_remote_mailbox_small(receiver); - XBT_DEBUG("No, nothing in the large mailbox, message is to be sent on the small one %p", mailbox); - } else{ - mailbox = smpi_process_remote_mailbox_small(receiver); - XBT_DEBUG("SSEND : Is there a corresponding recv already posted in the small mailbox %p?", mailbox); - action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, static_cast(request)); - if(action == nullptr){ - XBT_DEBUG("No, we are first, send to large mailbox"); - mailbox = smpi_process_remote_mailbox(receiver); - } - } - }else{ + if (action == nullptr) { + if ((request->flags & SSEND) == 0){ + mailbox = smpi_process_remote_mailbox_small(receiver); + XBT_DEBUG("No, nothing in the large mailbox, message is to be sent on the small one %p", mailbox); + } + else { + mailbox = smpi_process_remote_mailbox_small(receiver); + XBT_DEBUG("SSEND : Is there a corresponding recv already posted in the small mailbox %p?", mailbox); + action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, static_cast(request)); + if (action == nullptr) { + XBT_DEBUG("No, we are first, send to large mailbox"); + mailbox = smpi_process_remote_mailbox(receiver); + } + } + } + else { XBT_DEBUG("Yes there was something for us in the large mailbox"); } - }else{ + } + else { mailbox = smpi_process_remote_mailbox(receiver); XBT_DEBUG("Send request %p is in the large mailbox %p (buf: %p)",mailbox, request,request->buf); } - void* buf = request->buf; - if ( ((request->flags & SSEND) == 0) && (((request->flags & RMA) != 0) || - (static_cast(request->size) < xbt_cfg_get_int("smpi/send-is-detached-thresh")))) { - void *oldbuf = NULL; - request->detached = 1; - XBT_DEBUG("Send request %p is detached", request); - request->refcount++; - if(request->old_type->sizeof_substruct == 0){ - oldbuf = request->buf; - if (!smpi_process_get_replaying() && oldbuf != NULL && request->size!=0){ - if((smpi_privatize_global_variables != 0) - && (static_cast(request->buf) >= smpi_start_data_exe) - && (static_cast(request->buf) < smpi_start_data_exe + smpi_size_data_exe )){ - XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment "); - smpi_switch_data_segment(request->src); - } - buf = xbt_malloc(request->size); - memcpy(buf,oldbuf,request->size); - XBT_DEBUG("buf %p copied into %p",oldbuf,buf); - } - } - } - // we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later request->real_size=request->size; request->action = simcall_comm_isend(SIMIX_process_from_PID(request->src+1), mailbox, request->size, -1.0, @@ -502,7 +508,7 @@ void smpi_mpi_start(MPI_Request request) XBT_DEBUG("send simcall posted"); /* FIXME: detached sends are not traceable (request->action == nullptr) */ - if (request->action) + if (request->action != nullptr) simcall_set_category(request->action, TRACE_internal_smpi_get_category()); if (async_small_thresh != 0 || ((request->flags & RMA)!=0)) @@ -868,7 +874,7 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* request->action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, static_cast(request)); } - if (request->action){ + if (request->action != nullptr){ simgrid::simix::Comm *sync_comm = static_cast(request->action); MPI_Request req = static_cast(sync_comm->src_data); *flag = 1;