Skip to content

Commit

Permalink
coll: refactor barrier_intra_k_dissemination
Browse files Browse the repository at this point in the history
Because the compiler can't figure out the arithmetics, it is warning:
    ‘MPIC_Waitall’ accessing 8 bytes in a region of size 0
[-Wstringop-overflow=]

Refactor to suppress warning and for better readability.
  • Loading branch information
hzhou committed Aug 24, 2024
1 parent 794bc65 commit cefbfd9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/mpi/coll/barrier/barrier_intra_k_dissemination.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ int MPIR_Barrier_intra_k_dissemination(MPIR_Comm * comm, int coll_group, int k,
nphases++;
}

MPIR_Request **rreqs = recv_reqs;
MPIR_Request **prev_rreqs = recv_reqs + (k - 1);
shift = 1;
for (i = 0; i < nphases; i++) {
for (j = 1; j < k; j++) {
Expand All @@ -95,14 +97,12 @@ int MPIR_Barrier_intra_k_dissemination(MPIR_Comm * comm, int coll_group, int k,
MPIR_Assert(to >= 0 && to < nranks);

/* recv from (k-1) nbrs */
mpi_errno =
MPIC_Irecv(NULL, 0, MPI_BYTE, from, MPIR_BARRIER_TAG, comm, coll_group,
&recv_reqs[(j - 1) + ((k - 1) * (i & 1))]);
mpi_errno = MPIC_Irecv(NULL, 0, MPI_BYTE, from, MPIR_BARRIER_TAG, comm, coll_group,
&rreqs[j - 1]);
MPIR_ERR_COLL_CHECKANDCONT(mpi_errno, errflag, mpi_errno_ret);
/* wait on recvs from prev phase */
if (i > 0 && j == 1) {
mpi_errno =
MPIC_Waitall(k - 1, &recv_reqs[((k - 1) * ((i - 1) & 1))], MPI_STATUSES_IGNORE);
mpi_errno = MPIC_Waitall(k - 1, prev_rreqs, MPI_STATUSES_IGNORE);
MPIR_ERR_COLL_CHECKANDCONT(mpi_errno, errflag, mpi_errno_ret);
}

Expand All @@ -114,10 +114,13 @@ int MPIR_Barrier_intra_k_dissemination(MPIR_Comm * comm, int coll_group, int k,
mpi_errno = MPIC_Waitall(k - 1, send_reqs, MPI_STATUSES_IGNORE);
MPIR_ERR_COLL_CHECKANDCONT(mpi_errno, errflag, mpi_errno_ret);
shift *= k;

MPIR_Request **tmp = rreqs;
rreqs = prev_rreqs;
prev_rreqs = tmp;
}

mpi_errno =
MPIC_Waitall(k - 1, recv_reqs + ((k - 1) * ((nphases - 1) & 1)), MPI_STATUSES_IGNORE);
mpi_errno = MPIC_Waitall(k - 1, prev_rreqs, MPI_STATUSES_IGNORE);
MPIR_ERR_COLL_CHECKANDCONT(mpi_errno, errflag, mpi_errno_ret);

fn_exit:
Expand Down

0 comments on commit cefbfd9

Please sign in to comment.