Skip to content
Open
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
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The format of this file is based on [Keep a Changelog](http://keepachangelog.com
### Changed
- Moved installed CMake targets from share/chai/cmake to lib/cmake/chai to be consistent with other libraries in the RAJA Portability Suite
- Improved dependency handling during the build of CHAI and when it is imported into another library/application
- Renamed CMake option CHAI\_DISABLE\_RM to CHAI\_ENABLE\_MANAGER
- Removed ArrayManager::enableDeviceSynchronization and ArrayManager::disableDeviceSynchronization. Instead, use the environment variables for device synchronization after all kernels (e.g. CUDA\_LAUNCH\_BLOCKING or HIP\_LAUNCH\_BLOCKING)

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions cmake/SetupChaiOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ option(CHAI_ENABLE_GPU_SIMULATION_MODE "Enable GPU Simulation Mode" Off)
option(CHAI_ENABLE_OPENMP "Enable OpenMP" Off)
option(CHAI_ENABLE_MPI "Enable MPI (for umpire replay only)" Off)

option(CHAI_DISABLE_RM "Make ManagedArray a thin wrapper" Off)
mark_as_advanced(CHAI_DISABLE_RM)
option(CHAI_ENABLE_MANAGER "Use the ArrayManager" On)
mark_as_advanced(CHAI_ENABLE_MANAGER)

option(CHAI_ENABLE_UM "Use CUDA unified (managed) memory" Off)
option(CHAI_THIN_GPU_ALLOCATE "Single memory space model" Off)
Expand Down Expand Up @@ -42,6 +42,6 @@ if (CHAI_ENABLE_UM AND NOT ENABLE_CUDA AND NOT CHAI_THIN_GPU_ALLOCATE)
message(FATAL_ERROR "Option CHAI_ENABLE_UM requires ENABLE_CUDA or CHAI_THIN_GPU_ALLOCATE")
endif()

if (CHAI_THIN_GPU_ALLOCATE AND NOT CHAI_DISABLE_RM)
message(FATAL_ERROR "Option CHAI_THIN_GPU_ALLOCATE requires CHAI_DISABLE_RM")
if (CHAI_THIN_GPU_ALLOCATE AND CHAI_ENABLE_MANAGER)
message(FATAL_ERROR "Option CHAI_THIN_GPU_ALLOCATE=On requires CHAI_ENABLE_MANAGER=Off")
endif()
11 changes: 6 additions & 5 deletions docs/sphinx/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Here is a summary of the configuration options, their default value, and meaning
ENABLE_HIP Off Enable HIP support.
CHAI_ENABLE_GPU_SIMULATION_MODE Off Simulates GPU execution.
CHAI_ENABLE_UM Off Enable support for CUDA Unified Memory.
CHAI_DISABLE_RM Off Disable the ArrayManager and make ManagedArray a thin wrapper around a pointer.
CHAI_ENABLE_MANAGER On Enable the ArrayManager.
ENABLE_TESTS On Build test executables.
ENABLE_BENCHMARKS On Build benchmark programs.
=========================== ======== ===============================================================================
Expand All @@ -51,10 +51,11 @@ These arguments are explained in more detail below:
not manually copy data. Data movement in this case is handled by the CUDA
driver and runtime.

* CHAI_DISABLE_RM
This option will remove all usage of the ``ArrayManager`` class and let the
``ManagedArray`` objects function as thin wrappers around a raw pointer. This
option can be used with CPU-only allocations, or with CUDA Unified Memory.
* CHAI_ENABLE_MANAGER
This option enables usage of the ``ArrayManager`` class. Turning it off lets
the ``ManagedArray`` objects function as thin wrappers around a raw pointer.
The thin wrapper version can be used with CPU-only allocations, unified
memory, or with architectures using a single memory space.

* ENABLE_TESTS
This option controls whether or not test executables will be built.
Expand Down
2 changes: 1 addition & 1 deletion src/chai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set (chai_headers
set (chai_sources
ArrayManager.cpp)

if(CHAI_DISABLE_RM)
if(NOT CHAI_ENABLE_MANAGER)
set(chai_headers
${chai_headers}
ManagedArray_thin.inl)
Expand Down
2 changes: 1 addition & 1 deletion src/chai/ChaiMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

#define CHAI_UNUSED_ARG(X)

#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)

#define CHAI_LOG(level, msg) \
UMPIRE_LOG(level, msg);
Expand Down
14 changes: 7 additions & 7 deletions src/chai/ManagedArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class ManagedArray : public CHAICopyable
*/
CHAI_HOST_DEVICE void set(size_t i, T val) const;

#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
/*!
* \brief Assign a user-defined callback triggerd upon memory migration.
*
Expand Down Expand Up @@ -369,7 +369,7 @@ class ManagedArray : public CHAICopyable
m_pointer_record = other.m_pointer_record;
m_allocator_id = other.m_allocator_id;
m_is_slice = other.m_is_slice;
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
#if !defined(CHAI_DEVICE_COMPILE)
// if we can, ensure elems is based off the pointer_record size out of paranoia
if (m_pointer_record != nullptr && !m_is_slice) {
Expand All @@ -388,7 +388,7 @@ class ManagedArray : public CHAICopyable
private:
// The following are only used by ManagedArray.inl, but for template
// shenanigan reasons need to be defined here.
#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
// if T is a CHAICopyable, then it is important to initialize all the
// elements with default constructors, since it is extremely easy to
// trigger a moveInnerImpl, which expects inner values to be initialized.
Expand Down Expand Up @@ -483,7 +483,7 @@ ManagedArray<T> makeManagedArray(T* data,
ExecutionSpace space,
bool owned)
{
#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
ArrayManager* manager = ArrayManager::getInstance();

// First, try and find an existing PointerRecord for the pointer
Expand Down Expand Up @@ -573,9 +573,9 @@ CHAI_INLINE CHAI_HOST_DEVICE ManagedArray<T> ManagedArray<T>::slice( size_t offs

} // end of namespace chai

#if defined(CHAI_DISABLE_RM)
#include "chai/ManagedArray_thin.inl"
#else
#if defined(CHAI_ENABLE_MANAGER)
#include "chai/ManagedArray.inl"
#else
#include "chai/ManagedArray_thin.inl"
#endif
#endif // CHAI_ManagedArray_HPP
2 changes: 1 addition & 1 deletion src/chai/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#cmakedefine CHAI_ENABLE_CUDA
#cmakedefine CHAI_ENABLE_HIP
#cmakedefine CHAI_DISABLE_RM
#cmakedefine CHAI_ENABLE_MANAGER
#cmakedefine CHAI_THIN_GPU_ALLOCATE
#cmakedefine CHAI_ENABLE_UM
#cmakedefine CHAI_DEBUG
Expand Down
12 changes: 6 additions & 6 deletions src/chai/managed_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#if defined(CHAI_ENABLE_MANAGED_PTR)

#if !defined(CHAI_DISABLE_RM) || defined(CHAI_THIN_GPU_ALLOCATE)
#if defined(CHAI_ENABLE_MANAGER) || defined(CHAI_THIN_GPU_ALLOCATE)
#include "chai/ArrayManager.hpp"
#endif

Expand Down Expand Up @@ -630,7 +630,7 @@ namespace chai {
/// with the ACTION_MOVE event.
///
CHAI_HOST void move() const {
#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
if (m_pointer_record) {
ExecutionSpace newSpace = ArrayManager::getInstance()->getExecutionSpace();

Expand Down Expand Up @@ -1085,7 +1085,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker<T> unpack(const chai::ManagedArray<ch
template <typename T,
typename... Args>
CHAI_HOST T* make_on_host(Args&&... args) {
#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
// Get the ArrayManager and save the current execution space
chai::ArrayManager* arrayManager = chai::ArrayManager::getInstance();
ExecutionSpace currentSpace = arrayManager->getExecutionSpace();
Expand All @@ -1098,7 +1098,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker<T> unpack(const chai::ManagedArray<ch
// Create on the host
T* cpuPointer = new T(detail::processArguments(args)...);

#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
// Set the execution space back to the previous value
arrayManager->setExecutionSpace(currentSpace);
#endif
Expand Down Expand Up @@ -1133,7 +1133,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker<T> unpack(const chai::ManagedArray<ch
template <typename T,
typename... Args>
CHAI_HOST T* make_on_device(Args... args) {
#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
// Get the ArrayManager and save the current execution space
chai::ArrayManager* arrayManager = chai::ArrayManager::getInstance();
ExecutionSpace currentSpace = arrayManager->getExecutionSpace();
Expand Down Expand Up @@ -1171,7 +1171,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker<T> unpack(const chai::ManagedArray<ch
free(cpuBuffer);
gpuFree(gpuBuffer);

#if !defined(CHAI_DISABLE_RM)
#if defined(CHAI_ENABLE_MANAGER)
// Set the execution space back to the previous value
arrayManager->setExecutionSpace(currentSpace);
#endif
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/managed_array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define device_assert(EXP) assert(EXP)
#endif

#ifdef CHAI_DISABLE_RM
#if !defined(CHAI_ENABLE_MANAGER)
#define assert_empty_map(IGNORED)
#else
#define assert_empty_map(IGNORED) ASSERT_EQ(chai::ArrayManager::getInstance()->getPointerMap().size(),0)
Expand All @@ -54,7 +54,7 @@ TEST(ManagedArray, SetOnHost)
assert_empty_map(true);
}

#if (!defined(CHAI_DISABLE_RM))
#if defined(CHAI_ENABLE_MANAGER)
TEST(ManagedArray, Const)
{
chai::ManagedArray<float> array(10);
Expand Down Expand Up @@ -168,7 +168,7 @@ TEST(ManagedArray, ArrayOfSlices) {
assert_empty_map(true);
}

#if (!defined(CHAI_DISABLE_RM))
#if defined(CHAI_ENABLE_MANAGER)
TEST(ManagedArray, PickHostFromHostConst) {
chai::ManagedArray<int> array(10);

Expand Down Expand Up @@ -213,7 +213,7 @@ TEST(ManagedArray, SetHostToHost)


#if defined(CHAI_ENABLE_UM)
#if (!defined(CHAI_DISABLE_RM))
#if defined(CHAI_ENABLE_MANAGER)
TEST(ManagedArray, PickHostFromHostConstUM) {
chai::ManagedArray<int> array(10, chai::UM);

Expand Down Expand Up @@ -293,7 +293,7 @@ GPU_TEST(ManagedArray, PickHostFromDeviceUM)
assert_empty_map(true);
}

#if (!defined(CHAI_DISABLE_RM))
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, PickHostFromDeviceConstUM) {
chai::ManagedArray<int> array(10, chai::UM);

Expand Down Expand Up @@ -348,7 +348,7 @@ GPU_TEST(ManagedArray, PickandSetSliceDeviceToDeviceUM) {
}
#endif

#if (!defined(CHAI_DISABLE_RM))
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, PickandSetDeviceToDevice)
{
chai::ManagedArray<int> array1(10);
Expand Down Expand Up @@ -748,7 +748,7 @@ TEST(ManagedArray, ExternalUnownedFromManagedArray)
}

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, ExternalUnownedMoveToGPU)
{
float data[20];
Expand Down Expand Up @@ -794,7 +794,7 @@ TEST(ManagedArray, data)
}

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, dataGPU)
{
// Initialize
Expand Down Expand Up @@ -891,7 +891,7 @@ TEST(ManagedArray, cdata)
}

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, cdataGPU)
{
// Initialize
Expand Down Expand Up @@ -1022,7 +1022,7 @@ TEST(ManagedArray, Reset)
}

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, ResetDevice)
{
chai::ManagedArray<float> array(20);
Expand All @@ -1043,7 +1043,7 @@ GPU_TEST(ManagedArray, ResetDevice)


#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, UserCallback)
{
int num_h2d = 0;
Expand Down Expand Up @@ -1427,7 +1427,7 @@ GPU_TEST(ManagedArray, DeviceInitializedNestedArrays)


#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, Move)
{
chai::ManagedArray<float> array(10, chai::GPU);
Expand Down Expand Up @@ -1700,7 +1700,7 @@ GPU_TEST(ManagedArray, MoveInnerToDeviceAgain)
outerArray.free();
assert_empty_map(true);
}
#endif // CHAI_DISABLE_RM
#endif // defined(CHAI_ENABLE_MANAGER)
#endif // defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)

TEST(ManagedArray, Clone)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/array_manager_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(ArrayManager, Constructor)
ASSERT_NE(rm, nullptr);
}

#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)

TEST(ArrayManager, getPointerMap)
{
Expand Down Expand Up @@ -183,4 +183,4 @@ TEST(ArrayManager, controlGlobalCallback)
ASSERT_TRUE(callbacksAreOn);
}

#endif // !CHAI_DISABLE_RM
#endif // defined(CHAI_ENABLE_MANAGER)