Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Kokkos Memory Pool when using Shared Memory Spaces #67

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Omega_h_for.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ void parallel_for(LO n, UnaryFunction&& f) {
template <typename T>
void parallel_for(LO n, T const& f, char const* name = "") {
#if defined(OMEGA_H_USE_KOKKOS)
if (n > 0) Kokkos::parallel_for(name, policy(n), f);
if (n > 0) {
Kokkos::parallel_for(name, policy(n), f);
Kokkos::fence();
}
#else
(void)name;
auto const first = IntIterator(0);
Expand Down
8 changes: 8 additions & 0 deletions src/Omega_h_pool_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ auto CompareFreeIndices::operator()(size_t lhs, IndexPair rhs) const -> bool {
StaticKokkosPool::StaticKokkosPool(size_t numChunks, size_t bytesPerChunks)
: numberOfChunks(numChunks)
, chunkSize(bytesPerChunks)
#if defined(OMEGA_H_MEM_SPACE_SHARED)
, pool(Kokkos::kokkos_malloc<Kokkos::SharedSpace>(numChunks * bytesPerChunks)) {
#else
, pool(Kokkos::kokkos_malloc(numChunks * bytesPerChunks)) {
#endif
insertIntoSets({0, numChunks});
}

Expand Down Expand Up @@ -160,7 +164,11 @@ auto StaticKokkosPool::getRequiredChunks(size_t n, size_t bytesPerChunk)
}

StaticKokkosPool::~StaticKokkosPool() {
#if defined(OMEGA_H_MEM_SPACE_SHARED)
Kokkos::kokkos_free<Kokkos::SharedSpace>(pool);
#else
Kokkos::kokkos_free(pool);
#endif
}

auto KokkosPool::getChunkSize() const -> size_t { return chunkSize; }
Expand Down
Loading