Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add smpi_status.cpp and hpp.
authordegomme <augustin.degomme@unibas.ch>
Sun, 19 Mar 2017 00:23:22 +0000 (01:23 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Sun, 19 Mar 2017 00:23:22 +0000 (01:23 +0100)
That's rather empty, as actually MPI_Status has to stay in C (its fields being public to the user codes).

include/smpi/forward.hpp
src/smpi/colls/allgather/allgather-rdb.cpp
src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp
src/smpi/colls/alltoall/alltoall-rdb.cpp
src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp
src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp
src/smpi/private.h
src/smpi/smpi_global.cpp
src/smpi/smpi_pmpi.cpp
src/smpi/smpi_request.cpp
tools/cmake/DefinePackages.cmake

index acbc310..436c9b3 100644 (file)
@@ -22,7 +22,9 @@ class Group;
 class Info;
 class Keyval;
 class Op;
 class Info;
 class Keyval;
 class Op;
+class Process;
 class Request;
 class Request;
+class Status;
 class Topo;
 class Topo_Cart;
 class Topo_Graph;
 class Topo;
 class Topo_Cart;
 class Topo_Graph;
index 6d2950a..4564a40 100644 (file)
@@ -64,7 +64,7 @@ Coll_allgather_rdb::allgather(void *sbuf, int send_count,
       Request::sendrecv(recv_ptr + send_offset, curr_count, send_type, dst,
                    tag, recv_ptr + recv_offset, mask * recv_count,
                    recv_type, dst, tag, comm, &status);
       Request::sendrecv(recv_ptr + send_offset, curr_count, send_type, dst,
                    tag, recv_ptr + recv_offset, mask * recv_count,
                    recv_type, dst, tag, comm, &status);
-      last_recv_count = smpi_mpi_get_count(&status, recv_type);
+      last_recv_count = Status::get_count(&status, recv_type);
       curr_count += last_recv_count;
     }
 
       curr_count += last_recv_count;
     }
 
@@ -117,7 +117,7 @@ Coll_allgather_rdb::allgather(void *sbuf, int send_count,
                    recv_type, dst, tag, comm, &status);
           // num_procs_completed is also equal to the no. of processes
           // whose data we don't have
                    recv_type, dst, tag, comm, &status);
           // num_procs_completed is also equal to the no. of processes
           // whose data we don't have
-          last_recv_count = smpi_mpi_get_count(&status, recv_type);
+          last_recv_count = Status::get_count(&status, recv_type);
           curr_count += last_recv_count;
         }
         tmp_mask >>= 1;
           curr_count += last_recv_count;
         }
         tmp_mask >>= 1;
index 5d5f945..2f19e83 100644 (file)
@@ -109,7 +109,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv (
                         comm, &status);
       /* for convenience, recv is posted for a bigger amount
          than will be sent */
                         comm, &status);
       /* for convenience, recv is posted for a bigger amount
          than will be sent */
-      last_recv_cnt=smpi_mpi_get_count(&status, recvtype);
+      last_recv_cnt=Status::get_count(&status, recvtype);
       curr_cnt += last_recv_cnt;
     }
 
       curr_cnt += last_recv_cnt;
     }
 
@@ -188,7 +188,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv (
                         comm, &status);
           /* for convenience, recv is posted for a
              bigger amount than will be sent */
                         comm, &status);
           /* for convenience, recv is posted for a
              bigger amount than will be sent */
-          last_recv_cnt=smpi_mpi_get_count(&status, recvtype);
+          last_recv_cnt=Status::get_count(&status, recvtype);
           curr_cnt += last_recv_cnt;
         }
         tmp_mask >>= 1;
           curr_cnt += last_recv_cnt;
         }
         tmp_mask >>= 1;
index f41ded7..2e9aa0e 100644 (file)
@@ -78,7 +78,7 @@ int Coll_alltoall_rdb::alltoall(void *send_buff, int send_count,
                    tmp_buff + recv_offset, mask * recv_count * num_procs,
                    recv_type, dst, tag, comm, &status);
 
                    tmp_buff + recv_offset, mask * recv_count * num_procs,
                    recv_type, dst, tag, comm, &status);
 
-      last_recv_count = smpi_mpi_get_count(&status, recv_type);
+      last_recv_count = Status::get_count(&status, recv_type);
       curr_size += last_recv_count;
     }
 
       curr_size += last_recv_count;
     }
 
