diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1bffbce5..ac7d01d4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/cmake/SetupChaiOptions.cmake b/cmake/SetupChaiOptions.cmake index 63e3d4b0..0a3ac504 100644 --- a/cmake/SetupChaiOptions.cmake +++ b/cmake/SetupChaiOptions.cmake @@ -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) @@ -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() diff --git a/docs/sphinx/advanced_configuration.rst b/docs/sphinx/advanced_configuration.rst index d8370b6a..043b9450 100644 --- a/docs/sphinx/advanced_configuration.rst +++ b/docs/sphinx/advanced_configuration.rst @@ -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. =========================== ======== =============================================================================== @@ -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. diff --git a/src/chai/CMakeLists.txt b/src/chai/CMakeLists.txt index a7a5cdf6..b0a22dae 100644 --- a/src/chai/CMakeLists.txt +++ b/src/chai/CMakeLists.txt @@ -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) diff --git a/src/chai/ChaiMacros.hpp b/src/chai/ChaiMacros.hpp index 4ba6e980..a3785537 100644 --- a/src/chai/ChaiMacros.hpp +++ b/src/chai/ChaiMacros.hpp @@ -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); diff --git a/src/chai/ManagedArray.hpp b/src/chai/ManagedArray.hpp index f4593ef7..fb324542 100644 --- a/src/chai/ManagedArray.hpp +++ b/src/chai/ManagedArray.hpp @@ -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. * @@ -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) { @@ -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. @@ -483,7 +483,7 @@ ManagedArray 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 @@ -573,9 +573,9 @@ CHAI_INLINE CHAI_HOST_DEVICE ManagedArray ManagedArray::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 diff --git a/src/chai/config.hpp.in b/src/chai/config.hpp.in index e8b1f847..a80a8bab 100644 --- a/src/chai/config.hpp.in +++ b/src/chai/config.hpp.in @@ -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 diff --git a/src/chai/managed_ptr.hpp b/src/chai/managed_ptr.hpp index 0bed0a19..0cdc9dd0 100644 --- a/src/chai/managed_ptr.hpp +++ b/src/chai/managed_ptr.hpp @@ -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 @@ -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(); @@ -1085,7 +1085,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker unpack(const chai::ManagedArray 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(); @@ -1098,7 +1098,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker unpack(const chai::ManagedArraysetExecutionSpace(currentSpace); #endif @@ -1133,7 +1133,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker unpack(const chai::ManagedArray 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(); @@ -1171,7 +1171,7 @@ CHAI_HOST ManagedArrayOfManagedPtrUnpacker unpack(const chai::ManagedArraysetExecutionSpace(currentSpace); #endif diff --git a/tests/integration/managed_array_tests.cpp b/tests/integration/managed_array_tests.cpp index 9e4a22a9..14ffc770 100644 --- a/tests/integration/managed_array_tests.cpp +++ b/tests/integration/managed_array_tests.cpp @@ -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) @@ -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 array(10); @@ -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 array(10); @@ -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 array(10, chai::UM); @@ -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 array(10, chai::UM); @@ -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 array1(10); @@ -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]; @@ -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 @@ -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 @@ -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 array(20); @@ -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; @@ -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 array(10, chai::GPU); @@ -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) diff --git a/tests/unit/array_manager_unit_tests.cpp b/tests/unit/array_manager_unit_tests.cpp index 072c0731..fa96c79a 100644 --- a/tests/unit/array_manager_unit_tests.cpp +++ b/tests/unit/array_manager_unit_tests.cpp @@ -16,7 +16,7 @@ TEST(ArrayManager, Constructor) ASSERT_NE(rm, nullptr); } -#ifndef CHAI_DISABLE_RM +#if defined(CHAI_ENABLE_MANAGER) TEST(ArrayManager, getPointerMap) { @@ -183,4 +183,4 @@ TEST(ArrayManager, controlGlobalCallback) ASSERT_TRUE(callbacksAreOn); } -#endif // !CHAI_DISABLE_RM +#endif // defined(CHAI_ENABLE_MANAGER)