+
+ //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 || (request->flags & (ISEND|SSEND))){// issend should be treated as isend
+ //isend and send timings may be different
+ sleeptime = (request->flags & ISEND)? 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));
+ }
+
+ int async_small_thresh = sg_cfg_get_int("smpi/async_small_thresh");
+
+ xbt_mutex_t mut=smpi_process_remote_mailboxes_mutex(receiver);
+
+ if (async_small_thresh != 0 || request->flags & RMA)
+ xbt_mutex_acquire(mut);
+
+ if (!(async_small_thresh != 0 || request->flags & RMA)) {
+ mailbox = smpi_process_remote_mailbox(receiver);
+ }
+ else if (request->flags & RMA || request->size < async_small_thresh) { // eager mode
+ 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, (void*)request);
+ if(action ==NULL){
+ if (! (request->flags & SSEND)){
+ 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, (void*)request);
+ if(action ==NULL){
+ 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");
+ }