@@ -131,7 +131,7 @@ int Coll_alltoall_rdb::alltoall(void *send_buff, int send_count,
                    mask * num_procs * send_count, send_type, dst,
                    tag, comm, &status);
 
                    mask * num_procs * send_count, send_type, dst,
                    tag, comm, &status);
 
-          last_recv_count = smpi_mpi_get_count(&status, send_type);
+          last_recv_count = Status::get_count(&status, send_type);
           curr_size += last_recv_count;
         }
 
           curr_size += last_recv_count;
         }
 
index 3649c03..4adaa00 100644 (file)
@@ -105,7 +105,7 @@ Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count,
       else {
         Request::recv((char *) buff + relative_rank * scatter_size, recv_size,
                  MPI_BYTE, src, tag, comm, &status);
       else {
         Request::recv((char *) buff + relative_rank * scatter_size, recv_size,
                  MPI_BYTE, src, tag, comm, &status);
-        curr_size = smpi_mpi_get_count(&status, MPI_BYTE);
+        curr_size = Status::get_count(&status, MPI_BYTE);
       }
       break;
     }
       }
       break;
     }
index 9a94599..cb88efc 100644 (file)
@@ -55,7 +55,7 @@ static int scatter_for_bcast(
                                          recv_size, MPI_BYTE, src,
                                          COLL_TAG_BCAST, comm, &status);
                 /* query actual size of data received */
                                          recv_size, MPI_BYTE, src,
                                          COLL_TAG_BCAST, comm, &status);
                 /* query actual size of data received */
-                curr_size=smpi_mpi_get_count(&status, MPI_BYTE);
+                curr_size=Status::get_count(&status, MPI_BYTE);
             }
             break;
         }
             }
             break;
         }
@@ -210,7 +210,7 @@ Coll_bcast_scatter_rdb_allgather::bcast (
                                          ((char *)tmp_buf + recv_offset),
                                          (nbytes-recv_offset < 0 ? 0 : nbytes-recv_offset), 
                                          MPI_BYTE, dst, COLL_TAG_BCAST, comm, &status);
                                          ((char *)tmp_buf + recv_offset),
                                          (nbytes-recv_offset < 0 ? 0 : nbytes-recv_offset), 
                                          MPI_BYTE, dst, COLL_TAG_BCAST, comm, &status);
-            recv_size=smpi_mpi_get_count(&status, MPI_BYTE);
+            recv_size=Status::get_count(&status, MPI_BYTE);
             curr_size += recv_size;
         }
 
             curr_size += recv_size;
         }
 
@@ -293,7 +293,7 @@ Coll_bcast_scatter_rdb_allgather::bcast (
                                              comm, &status);
                     /* nprocs_completed is also equal to the no. of processes
                        whose data we don't have */
                                              comm, &status);
                     /* nprocs_completed is also equal to the no. of processes
                        whose data we don't have */
-                    recv_size=smpi_mpi_get_count(&status, MPI_BYTE);
+                    recv_size=Status::get_count(&status, MPI_BYTE);
                     curr_size += recv_size;
                     /* printf("Rank %d, recv from %d, offset %d, size %d\n", rank, dst, offset, recv_size);
                        fflush(stdout);*/
                     curr_size += recv_size;
                     /* printf("Rank %d, recv from %d, offset %d, size %d\n", rank, dst, offset, recv_size);
                        fflush(stdout);*/
index 047b7a8..cfb141c 100644 (file)
@@ -26,6 +26,7 @@
 #include "src/smpi/smpi_datatype.hpp"
 #include "src/smpi/smpi_datatype_derived.hpp"
 #include "src/smpi/smpi_request.hpp"
 #include "src/smpi/smpi_datatype.hpp"
 #include "src/smpi/smpi_datatype_derived.hpp"
 #include "src/smpi/smpi_request.hpp"
+#include "src/smpi/smpi_status.hpp"
 #include "src/smpi/smpi_win.hpp"
 SG_BEGIN_DECL()
 
 #include "src/smpi/smpi_win.hpp"
 SG_BEGIN_DECL()
 
@@ -93,10 +94,6 @@ XBT_PRIVATE void smpi_global_destroy();
 XBT_PRIVATE double smpi_mpi_wtime();
 XBT_PRIVATE void smpi_mpi_init();
 
 XBT_PRIVATE double smpi_mpi_wtime();
 XBT_PRIVATE void smpi_mpi_init();
 
