Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
leak --
[simgrid.git] / src / smpi / smpi_base.c
index 562ddde..38011e6 100644 (file)
@@ -352,7 +352,7 @@ void smpi_mpi_start(MPI_Request request)
     int receiver = request->dst;//smpi_group_index(smpi_comm_group(request->comm), request->dst);
 
     #ifdef HAVE_TRACING
-      int rank = smpi_process_index();
+      int rank = request->src;
       if (TRACE_smpi_view_internals()) {
         TRACE_smpi_send(rank, rank, receiver,request->size);
       }
@@ -373,6 +373,7 @@ void smpi_mpi_start(MPI_Request request)
     if ( (! (request->flags & SSEND)) && (request->size < sg_cfg_get_int("smpi/send_is_detached_thres"))) {
       void *oldbuf = NULL;
       request->detached = 1;
+      XBT_DEBUG("Send request %p is detached", request);
       request->refcount++;
       if(request->old_type->has_subtype == 0){
         oldbuf = request->buf;
@@ -381,13 +382,13 @@ void smpi_mpi_start(MPI_Request request)
              && ((char*)request->buf >= start_data_exe)
              && ((char*)request->buf < start_data_exe + size_data_exe )){
             XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment ");
-                   switch_data_segment(smpi_process_index());
+                   switch_data_segment(request->src);
          }
           buf = xbt_malloc(request->size);
           memcpy(buf,oldbuf,request->size);
+          XBT_DEBUG("buf %p copied into %p",oldbuf,buf);
         }
       }
-      XBT_DEBUG("Send request %p is detached; buf %p copied into %p",request,oldbuf,request->buf);
     }
 
     // we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
@@ -406,9 +407,8 @@ void smpi_mpi_start(MPI_Request request)
         simcall_process_sleep(sleeptime);
         XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size));
     }
-
     request->action =
-      simcall_comm_isend(mailbox, request->size, -1.0,
+      simcall_comm_isend(SIMIX_process_from_PID(request->src+1), mailbox, request->size, -1.0,
                          buf, request->real_size,
                          &match_send,
                          &xbt_free_f, // how to free the userdata if a detached send fails
@@ -634,18 +634,17 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
             switch_data_segment(smpi_process_index());
         }
       }
-      if(req->flags & RECV) {
-
-        if(datatype->has_subtype == 1){
-          // This part handles the problem of non-contignous memory
-          // the unserialization at the reception
-          s_smpi_subtype_t *subtype = datatype->substruct;
-            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);
-        }else{//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);
-        }
+
+      if(datatype->has_subtype == 1){
+        // This part handles the problem of non-contignous memory
+        // the unserialization at the reception
+        s_smpi_subtype_t *subtype = datatype->substruct;
+        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);
+      }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);
       }
     }
     smpi_comm_unuse(req->comm);