Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
provide Test and Wait functions with a better MPI_STATUS_IGNORE and MPI_REQUEST_NULL...
[simgrid.git] / src / smpi / smpi_pmpi.c
index ebaa2f1..64f0161 100644 (file)
@@ -903,8 +903,8 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
-  int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int src_traced = smpi_group_index(smpi_comm_group(comm), src);
   TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
 #endif
   if (request == NULL) {
@@ -931,9 +931,9 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
+  int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
   TRACE_smpi_send(rank, rank, dst_traced);
 #endif
@@ -963,8 +963,8 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
-  int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int src_traced = smpi_group_index(smpi_comm_group(comm), src);
   TRACE_smpi_computing_out(rank);
 
   TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
@@ -977,7 +977,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
   }
 #ifdef HAVE_TRACING
   //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
-  if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE);
+  if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
   TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
   TRACE_smpi_recv(rank, src_traced, rank);
   TRACE_smpi_computing_in(rank);
@@ -993,9 +993,9 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
+  int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
   TRACE_smpi_send(rank, rank, dst_traced);
 #endif
@@ -1022,10 +1022,10 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
-  int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
+  int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+  int src_traced = smpi_group_index(smpi_comm_group(comm), src);
   TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
   TRACE_smpi_send(rank, rank, dst_traced);
   TRACE_smpi_send(rank, src_traced, rank);
@@ -1074,9 +1074,10 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
   int retval;
 
   smpi_bench_end();
-  if (request == NULL || flag == NULL) {
+  if (request == MPI_REQUEST_NULL || flag == NULL) {
     retval = MPI_ERR_ARG;
   } else if (*request == MPI_REQUEST_NULL) {
+    *flag=TRUE;
     retval = MPI_ERR_REQUEST;
   } else {
     *flag = smpi_mpi_test(request, status);
@@ -1159,13 +1160,13 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
   smpi_bench_end();
 #ifdef HAVE_TRACING
   int rank = request && (*request)->comm != MPI_COMM_NULL
-      ? smpi_comm_rank((*request)->comm)
+      ? smpi_process_index()
       : -1;
   TRACE_smpi_computing_out(rank);
 
   MPI_Group group = smpi_comm_group((*request)->comm);
-  int src_traced = smpi_group_rank(group, (*request)->src);
-  int dst_traced = smpi_group_rank(group, (*request)->dst);
+  int src_traced = smpi_group_index(group, (*request)->src);
+  int dst_traced = smpi_group_index(group, (*request)->dst);
   int is_wait_for_receive = (*request)->recv;
   TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
 #endif
@@ -1223,7 +1224,7 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
       xbt_free(t);
     }
   }
-  int rank_traced = smpi_comm_rank(MPI_COMM_WORLD);
+  int rank_traced = smpi_process_index();
   TRACE_smpi_computing_out(rank_traced);
 
   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
@@ -1280,7 +1281,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
     xbt_free(adst);
     xbt_free(arecv);
   }
-  int rank_traced = smpi_comm_rank (MPI_COMM_WORLD);
+  int rank_traced = smpi_process_index();
   TRACE_smpi_computing_out(rank_traced);
 
   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
@@ -1323,15 +1324,32 @@ int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
   return retval;
 }
 
+int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
+                 int* indices, MPI_Status status[])
+{
+  int retval;
+
+   smpi_bench_end();
+   if (outcount == NULL || indices == NULL) {
+     retval = MPI_ERR_ARG;
+   } else {
+     *outcount = smpi_mpi_testsome(incount, requests, indices, status);
+     retval = MPI_SUCCESS;
+   }
+   smpi_bench_begin();
+   return retval;
+}
+
+
 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
 {
   int retval;
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1354,7 +1372,7 @@ int PMPI_Barrier(MPI_Comm comm)
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1380,9 +1398,9 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1411,9 +1429,9 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1444,7 +1462,7 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1473,7 +1491,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1505,9 +1523,10 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1536,9 +1555,9 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1568,9 +1587,9 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
-  int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
   if (comm == MPI_COMM_NULL) {
@@ -1596,7 +1615,7 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1625,7 +1644,7 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1652,7 +1671,7 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
 {
   int retval, i, size, count;
   int *displs;
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
@@ -1699,7 +1718,7 @@ int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -1744,7 +1763,7 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
-  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
@@ -2024,10 +2043,6 @@ int PMPI_Buffer_detach(void* buffer, int* size) {
    return not_yet_implemented();
 }
 
-int PMPI_Testsome(int incount, MPI_Request* requests, int* outcount, int* indices, MPI_Status* statuses) {
-   return not_yet_implemented();
-}
-
 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
    return not_yet_implemented();
 }