From 3cc7ccb3995997fcb12d4580dc9c982c4140084b Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Thu, 15 Aug 2024 10:37:26 -0500 Subject: [PATCH] ch4: implement MPIR_Data send/recv in netmod/shm/mpidig (WIP) --- src/mpid/ch4/ch4_api.txt | 7 +++++ src/mpid/ch4/src/mpidig_send.h | 57 ++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/mpid/ch4/ch4_api.txt b/src/mpid/ch4/ch4_api.txt index f69e0805246..f53901033fd 100644 --- a/src/mpid/ch4/ch4_api.txt +++ b/src/mpid/ch4/ch4_api.txt @@ -138,12 +138,18 @@ Non Native API: SHM*: req Native API: + send_data : int + NM*: data-2, rank, tag, comm, attr-2, addr, req_p + SHM*: data-2, rank, tag, comm, attr-2, addr, req_p mpi_isend : int NM*: buf, count, datatype, rank, tag, comm, attr-2, addr, req_p SHM*: buf, count, datatype, rank, tag, comm, attr-2, addr, req_p mpi_cancel_send : int NM*: sreq SHM*: sreq + recv_data : int + NM*: data-2, rank, tag, comm, attr-2, addr, req_p, partner + SHM*: data-2, rank, tag, comm, attr-2, req_p mpi_irecv : int NM*: buf-2, count, datatype, rank, tag, comm, attr-2, addr, req_p, partner SHM*: buf-2, count, datatype, rank, tag, comm, attr-2, req_p @@ -446,6 +452,7 @@ PARAM: context_id: MPIR_Context_id_t count: MPI_Aint data: const void * + data-2: MPIR_Data * data_sz: MPI_Aint datatype: MPI_Datatype datatype_p: MPIR_Datatype * diff --git a/src/mpid/ch4/src/mpidig_send.h b/src/mpid/ch4/src/mpidig_send.h index 1ff868d4cc6..af1dcc8f081 100644 --- a/src/mpid/ch4/src/mpidig_send.h +++ b/src/mpid/ch4/src/mpidig_send.h @@ -40,8 +40,7 @@ MPL_STATIC_INLINE_PREFIX bool MPIDIG_check_eager(int is_local, MPI_Aint am_hdr_s #endif } -MPL_STATIC_INLINE_PREFIX int MPIDIG_isend_impl(const void *buf, MPI_Aint count, - MPI_Datatype datatype, int rank, int tag, +MPL_STATIC_INLINE_PREFIX int MPIDIG_isend_impl(MPIR_Data * data, int rank, int tag, MPIR_Comm * comm, int context_offset, MPIDI_av_entry_t * addr, uint8_t flags, int src_vci, int dst_vci, @@ -78,29 +77,35 @@ MPL_STATIC_INLINE_PREFIX int MPIDIG_isend_impl(const void *buf, MPI_Aint count, MPIR_cc_inc(sreq->cc_ptr); /* expecting SSEND_ACK */ } MPI_Aint data_sz; - MPIDI_Datatype_check_size(datatype, count, data_sz); + if (data->length > 0) { + data_sz = data->length; + } else { + MPIDI_Datatype_check_size(data->datatype, data->count, data_sz); + } am_hdr.data_sz = data_sz; am_hdr.rndv_hdr_sz = 0; #ifdef HAVE_DEBUGGER_SUPPORT - MPIDIG_REQUEST(sreq, datatype) = datatype; - MPIDIG_REQUEST(sreq, buffer) = (void *) buf; - MPIDIG_REQUEST(sreq, count) = count; + /* FIXME: partial data support in debugger */ + MPIDIG_REQUEST(sreq, datatype) = data->datatype; + MPIDIG_REQUEST(sreq, buffer) = data->buf; + MPIDIG_REQUEST(sreq, count) = data->count; #endif int is_local = MPIDI_av_is_local(addr); MPI_Aint am_hdr_sz = (MPI_Aint) sizeof(am_hdr); if (MPIDIG_check_eager(is_local, am_hdr_sz, data_sz, sreq)) { /* EAGER send */ - CH4_CALL(am_isend(rank, comm, MPIDIG_SEND, &am_hdr, am_hdr_sz, buf, count, datatype, - src_vci, dst_vci, sreq), is_local, mpi_errno); + CH4_CALL(am_isend(rank, comm, MPIDIG_SEND, &am_hdr, am_hdr_sz, + data->buf, data->count, data->datatype, src_vci, dst_vci, sreq), + is_local, mpi_errno); } else { /* RNDV send */ - MPIDIG_REQUEST(sreq, buffer) = (void *) buf; - MPIDIG_REQUEST(sreq, count) = count; - MPIDIG_REQUEST(sreq, datatype) = datatype; + MPIDIG_REQUEST(sreq, buffer) = data->buf; + MPIDIG_REQUEST(sreq, count) = data->count; + MPIDIG_REQUEST(sreq, datatype) = data->datatype; MPIDIG_REQUEST(sreq, u.send.dest) = rank; - MPIR_Datatype_add_ref_if_not_builtin(datatype); + MPIR_Datatype_add_ref_if_not_builtin(data->datatype); MPIDIG_AM_SEND_SET_RNDV(am_hdr.flags, MPIDIG_RNDV_GENERIC); CH4_CALL(am_send_hdr(rank, comm, MPIDIG_SEND, &am_hdr, am_hdr_sz, src_vci, dst_vci), @@ -115,10 +120,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDIG_isend_impl(const void *buf, MPI_Aint count, goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPIDIG_mpi_isend(const void *buf, - MPI_Aint count, - MPI_Datatype datatype, - int rank, +MPL_STATIC_INLINE_PREFIX int MPIDIG_send_data(MPIR_Data * data, int rank, int tag, MPIR_Comm * comm, int context_offset, MPIDI_av_entry_t * addr, int src_vci, int dst_vci, MPIR_Request ** request, @@ -128,13 +130,34 @@ MPL_STATIC_INLINE_PREFIX int MPIDIG_mpi_isend(const void *buf, MPIR_FUNC_ENTER; uint8_t flags = syncflag ? MPIDIG_AM_SEND_FLAGS_SYNC : MPIDIG_AM_SEND_FLAGS_NONE; - mpi_errno = MPIDIG_isend_impl(buf, count, datatype, rank, tag, comm, context_offset, addr, + mpi_errno = MPIDIG_isend_impl(data, rank, tag, comm, context_offset, addr, flags, src_vci, dst_vci, request, errflag); MPIR_FUNC_EXIT; return mpi_errno; } +MPL_STATIC_INLINE_PREFIX int MPIDIG_mpi_isend(const void *buf, + MPI_Aint count, + MPI_Datatype datatype, + int rank, + int tag, MPIR_Comm * comm, int context_offset, + MPIDI_av_entry_t * addr, int src_vci, int dst_vci, + MPIR_Request ** request, + bool syncflag, MPIR_Errflag_t errflag) +{ + MPIR_Data data = { + .buf = (void *) buf, + .count = count, + .datatype = datatype, + .offset = 0, + .length = -1, + }; + + return MPIDIG_send_data(&data, rank, tag, comm, context_offset, addr, src_vci, dst_vci, + request, syncflag, errflag); +} + MPL_STATIC_INLINE_PREFIX int MPIDIG_mpi_cancel_send(MPIR_Request * sreq) { int mpi_errno = MPI_SUCCESS;