-XBT_PRIVATE void smpi_empty_status(MPI_Status * status);
-XBT_PRIVATE int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
-
-
 // utilities
 extern XBT_PRIVATE double smpi_cpu_threshold;
 extern XBT_PRIVATE double smpi_host_speed;
 // utilities
 extern XBT_PRIVATE double smpi_cpu_threshold;
 extern XBT_PRIVATE double smpi_host_speed;
index d5de927..6878d5d 100644 (file)
@@ -532,17 +532,3 @@ double smpi_mpi_wtime(){
   return time;
 }
 
   return time;
 }
 
-void smpi_empty_status(MPI_Status * status)
-{
-  if(status != MPI_STATUS_IGNORE) {
-    status->MPI_SOURCE = MPI_ANY_SOURCE;
-    status->MPI_TAG = MPI_ANY_TAG;
-    status->MPI_ERROR = MPI_SUCCESS;
-    status->count=0;
-  }
-}
-
-int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
-{
-  return status->count / datatype->size();
-}
index 7569a88..33038ba 100644 (file)
@@ -873,7 +873,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (src == MPI_PROC_NULL) {
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (src == MPI_PROC_NULL) {
-    smpi_empty_status(status);
+    Status::empty(status);
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
@@ -1019,7 +1019,7 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dst,
   } else if (!sendtype->is_valid() || !recvtype->is_valid()) {
     retval = MPI_ERR_TYPE;
   } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
   } else if (!sendtype->is_valid() || !recvtype->is_valid()) {
     retval = MPI_ERR_TYPE;
   } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
