Skip to content

Commit 02d257f

Browse files
authored
Merge pull request kokkos#147 from cwpearson/fix/recv-labels
2 parents a79508d + 9b49421 commit 02d257f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/KokkosComm/mpi/recv.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace KokkosComm::mpi {
2727

2828
template <KokkosView RecvView>
2929
void recv(const RecvView &rv, int src, int tag, MPI_Comm comm, MPI_Status *status) {
30-
Kokkos::Tools::pushRegion("KokkosComm::Impl::recv");
30+
Kokkos::Tools::pushRegion("KokkosComm::mpi::recv");
3131
using KCT = KokkosComm::Traits<RecvView>;
3232

3333
if (KokkosComm::is_contiguous(rv)) {
@@ -42,7 +42,7 @@ void recv(const RecvView &rv, int src, int tag, MPI_Comm comm, MPI_Status *statu
4242

4343
template <KokkosExecutionSpace ExecSpace, KokkosView RecvView>
4444
void recv(const ExecSpace &space, RecvView &rv, int src, int tag, MPI_Comm comm) {
45-
Kokkos::Tools::pushRegion("KokkosComm::Impl::recv");
45+
Kokkos::Tools::pushRegion("KokkosComm::mpi::recv");
4646

4747
using KCT = KokkosComm::Traits<RecvView>;
4848
using KCPT = KokkosComm::PackTraits<RecvView>;
@@ -51,13 +51,14 @@ void recv(const ExecSpace &space, RecvView &rv, int src, int tag, MPI_Comm comm)
5151

5252
if (!KokkosComm::is_contiguous(rv)) {
5353
Args args = Packer::allocate_packed_for(space, "packed", rv);
54-
space.fence(); // make sure allocation is complete before recv
54+
space.fence("Fence after allocation before MPI_Recv");
5555
MPI_Recv(KokkosComm::data_handle(args.view), args.count, args.datatype, src, tag, comm, MPI_STATUS_IGNORE);
5656
Packer::unpack_into(space, rv, args.view);
5757
} else {
5858
using RecvScalar = typename RecvView::value_type;
59-
space.fence(); // can't recv in space until any preceding work is done
60-
recv(rv, src, tag, comm, MPI_STATUS_IGNORE);
59+
space.fence("Fence before MPI_Recv"); // prevent work in `space` from writing to recv buffer
60+
MPI_Recv(KokkosComm::data_handle(rv), KokkosComm::span(rv), KokkosComm::Impl::mpi_type_v<RecvScalar>, src, tag,
61+
comm, MPI_STATUS_IGNORE);
6162
}
6263

6364
Kokkos::Tools::popRegion();

0 commit comments

Comments
 (0)