Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -21,6 +21,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_OPENMP "Enable OpenMP" Off)
option(CHAI_ENABLE_MPI "Enable MPI (for umpire replay only)" Off)
option(CHAI_ENABLE_IMPLICIT_CONVERSIONS "Enable implicit conversions to-from raw pointers" On)

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 @@ -41,6 +41,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 @@ -26,7 +26,7 @@ Here is a summary of the configuration options, their default value, and meaning
CHAI_ENABLE_GPU_SIMULATION_MODE Off Simulates GPU execution.
CHAI_ENABLE_UM Off Enable support for CUDA Unified Memory.
CHAI_ENABLE_IMPLICIT_CONVERSIONS On Enable implicit conversions between ManagedArray and raw pointers
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 Down Expand Up @@ -57,10 +57,11 @@ These arguments are explained in more detail below:
``ManagedArray<T>`` and the correpsonding raw pointer type ``T*``. This
option is disabled by default, and should be used with caution.

* 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 @@ -22,7 +22,7 @@ set (chai_headers
PointerRecord.hpp
Types.hpp)

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 @@ -70,7 +70,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 @@ -358,7 +358,7 @@ class ManagedArray : public CHAICopyable
#endif


#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
/*!
* \brief Assign a user-defined callback triggerd upon memory migration.
*
Expand Down Expand Up @@ -415,7 +415,7 @@ class ManagedArray : public CHAICopyable
m_offset = other.m_offset;
m_pointer_record = other.m_pointer_record;
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 @@ -435,7 +435,7 @@ class ManagedArray : public CHAICopyable
CHAI_HOST void modify(size_t i, const T& val) const;
// 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
// ManagedArrays to nullptr at allocation, since it is extremely easy to
// trigger a moveInnerImpl, which expects inner values to be initialized.
Expand Down Expand Up @@ -505,7 +505,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 @@ -589,9 +589,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 @@ -11,7 +11,7 @@
#cmakedefine CHAI_ENABLE_CUDA
#cmakedefine CHAI_ENABLE_HIP
#cmakedefine CHAI_ENABLE_IMPLICIT_CONVERSIONS
#cmakedefine CHAI_DISABLE_RM
#cmakedefine CHAI_ENABLE_MANAGER
#cmakedefine CHAI_THIN_GPU_ALLOCATE
#cmakedefine CHAI_ENABLE_UM
#cmakedefine CHAI_DEBUG
Expand Down
20 changes: 10 additions & 10 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 @@ -589,7 +589,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 @@ -869,7 +869,7 @@ namespace chai {
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 @@ -882,7 +882,7 @@ namespace chai {
// 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 All @@ -907,7 +907,7 @@ namespace chai {
typename F,
typename... Args>
CHAI_HOST T* make_on_host_from_factory(F f, 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 @@ -920,7 +920,7 @@ namespace chai {
// Create the object on the device
T* cpuPointer = f(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 @@ -955,7 +955,7 @@ namespace chai {
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 @@ -987,7 +987,7 @@ namespace chai {
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 All @@ -1010,7 +1010,7 @@ namespace chai {
typename F,
typename... Args>
CHAI_HOST T* make_on_device_from_factory(F f, 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 @@ -1042,7 +1042,7 @@ namespace chai {
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
30 changes: 15 additions & 15 deletions tests/integration/managed_array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 Down Expand Up @@ -50,7 +50,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 @@ -165,7 +165,7 @@ TEST(ManagedArray, ArrayOfSlices) {
}

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

Expand Down Expand Up @@ -236,7 +236,7 @@ TEST(ManagedArray, IncrementDecrementOnHost)


#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 @@ -343,7 +343,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 @@ -443,7 +443,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 @@ -904,7 +904,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 @@ -950,7 +950,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 @@ -1047,7 +1047,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 @@ -1178,7 +1178,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 @@ -1199,7 +1199,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 @@ -1583,7 +1583,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 @@ -1856,11 +1856,11 @@ 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)


#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
TEST(ManagedArray, DeepCopy)
{
chai::ManagedArray<float> array(10);
Expand All @@ -1885,7 +1885,7 @@ TEST(ManagedArray, DeepCopy)
#endif

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#ifndef CHAI_DISABLE_RM
#if defined(CHAI_ENABLE_MANAGER)
GPU_TEST(ManagedArray, DeviceDeepCopy)
{
chai::ManagedArray<float> array(10, chai::GPU);
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)