-    smpi_empty_status(status);
+    Status::empty(status);
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval             = MPI_SUCCESS;
   }else if (dst >= comm->group()->size() || dst <0 ||
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval             = MPI_SUCCESS;
   }else if (dst >= comm->group()->size() || dst <0 ||
@@ -1095,7 +1095,7 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
     retval = MPI_ERR_ARG;
   } else if (*request == MPI_REQUEST_NULL) {
     *flag= true;
     retval = MPI_ERR_ARG;
   } else if (*request == MPI_REQUEST_NULL) {
     *flag= true;
-    smpi_empty_status(status);
+    Status::empty(status);
     retval = MPI_SUCCESS;
   } else {
     int rank = ((*request)->comm() != MPI_COMM_NULL) ? smpi_process()->index() : -1;
     retval = MPI_SUCCESS;
   } else {
     int rank = ((*request)->comm() != MPI_COMM_NULL) ? smpi_process()->index() : -1;
@@ -1152,7 +1152,7 @@ int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
   } else if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (source == MPI_PROC_NULL) {
   } else if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (source == MPI_PROC_NULL) {
-    smpi_empty_status(status);
+    Status::empty(status);
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else {
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else {
@@ -1173,7 +1173,7 @@ int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* statu
     retval = MPI_ERR_COMM;
   } else if (source == MPI_PROC_NULL) {
     *flag=true;
     retval = MPI_ERR_COMM;
   } else if (source == MPI_PROC_NULL) {
     *flag=true;
-    smpi_empty_status(status);
+    Status::empty(status);
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else {
     status->MPI_SOURCE = MPI_PROC_NULL;
     retval = MPI_SUCCESS;
   } else {
@@ -1190,7 +1190,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
 
   smpi_bench_end();
 
 
   smpi_bench_end();
 
-  smpi_empty_status(status);
+  Status::empty(status);
 
   if (request == nullptr) {
     retval = MPI_ERR_ARG;
 
   if (request == nullptr) {
     retval = MPI_ERR_ARG;
@@ -2154,7 +2154,7 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
     } else if (status->count % size != 0) {
       return MPI_UNDEFINED;
     } else {
     } else if (status->count % size != 0) {
       return MPI_UNDEFINED;
     } else {
-      *count = smpi_mpi_get_count(status, datatype);
+      *count = Status::get_count(status, datatype);
       return MPI_SUCCESS;
     }
   }
       return MPI_SUCCESS;
     }
   }
index ab1b5f0..46061fb 100644 (file)
@@ -567,7 +567,7 @@ int Request::test(MPI_Request * request, MPI_Status * status) {
   if(smpi_test_sleep > 0)  
     simcall_process_sleep(nsleeps*smpi_test_sleep);
 
   if(smpi_test_sleep > 0)  
     simcall_process_sleep(nsleeps*smpi_test_sleep);
 
-  smpi_empty_status(status);
+  Status::empty(status);
   int flag = 1;
   if (((*request)->flags_ & PREPARED) == 0) {
     if ((*request)->action_ != nullptr)
   int flag = 1;
   if (((*request)->flags_ & PREPARED) == 0) {
     if ((*request)->action_ != nullptr)
@@ -650,7 +650,7 @@ int Request::testany(int count, MPI_Request requests[], int *index, MPI_Status *
   } else {
       //all requests are null or inactive, return true
       flag = 1;
   } else {
       //all requests are null or inactive, return true
       flag = 1;
-      smpi_empty_status(status);
+      Status::empty(status);
   }
 
   return flag;
   }
 
   return flag;
@@ -669,7 +669,7 @@ int Request::testall(int count, MPI_Request requests[], MPI_Status status[])
           requests[i]=MPI_REQUEST_NULL;
       }
     }else{
           requests[i]=MPI_REQUEST_NULL;
       }
     }else{
-      smpi_empty_status(pstat);
+      Status::empty(pstat);
     }
     if(status != MPI_STATUSES_IGNORE) {
       status[i] = *pstat;
     }
     if(status != MPI_STATUSES_IGNORE) {
       status[i] = *pstat;
@@ -744,7 +744,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
 void Request::finish_wait(MPI_Request* request, MPI_Status * status)
 {
   MPI_Request req = *request;
 void Request::finish_wait(MPI_Request* request, MPI_Status * status)
 {
   MPI_Request req = *request;
-  smpi_empty_status(status);
+  Status::empty(status);
 
   if(!((req->detached_ != 0) && ((req->flags_ & SEND) != 0)) && ((req->flags_ & PREPARED) == 0)){
     if(status != MPI_STATUS_IGNORE) {
 
   if(!((req->detached_ != 0) && ((req->flags_ & SEND) != 0)) && ((req->flags_ & PREPARED) == 0)){
     if(status != MPI_STATUS_IGNORE) {
@@ -805,7 +805,7 @@ void Request::wait(MPI_Request * request, MPI_Status * status)
 {
   (*request)->print_request("Waiting");
   if ((*request)->flags_ & PREPARED) {
 {
   (*request)->print_request("Waiting");
   if ((*request)->flags_ & PREPARED) {
-    smpi_empty_status(status);
+    Status::empty(status);
     return;
   }
 
     return;
   }
 
@@ -872,7 +872,7 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status)
   }
 
   if (index==MPI_UNDEFINED)
   }
 
   if (index==MPI_UNDEFINED)
-    smpi_empty_status(status);
+    Status::empty(status);
 
   return index;
 }
 
   return index;
 }
@@ -893,9 +893,9 @@ int Request::waitall(int count, MPI_Request requests[], MPI_Status status[])
   if (status != MPI_STATUSES_IGNORE) {
     for (int c = 0; c < count; c++) {
       if (requests[c] == MPI_REQUEST_NULL || requests[c]->dst_ == MPI_PROC_NULL || (requests[c]->flags_ & PREPARED)) {
   if (status != MPI_STATUSES_IGNORE) {
     for (int c = 0; c < count; c++) {
       if (requests[c] == MPI_REQUEST_NULL || requests[c]->dst_ == MPI_PROC_NULL || (requests[c]->flags_ & PREPARED)) {
-        smpi_empty_status(&status[c]);
+        Status::empty(&status[c]);
       } else if (requests[c]->src_ == MPI_PROC_NULL) {
       } else if (requests[c]->src_ == MPI_PROC_NULL) {
-        smpi_empty_status(&status[c]);
+        Status::empty(&status[c]);
         status[c].MPI_SOURCE = MPI_PROC_NULL;
       }
     }
         status[c].MPI_SOURCE = MPI_PROC_NULL;
       }
     }
index 59e496d..5aa4170 100644 (file)
@@ -236,6 +236,8 @@ set(SMPI_SRC
   src/smpi/smpi_replay.cpp
   src/smpi/smpi_request.cpp
   src/smpi/smpi_request.hpp
   src/smpi/smpi_replay.cpp
   src/smpi/smpi_request.cpp
   src/smpi/smpi_request.hpp
+  src/smpi/smpi_status.cpp
+  src/smpi/smpi_status.hpp
   src/smpi/smpi_win.cpp
   src/smpi/smpi_win.hpp
   src/smpi/smpi_topo.cpp
   src/smpi/smpi_win.cpp
   src/smpi/smpi_win.hpp
   src/smpi/smpi_topo.cpp