Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add support for Ssend/Issend in SMPI
authorAugustin Degomme <degomme@idpann.imag.fr>
Mon, 11 Feb 2013 16:43:44 +0000 (17:43 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Mon, 11 Feb 2013 16:43:44 +0000 (17:43 +0100)
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_pmpi.c

index 148f4b0..15865c7 100644 (file)
@@ -22,8 +22,9 @@ typedef struct s_smpi_process_data *smpi_process_data_t;
 #define NON_PERSISTENT 0x2
 #define SEND           0x4
 #define RECV           0x8
 #define NON_PERSISTENT 0x2
 #define SEND           0x4
 #define RECV           0x8
-#define RECV_DELETE     0x10
-
+#define RECV_DELETE    0x10
+#define ISEND          0x20
+#define SSEND          0x40
 // this struct is here to handle the problem of non-contignous data
 // for each such structure these function should be implemented (vector
 // index hvector hindex struct)
 // this struct is here to handle the problem of non-contignous data
 // for each such structure these function should be implemented (vector
 // index hvector hindex struct)
@@ -159,6 +160,8 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
                                int dst, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
                                int src, int tag, MPI_Comm comm);
                                int dst, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
                                int src, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype,
+                               int dst, int tag, MPI_Comm comm);
 void smpi_mpi_start(MPI_Request request);
 void smpi_mpi_startall(int count, MPI_Request * requests);
 void smpi_mpi_request_free(MPI_Request * request);
 void smpi_mpi_start(MPI_Request request);
 void smpi_mpi_startall(int count, MPI_Request * requests);
 void smpi_mpi_request_free(MPI_Request * request);
@@ -166,6 +169,10 @@ MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
                             int dst, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
                            int dst, int tag, MPI_Comm comm);
                             int dst, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
                            int dst, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype,
+                           int dst, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype,
+                           int dst, int tag, MPI_Comm comm);
 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
                             int src, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
                             int src, int tag, MPI_Comm comm);
 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
index 19cce6b..19cd933 100644 (file)
@@ -266,6 +266,16 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
   return request;
 }
 
   return request;
 }
 
+MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype,
+                               int dst, int tag, MPI_Comm comm)
+{
+  MPI_Request request =
+    build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
+                  comm, PERSISTENT | SSEND | SEND);
+  request->refcount++;
+  return request;
+}
+
 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
                                int src, int tag, MPI_Comm comm)
 {
 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
                                int src, int tag, MPI_Comm comm)
 {
@@ -313,7 +323,7 @@ void smpi_mpi_start(MPI_Request request)
       XBT_DEBUG("Send request %p is not in the permanent receive mailbox (buf: %p)",request,request->buf);
       mailbox = smpi_process_remote_mailbox(receiver);
     }
       XBT_DEBUG("Send request %p is not in the permanent receive mailbox (buf: %p)",request,request->buf);
       mailbox = smpi_process_remote_mailbox(receiver);
     }
-    if (request->size < sg_cfg_get_int("smpi/send_is_detached_thres") ) { //(FIXME: this limit should be configurable)
+    if ( (! (request->flags & SSEND)) && (request->size < sg_cfg_get_int("smpi/send_is_detached_thres"))) {
       void *oldbuf = NULL;
       request->detached = 1;
       request->refcount++;
       void *oldbuf = NULL;
       request->detached = 1;
       request->refcount++;
@@ -393,8 +403,26 @@ MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
 {
   MPI_Request request =
       build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
 {
   MPI_Request request =
       build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
-                    comm, NON_PERSISTENT | SEND);
+                    comm, NON_PERSISTENT | ISEND | SEND);
+
+  smpi_mpi_start(request);
+  return request;
+}
+
+MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype,
+                           int dst, int tag, MPI_Comm comm)
+{
+  MPI_Request request =
+      build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
+                    comm, NON_PERSISTENT | ISEND | SSEND | SEND);
+  smpi_mpi_start(request);
+  return request;
+}
 
 
+MPI_Request smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype,
+                           int dst, int tag, MPI_Comm comm)
+{
+  MPI_Request request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
   smpi_mpi_start(request);
   return request;
 }
   smpi_mpi_start(request);
   return request;
 }
index 1e4dc07..9d5912d 100644 (file)
@@ -862,6 +862,24 @@ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
   return retval;
 }
 
   return retval;
 }
 
