Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add support of MPI_Testall
authorAugustin Degomme <degomme@idpann.imag.fr>
Thu, 20 Sep 2012 17:54:24 +0000 (19:54 +0200)
committerAugustin Degomme <degomme@idpann.imag.fr>
Thu, 20 Sep 2012 17:54:24 +0000 (19:54 +0200)
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_pmpi.c

index f32ddc6..b0a8f5f 100644 (file)
@@ -118,6 +118,8 @@ void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
 int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
                      MPI_Status * status);
+int smpi_mpi_testall(int count, MPI_Request requests[],
+                     MPI_Status status[]);
 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
 MPI_Request smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag,
                     MPI_Status* status);
index 28566f5..c9443f0 100644 (file)
@@ -342,6 +342,43 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
   return flag;
 }
 
+
+int smpi_mpi_testall(int count, MPI_Request requests[],
+                     MPI_Status status[])
+{
+  xbt_dynar_t comms;
+  int i, flag, size;
+  int* map;
+
+  flag = 0;
+  if(count > 0) {
+    comms = xbt_dynar_new(sizeof(smx_action_t), NULL);
+    map = xbt_new(int, count);
+    size = 0;
+    for(i = 0; i < count; i++) {
+      if(requests[i]->action) {
+         xbt_dynar_push(comms, &requests[i]->action);
+         map[size] = i;
+         size++;
+      }
+    }
+
+    int n_finished=0;
+    while(n_finished<size) {
+      i = simcall_comm_testany(comms);
+      if(i != MPI_UNDEFINED) {
+        smpi_mpi_wait(&requests[i], &status[i]);
+      }
+      n_finished++;
+      XBT_DEBUG("TestAll, n finished %d on %d to test", n_finished, size);
+    }
+    flag = 1;
+    xbt_free(map);
+    xbt_dynar_free(&comms);
+  }
+  return flag;
+}
+
 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status){
   int flag=0;
   //FIXME find another wait to avoid busy waiting ?
index 561ad0d..5f7bd69 100644 (file)
@@ -1098,7 +1098,20 @@ int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
   return retval;
 }
 
+int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
+{
+  int retval;
 
+  smpi_bench_end();
+  if (flag == NULL) {
+    retval = MPI_ERR_ARG;
+  } else {
+    *flag = smpi_mpi_testall(count, requests, statuses);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
 
 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
   int retval;
@@ -2023,10 +2036,6 @@ int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int out
    return not_yet_implemented();
 }
 
-int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses) {
-   return not_yet_implemented();
-}
-
 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
    return not_yet_implemented();
 }