From df86235deb77e8678d0b590c43a54f812ebb8566 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 11 Feb 2013 17:43:44 +0100 Subject: [PATCH] add support for Ssend/Issend in SMPI --- src/smpi/private.h | 11 +++- src/smpi/smpi_base.c | 32 +++++++++++- src/smpi/smpi_pmpi.c | 116 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 144 insertions(+), 15 deletions(-) diff --git a/src/smpi/private.h b/src/smpi/private.h index 148f4b08aa..15865c7f6b 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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 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) @@ -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); +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); @@ -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); +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, diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 19cce6ba09..19cd933b84 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -266,6 +266,16 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, 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) { @@ -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); } - 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++; @@ -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, - 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; } diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index 1e4dc070af..9d5912da24 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -862,6 +862,24 @@ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, 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; @@ -1001,7 +1019,50 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, 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) @@ -1094,6 +1155,50 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, 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, @@ -2200,13 +2305,7 @@ int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcou 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(); @@ -2236,11 +2335,6 @@ int PMPI_Comm_remote_size(MPI_Comm comm, int* size) { 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(); } -- 2.20.1