+int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
+  int retval;
+
+    smpi_bench_end();
+    if (request == NULL) {
+      retval = MPI_ERR_ARG;
+    } else if (comm == MPI_COMM_NULL) {
+      retval = MPI_ERR_COMM;
+    } else if (dst == MPI_PROC_NULL) {
+      retval = MPI_SUCCESS;
+    } else {
+      *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
+      retval = MPI_SUCCESS;
+    }
+    smpi_bench_begin();
+    return retval;
+}
+
 int PMPI_Start(MPI_Request * request)
 {
   int retval;
 int PMPI_Start(MPI_Request * request)
 {
   int retval;
@@ -1001,7 +1019,50 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
   return retval;
 }
 
   return retval;
 }
 
+int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
+  int retval;
+
+  smpi_bench_end();
+  if (request == NULL) {
+    retval = MPI_ERR_ARG;
+  } else if (comm == MPI_COMM_NULL) {
+    retval = MPI_ERR_COMM;
+  } else if (dst == MPI_PROC_NULL) {
+    *request = MPI_REQUEST_NULL;
+    retval = MPI_SUCCESS;
+  } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+    retval = MPI_ERR_COMM;
+  } else if (count < 0) {
+    retval = MPI_ERR_COUNT;
+  } else if (buf==NULL && count > 0) {
+    retval = MPI_ERR_COUNT;
+  } else if (datatype == MPI_DATATYPE_NULL){
+    retval = MPI_ERR_TYPE;
+  } else if(tag<0 && tag !=  MPI_ANY_TAG){
+    retval = MPI_ERR_TAG;
+  } else {
+
+#ifdef HAVE_TRACING
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  TRACE_smpi_computing_out(rank);
+  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
+
+    *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
+    retval = MPI_SUCCESS;
 
 
+#ifdef HAVE_TRACING
+  TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
+  (*request)->send = 1;
+  TRACE_smpi_computing_in(rank);
+#endif
+  }
+
+  smpi_bench_begin();
+  return retval;
+}
 
 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
              MPI_Comm comm, MPI_Status * status)
 
 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
              MPI_Comm comm, MPI_Status * status)
@@ -1094,6 +1155,50 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
   return retval;
 }
 
   return retval;
 }
 
+
+
+int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
+  int retval;
+
+   smpi_bench_end();
+
+   if (comm == MPI_COMM_NULL) {
+     retval = MPI_ERR_COMM;
+   } else if (dst == MPI_PROC_NULL) {
+     retval = MPI_SUCCESS;
+   } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+     retval = MPI_ERR_COMM;
+   } else if (count < 0) {
+     retval = MPI_ERR_COUNT;
+   } else if (buf==NULL && count > 0) {
+     retval = MPI_ERR_COUNT;
+   } else if (datatype == MPI_DATATYPE_NULL){
+     retval = MPI_ERR_TYPE;
+   } else if(tag<0 && tag !=  MPI_ANY_TAG){
+     retval = MPI_ERR_TAG;
+   } else {
+
+ #ifdef HAVE_TRACING
+   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+   TRACE_smpi_computing_out(rank);
+   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
+
+     smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
+     retval = MPI_SUCCESS;
+
+ #ifdef HAVE_TRACING
+   TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
+   TRACE_smpi_computing_in(rank);
+ #endif
+   }
+
+   smpi_bench_begin();
+   return retval;}
+
+
 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                  int dst, int sendtag, void *recvbuf, int recvcount,
                  MPI_Datatype recvtype, int src, int recvtag,
 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                  int dst, int sendtag, void *recvbuf, int recvcount,
                  MPI_Datatype recvtype, int src, int recvtag,
@@ -2200,13 +2305,7 @@ int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcou
    return not_yet_implemented();
 }
 
    return not_yet_implemented();
 }
 
-int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
-   return not_yet_implemented();
-}
 
 
-int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
-   return not_yet_implemented();
-}
 
 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
    return not_yet_implemented();
 
 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
    return not_yet_implemented();
@@ -2236,11 +2335,6 @@ int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
    return not_yet_implemented();
 }
 
    return not_yet_implemented();
 }
 
-int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
-   return not_yet_implemented();
-}
-
-
 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
    return not_yet_implemented();
 }
 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
    return not_yet_implemented();
 }