Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b8bd28c
Initial port of read_stl_mesh_shared and quest::signed_distance funct…
BradWhitlock Sep 5, 2025
5fb886e
Fix some race conditions that prevented passage of quest_signed_dista…
BradWhitlock Sep 5, 2025
7d4245d
Fix issue in quest_signed_distance_interface test. Complete shared me…
BradWhitlock Sep 6, 2025
4c73b35
Initial change to Axom spack package.py to select Umpire that has MPI…
BradWhitlock Sep 6, 2025
55d8f1c
make style
BradWhitlock Sep 6, 2025
ebab4a6
Fix variable name use.
BradWhitlock Sep 6, 2025
6adb053
Change message about Umpire.
BradWhitlock Sep 6, 2025
4684659
Fix old typo
BradWhitlock Sep 8, 2025
cb19673
Fix conditional compilation block.
BradWhitlock Sep 8, 2025
73ea86a
Removed extra dashes.
BradWhitlock Sep 8, 2025
f12ff68
Avoid direct MPI calls for case when this MPI test is actually NOT us…
BradWhitlock Sep 8, 2025
88fa450
Fix mistake
BradWhitlock Sep 8, 2025
5aa1325
Change macro used to select MPI abstraction functions.
BradWhitlock Sep 8, 2025
f114986
Moved a function so it is more like the previous ordering.
BradWhitlock Sep 8, 2025
e849acc
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 9, 2025
0ddce42
Make AXOM_USE_UMPIRE_SHARED_MEMORY be set in config.hpp
BradWhitlock Sep 9, 2025
ce0f380
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 9, 2025
40c11f1
Removed MPI build option.
BradWhitlock Sep 9, 2025
0c2f6c1
Merge branch 'feature/whitlock/use_umpire_shared_memory' of github.co…
BradWhitlock Sep 9, 2025
ee8de79
Moved shared memory allocator to core.
BradWhitlock Sep 9, 2025
ee8e9ba
make style
BradWhitlock Sep 9, 2025
d367dc7
Moved some function declarations.
BradWhitlock Sep 9, 2025
4ce036a
Change how we get some Umpire includes
BradWhitlock Sep 9, 2025
cad2b2b
Removed some comments related to MPI windows.
BradWhitlock Sep 9, 2025
c69d950
Removed some Umpire includes from signed_distance.
BradWhitlock Sep 9, 2025
7bef6e0
Renamed axom shared allocator.
BradWhitlock Sep 9, 2025
c14f563
Merged develop into branch
BradWhitlock Sep 10, 2025
2118611
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 11, 2025
971165e
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 12, 2025
984cd26
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 23, 2025
12395db
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Sep 24, 2025
8b74c20
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Oct 1, 2025
9b0dd9c
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Oct 4, 2025
5475938
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Oct 21, 2025
9e8d791
Use UMPIRE_DEFAULT_SHARED_MEMORY_RESOURCE in the name of the requeste…
BradWhitlock Oct 21, 2025
a7114d8
Merge branch 'feature/whitlock/use_umpire_shared_memory' of github.co…
BradWhitlock Oct 21, 2025
d3e3ef8
Merge branch 'develop' into feature/whitlock/use_umpire_shared_memory
BradWhitlock Oct 21, 2025
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
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice functionality @BradWhitlock !

Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
arrays of query points
- Core: Updates behavior of `FlatMap::reserve()` to only trigger a rehash if maximum load factor
would be exceeded.
- Quest: The signed_distance functions were modified so they use Umpire's shared memory mechanisms instead of using MPI3 directly.
- Axom's `AXOM_USE_MPI3` CMake build option and corresponding macro definition were removed.
- When Umpire is present, Axom now detects whether it supports shared memory and defines the `AXOM_USE_UMPIRE_SHARED_MEMORY` macro if appropriate. This macro can be used to conditionally compile code involving shared memory via Umpire.
- Quest: Moves curve linearization from the `quest::C2CReader` into `quest::LinearizeCurves` so the logic can be used with other curve data.

### Fixed
Expand Down
1 change: 1 addition & 0 deletions scripts/spack/packages/axom/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is mpi3_shmem always available when mpi is available?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its something like this:

depends_on("umpire+mpi3_shmem", when="+mpi ^mpi@3:")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


with when("+raja"):
depends_on("raja")
Expand Down
6 changes: 5 additions & 1 deletion src/axom/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#cmakedefine AXOM_USE_CUDA
#cmakedefine AXOM_USE_HIP
#cmakedefine AXOM_USE_MPI
#cmakedefine AXOM_USE_MPI3
#cmakedefine AXOM_USE_MPIF_HEADER
#cmakedefine AXOM_USE_OPENMP

Expand All @@ -77,6 +76,11 @@
#cmakedefine AXOM_USE_SPARSEHASH
#cmakedefine AXOM_USE_UMPIRE

/*
* Compiler defines for library capabilities
*/
#cmakedefine AXOM_USE_UMPIRE_SHARED_MEMORY

/*
* Compiler defines for third-party executables
*/
Expand Down
1 change: 1 addition & 0 deletions src/axom/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ set(core_sources

numerics/polynomial_solvers.cpp

memory_management.cpp
Path.cpp
Types.cpp
)
Expand Down
61 changes: 61 additions & 0 deletions src/axom/core/memory_management.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
17 changes: 17 additions & 0 deletions src/axom/core/memory_management.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ inline int getAllocatorIDFromPointer(const void* ptr)
return ptr == nullptr ? INVALID_ALLOCATOR_ID : MALLOC_ALLOCATOR_ID;
}

/*!
* \brief Determines whether an allocator id is for shared memory.
*
* \param allocID An allocator id.
*
* \return True if the allocator id is for shared memory; false otherwise.
*/
bool isSharedMemoryAllocator(int allocID);

/*!
* \brief Get the allocator ID for Axom's shared memory allocator.
*
* \return The allocator ID for Axom's shared memory allocator (if Axom is using Umpire),
* or INVALID_ALLOCATOR_ID otherwise.
*/
int getSharedMemoryAllocatorID();

/*!
* \brief Allocates a chunk of memory of type T.
*
Expand Down
3 changes: 2 additions & 1 deletion src/axom/core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ axom_add_test( NAME core_collections
if (AXOM_ENABLE_MPI)
set( core_mpi_tests
core_types.hpp
core_shared_memory.hpp
)

axom_add_executable(NAME core_mpi_tests
Expand All @@ -117,7 +118,7 @@ if (AXOM_ENABLE_MPI)
get_filename_component( test_suite ${test_suite} NAME_WE )
axom_add_test( NAME ${test_suite}_mpi
COMMAND core_mpi_tests --gtest_filter=${test_suite}*
NUM_MPI_TASKS 1 )
NUM_MPI_TASKS 2 )
endforeach()
endif()

Expand Down
1 change: 1 addition & 0 deletions src/axom/core/tests/core_mpi_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "axom/config.hpp"

#include "core_types.hpp"
#include "core_shared_memory.hpp"

int main(int argc, char* argv[])
{
Expand Down
54 changes: 54 additions & 0 deletions src/axom/core/tests/core_shared_memory.hpp
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
Loading