Skip to content

Commit

Permalink
Remove use of MPI_Win_lock/unlock from MPI Ops
Browse files Browse the repository at this point in the history
  • Loading branch information
janciesko committed Aug 3, 2022
1 parent 405f69d commit 1419359
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
6 changes: 0 additions & 6 deletions src/impl/mpispace/Kokkos_MPISpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ void MPISpace::deallocate(void *const, const size_t) const {
MPI_Win_unlock_all(current_win);
MPI_Win_free(&current_win);

// We pass a mempory space instance do multiple Views thus
// setting "current_win = MPI_WIN_NULL;" will result in a wrong handle if
// subsequent view runs out of scope
// Fixme: The following only works when views are allocated sequentially
// We need a thread-safe map to associate views and windows

if (last_valid != 0)
current_win = mpi_windows[last_valid - 1];
else
Expand Down
28 changes: 14 additions & 14 deletions src/impl/mpispace/Kokkos_MPISpace_Ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ namespace Impl {
assert(win != MPI_WIN_NULL); \
int _typesize; \
MPI_Type_size(mpi_type, &_typesize); \
MPI_Win_lock(MPI_LOCK_SHARED, pe, 0, win); \
/*MPI_Win_lock(MPI_LOCK_SHARED, pe, 0, win); */ \
MPI_Put(&val, 1, mpi_type, pe, \
sizeof(SharedAllocationHeader) + offset * _typesize, 1, mpi_type, \
win); \
MPI_Win_unlock(pe, win); \
/* MPI_Win_unlock(pe, win); */ \
MPI_Win_flush(pe, win); \
}

Expand All @@ -79,18 +79,18 @@ KOKKOS_REMOTESPACES_P(double, MPI_DOUBLE)

#undef KOKKOS_REMOTESPACES_P

#define KOKKOS_REMOTESPACES_G(type, mpi_type) \
static KOKKOS_INLINE_FUNCTION void mpi_type_g( \
type &val, const size_t offset, const int pe, const MPI_Win &win) { \
assert(win != MPI_WIN_NULL); \
int _typesize; \
MPI_Type_size(mpi_type, &_typesize); \
MPI_Win_lock(MPI_LOCK_SHARED, pe, 0, win); \
MPI_Get(&val, 1, mpi_type, pe, \
sizeof(SharedAllocationHeader) + offset * _typesize, 1, mpi_type, \
win); \
MPI_Win_unlock(pe, win); \
MPI_Win_flush(pe, win); \
#define KOKKOS_REMOTESPACES_G(type, mpi_type) \
static KOKKOS_INLINE_FUNCTION void mpi_type_g( \
type &val, const size_t offset, const int pe, const MPI_Win &win) { \
assert(win != MPI_WIN_NULL); \
int _typesize; \
MPI_Type_size(mpi_type, &_typesize); \
/*MPI_Win_lock(MPI_LOCK_SHARED, pe, 0, win); */ \
MPI_Get(&val, 1, mpi_type, pe, \
sizeof(SharedAllocationHeader) + offset * _typesize, 1, mpi_type, \
win); \
/*MPI_Win_unlock(pe, win); */ \
MPI_Win_flush(pe, win); \
}

KOKKOS_REMOTESPACES_G(char, MPI_SIGNED_CHAR)
Expand Down

0 comments on commit 1419359

Please sign in to comment.