Skip to content

Commit

Permalink
coll/libnbc/ialltoallv: skip send/recv 0-byte data
Browse files Browse the repository at this point in the history
As per MPI specification the amount of data sent must be equal to the
amount of data received for each communication pair, and therefore
both count and datatype size should be accounted for to determine if
the data is 0-byte and therefore skippable.

Signed-off-by: Wenduo Wang <wenduwan@amazon.com>
  • Loading branch information
wenduwan committed Dec 25, 2023
1 parent e8471a6 commit d4546c7
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions ompi/mca/coll/libnbc/nbc_ialltoallv.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
}


if (!inplace && sendcounts[rank] != 0) {
if (!inplace && 0 < sendcounts[rank] && 0 < sndext) {
rbuf = (char *) recvbuf + rdispls[rank] * rcvext;
sbuf = (char *) sendbuf + sdispls[rank] * sndext;
res = NBC_Sched_copy (sbuf, false, sendcounts[rank], sendtype,
Expand Down Expand Up @@ -272,7 +272,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
}

/* post send */
if (sendcounts[i] != 0) {
if (0 < sendcounts[i] && 0 < sndext) {
char *sbuf = ((char *) sendbuf) + (sdispls[i] * sndext);
res = NBC_Sched_send(sbuf, false, sendcounts[i], sendtype, i, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
Expand All @@ -281,7 +281,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
}

/* post receive */
if (recvcounts[i] != 0) {
if (0 < recvcounts[i] && 0 < rcvext) {
char *rbuf = ((char *) recvbuf) + (rdispls[i] * rcvext);
res = NBC_Sched_recv(rbuf, false, recvcounts[i], recvtype, i, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
Expand All @@ -306,7 +306,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
int rcvpeer = (rank + p - i) %p;

/* post send */
if (sendcounts[sndpeer] != 0) {
if (0 < sendcounts[sndpeer] && 0 < sndext) {
char *sbuf = ((char *) sendbuf) + (sdispls[sndpeer] * sndext);
res = NBC_Sched_send(sbuf, false, sendcounts[sndpeer], sendtype, sndpeer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
Expand All @@ -315,7 +315,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
}

/* post receive */
if (recvcounts[rcvpeer] != 0) {
if (0 < recvcounts[rcvpeer] && 0 < rcvext) {
char *rbuf = ((char *) recvbuf) + (rdispls[rcvpeer] * rcvext);
res = NBC_Sched_recv(rbuf, false, recvcounts[rcvpeer], recvtype, rcvpeer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
Expand All @@ -338,34 +338,34 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
char *sbuf = (char *) buf + displs[speer] * ext;
char *rbuf = (char *) buf + displs[rpeer] * ext;

if (0 != counts[rpeer]) {
if (0 < counts[rpeer] && 0 < ext) {
res = NBC_Sched_copy (rbuf, false, counts[rpeer], type,
(void *)(-gap), true, counts[rpeer], type,
schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
}
if (0 != counts[speer]) {
if (0 < counts[speer] && 0 < ext) {
res = NBC_Sched_send (sbuf, false , counts[speer], type, speer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
}
if (0 != counts[rpeer]) {
if (0 < counts[rpeer] && 0 < ext) {
res = NBC_Sched_recv (rbuf, false , counts[rpeer], type, rpeer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
}

if (0 != counts[rpeer]) {
if (0 < counts[rpeer] && 0 < ext) {
res = NBC_Sched_send ((void *)(-gap), true, counts[rpeer], type, rpeer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
}
if (0 != counts[speer]) {
if (0 < counts[speer] && 0 < ext) {
res = NBC_Sched_recv (sbuf, false, counts[speer], type, speer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
Expand All @@ -374,15 +374,17 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
}
if (0 == (p%2)) {
int peer = (rank + p/2) % p;

char *tbuf = (char *) buf + displs[peer] * ext;
res = NBC_Sched_copy (tbuf, false, counts[peer], type,
(void *)(-gap), true, counts[peer], type,
schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;

if (0 < counts[peer] && 0 < ext) {
res = NBC_Sched_copy(tbuf, false, counts[peer], type, (void *) (-gap), true, counts[peer],
type, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
}
if (0 != counts[peer]) {

if (0 < counts[peer] && 0 < ext) {
res = NBC_Sched_send ((void *)(-gap), true , counts[peer], type, peer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
Expand Down

0 comments on commit d4546c7

Please sign in to comment.