diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f0e02399..30650230 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/cmake/SetupChaiOptions.cmake b/cmake/SetupChaiOptions.cmake index e4d7414b..51e3ea3d 100644 --- a/cmake/SetupChaiOptions.cmake +++ b/cmake/SetupChaiOptions.cmake @@ -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) @@ -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() diff --git a/docs/sphinx/advanced_configuration.rst b/docs/sphinx/advanced_configuration.rst index 846f5048..8bbf407b 100644 --- a/docs/sphinx/advanced_configuration.rst +++ b/docs/sphinx/advanced_configuration.rst @@ -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. =========================== ======== =============================================================================== @@ -57,10 +57,11 @@ These arguments are explained in more detail below: ``ManagedArray`` 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. diff --git a/src/chai/CMakeLists.txt b/src/chai/CMakeLists.txt index 2285c544..1c1f79f2 100644 --- a/src/chai/CMakeLists.txt +++ b/src/chai/CMakeLists.txt @@ -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) diff --git a/src/chai/ChaiMacros.hpp b/src/chai/ChaiMacros.hpp index 2ff13c72..549d76a1 100644 --- a/src/chai/ChaiMacros.hpp +++ b/src/chai/ChaiMacros.hpp @@ -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); diff --git a/src/chai/ManagedArray.hpp b/src/chai/ManagedArray.hpp index 6cfd5063..67e8cef5 100644 --- a/src/chai/ManagedArray.hpp +++ b/src/chai/ManagedArray.hpp @@ -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. * @@ -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) { @@ -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. @@ -505,7 +505,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 @@ -589,9 +589,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 fdb77cdd..3638dffb 100644 --- a/src/chai/config.hpp.in +++ b/src/chai/config.hpp.in @@ -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 diff --git a/src/chai/managed_ptr.hpp b/src/chai/managed_ptr.hpp index 14988cb0..3b2f4578 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 @@ -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(); @@ -869,7 +869,7 @@ namespace chai { template 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(); @@ -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 @@ -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(); @@ -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 @@ -955,7 +955,7 @@ namespace chai { template 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(); @@ -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 @@ -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(); @@ -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 diff --git a/tests/integration/managed_array_tests.cpp b/tests/integration/managed_array_tests.cpp index 28f4e11b..763b4f7b 100644 --- a/tests/integration/managed_array_tests.cpp +++ b/tests/integration/managed_array_tests.cpp @@ -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) @@ -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 array(10); @@ -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 array(10); @@ -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 array(10, chai::UM); @@ -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 array(10, chai::UM); @@ -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 array1(10); @@ -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]; @@ -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 @@ -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 @@ -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 array(20); @@ -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; @@ -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 array(10, chai::GPU); @@ -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 array(10); @@ -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 array(10, chai::GPU); diff --git a/tests/unit/array_manager_unit_tests.cpp b/tests/unit/array_manager_unit_tests.cpp index abc4197a..f872582c 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)