Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not request status if not requested by caller.
[simgrid.git] / src / smpi / smpi_base.c
index b032ec7..be4baca 100644 (file)
@@ -19,32 +19,6 @@ XBT_LOG_EXTERNAL_CATEGORY(smpi_receiver);
 XBT_LOG_EXTERNAL_CATEGORY(smpi_sender);
 XBT_LOG_EXTERNAL_CATEGORY(smpi_util);
 
-void smpi_process_init(int *argc, char ***argv)
-{
-  int index;
-  smpi_process_data_t data;
-  smx_process_t proc;
-
-  proc = SIMIX_process_self();
-  index = atoi((*argv)[1]);
-  data = smpi_process_remote_data(index);
-  SIMIX_process_set_data(proc, data);
-  if (*argc > 2) {
-    free((*argv)[1]);
-    memmove(&(*argv)[1], &(*argv)[2], sizeof(char *) * (*argc - 2));
-    (*argv)[(*argc) - 1] = NULL;
-  }
-  (*argc)--;
-  DEBUG2("<%d> New process in the game: %p", index, proc);
-}
-
-void smpi_process_destroy(void)
-{
-  int index = smpi_process_index();
-
-  DEBUG1("<%d> Process left the game", index);
-}
-
 static MPI_Request build_request(void *buf, int count,
                                  MPI_Datatype datatype, int src, int dst,
                                  int tag, MPI_Comm comm, unsigned flags)
@@ -215,6 +189,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
     status->MPI_ERROR = MPI_SUCCESS;
     status->count = SIMIX_communication_get_dst_buf_size((*request)->pair);
   }
+  SIMIX_communication_destroy((*request)->pair);
   print_request("finishing wait", *request);
   if ((*request)->complete == 1) {
     SIMIX_rdv_destroy((*request)->rdv);
@@ -311,22 +286,20 @@ int smpi_mpi_waitany(int count, MPI_Request requests[],
 void smpi_mpi_waitall(int count, MPI_Request requests[],
                       MPI_Status status[])
 {
-  int index;
+  int index, c;
   MPI_Status stat;
+  MPI_Status *pstat = status == MPI_STATUS_IGNORE ? MPI_STATUS_IGNORE : &stat;
 
-  while (count > 0) {
-    index = smpi_mpi_waitany(count, requests, &stat);
+  c = count;
+  while (c > 0) {
+    index = smpi_mpi_waitany(count, requests, pstat);
     if (index == MPI_UNDEFINED) {
       break;
     }
     if (status != MPI_STATUS_IGNORE) {
-      memcpy(&status[index], &stat, sizeof(stat));
+      memcpy(&status[index], pstat, sizeof *pstat);
     }
-    // FIXME: check this -v
-    // Move the last request to the found position
-    requests[index] = requests[count - 1];
-    requests[count - 1] = MPI_REQUEST_NULL;
-    count--;
+    c--;
   }
 }