-
Notifications
You must be signed in to change notification settings - Fork 30
Change MPI3 shared memory in Quest so it uses Umpire. #1652
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
Changes from all commits
b8bd28c
5fb886e
7d4245d
4c73b35
55d8f1c
ebab4a6
6adb053
4684659
cb19673
73ea86a
f12ff68
88fa450
5aa1325
f114986
e849acc
0ddce42
ce0f380
40c11f1
0c2f6c1
ee8de79
ee8e9ba
d367dc7
4ce036a
cad2b2b
c69d950
7bef6e0
c14f563
2118611
971165e
984cd26
12395db
8b74c20
9b0dd9c
5475938
9e8d791
a7114d8
d3e3ef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,7 @@ class Axom(CachedCMakePackage, CudaPackage, ROCmPackage): | |
| depends_on("[email protected]", when="@0.6.0") | ||
| depends_on("umpire@5:5.0.1", when="@:0.5.0") | ||
| depends_on("umpire+openmp", when="+openmp") | ||
| depends_on("umpire+mpi3_shmem", when="+mpi") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its something like this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| with when("+raja"): | ||
| depends_on("raja") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,7 @@ set(core_sources | |
|
|
||
| numerics/polynomial_solvers.cpp | ||
|
|
||
| memory_management.cpp | ||
| Path.cpp | ||
| Types.cpp | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and | ||
| // other Axom Project Developers. See the top-level LICENSE file for details. | ||
| // | ||
| // SPDX-License-Identifier: (BSD-3-Clause) | ||
|
|
||
| #include "axom/core/memory_management.hpp" | ||
|
|
||
| #if defined(AXOM_USE_UMPIRE) | ||
| #include "axom/fmt.hpp" | ||
| #include "umpire/Umpire.hpp" | ||
| #include "umpire/util/MemoryResourceTraits.hpp" | ||
| #if defined(AXOM_USE_UMPIRE_SHARED_MEMORY) | ||
| #include "umpire/strategy/NamedAllocationStrategy.hpp" | ||
| #endif | ||
| #endif | ||
|
|
||
| namespace axom | ||
| { | ||
|
|
||
| bool isSharedMemoryAllocator(int allocID) | ||
| { | ||
| bool isShared = false; | ||
| #if defined(AXOM_USE_UMPIRE) | ||
| umpire::ResourceManager& rm = umpire::ResourceManager::getInstance(); | ||
| if(rm.isAllocator(allocID)) | ||
| { | ||
| umpire::Allocator allocator = rm.getAllocator(allocID); | ||
|
|
||
| isShared = allocator.getAllocationStrategy()->getTraits().resource == | ||
| umpire::MemoryResourceTraits::resource_type::shared; | ||
| } | ||
| #endif | ||
| return isShared; | ||
| } | ||
|
|
||
| int getSharedMemoryAllocatorID() | ||
| { | ||
| int allocator_id = INVALID_ALLOCATOR_ID; | ||
| #if defined(AXOM_USE_UMPIRE_SHARED_MEMORY) | ||
| const std::string allocatorName("axom_shared_allocator"); | ||
| auto& rm = umpire::ResourceManager::getInstance(); | ||
| if(!rm.isAllocator(allocatorName)) | ||
| { | ||
| // Create the allocator | ||
| const auto name = axom::fmt::format("SHARED::{}", UMPIRE_DEFAULT_SHARED_MEMORY_RESOURCE); | ||
| auto traits {umpire::get_default_resource_traits(name)}; | ||
| traits.scope = umpire::MemoryResourceTraits::shared_scope::node; | ||
| auto axom_node_allocator {rm.makeResource(axom::fmt::format("{}::axom_node_allocator", name), traits)}; | ||
| auto axom_shared_allocator { | ||
| rm.makeAllocator<umpire::strategy::NamedAllocationStrategy>(allocatorName, axom_node_allocator)}; | ||
| allocator_id = axom_shared_allocator.getId(); | ||
| } | ||
| else | ||
| { | ||
| allocator_id = rm.getAllocator(allocatorName).getId(); | ||
| } | ||
| #endif | ||
| return allocator_id; | ||
| } | ||
|
|
||
| } // end namespace axom |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and | ||
| // other Axom Project Developers. See the top-level LICENSE file for details. | ||
| // | ||
| // SPDX-License-Identifier: (BSD-3-Clause) | ||
|
|
||
| // Axom includes | ||
| #include "axom/config.hpp" | ||
| #include "axom/core/memory_management.hpp" | ||
|
|
||
| // gtest includes | ||
| #include "gtest/gtest.h" | ||
|
|
||
| #include <mpi.h> | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| #if defined(AXOM_USE_UMPIRE_SHARED_MEMORY) | ||
| TEST(core_shared_memory, shared_memory_allocator) | ||
| { | ||
| EXPECT_FALSE(axom::isSharedMemoryAllocator(axom::getDefaultAllocatorID())); | ||
| EXPECT_TRUE(axom::isSharedMemoryAllocator(axom::getSharedMemoryAllocatorID())); | ||
|
|
||
| int rank = 0; | ||
| MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
|
|
||
| const int sizes[] = {1024, 4096, 1000000}; | ||
| for(int si = 0; si < 3; si++) | ||
| { | ||
| // Allocate shared memory | ||
| const int N = sizes[si]; | ||
| int *buffer = axom::allocate<int>(N, axom::getSharedMemoryAllocatorID()); | ||
|
|
||
| // Populate the shared memory on rank 0 | ||
| if(rank == 0) | ||
| { | ||
| for(int i = 0; i < N; i++) | ||
| { | ||
| buffer[i] = i; | ||
| } | ||
| } | ||
|
|
||
| MPI_Barrier(MPI_COMM_WORLD); | ||
|
|
||
| // Test the shared memory on all ranks. | ||
| for(int i = 0; i < N; i++) | ||
| { | ||
| EXPECT_EQ(buffer[i], i); | ||
| } | ||
|
|
||
| MPI_Barrier(MPI_COMM_WORLD); | ||
|
|
||
| axom::deallocate(buffer); | ||
| } | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice functionality @BradWhitlock !