From 25fd008779d625704534a233dc0268f78d03eead Mon Sep 17 00:00:00 2001 From: Alan Dayton <6393677+adayton1@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:27:00 -0800 Subject: [PATCH] Remove implicit conversions (#305) --- RELEASE_NOTES.md | 1 + cmake/SetupOptions.cmake | 4 -- .../lc/toss_4_x86_64_ib_cray/amdclang.cmake | 2 - src/care/KeyValueSorter_decl.h | 51 ------------------- src/care/algorithm_decl.h | 10 ---- src/care/algorithm_impl.h | 15 ------ src/care/care_inst.h | 15 ------ src/care/config.h.in | 1 - src/care/host_device_ptr.h | 16 ------ src/care/host_ptr.h | 9 ---- 10 files changed, 1 insertion(+), 123 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3d7efc33..d3e45687 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -25,6 +25,7 @@ The format of this file is based on [Keep a Changelog](http://keepachangelog.com - Removed Accessor template parameter from host\_device\_ptr. - Removed NoOpAccessor and RaceConditionAccessor. It is recommended to use ThreadSanitizer (TSAN) instead to locate race conditions. - Removed CARE\_ENABLE\_RACE\_DETECTION configuration option. +- Removed implicit conversions between raw pointers and host\_device\_ptrs/host\_ptrs and the corresponding CARE\_ENABLE\_IMPLICIT\_CONVERSIONS configuration option. ### Changed - Renamed host\_device\_ptr::getPointer to host\_device\_ptr::data. diff --git a/cmake/SetupOptions.cmake b/cmake/SetupOptions.cmake index db7fe22f..d70b436c 100644 --- a/cmake/SetupOptions.cmake +++ b/cmake/SetupOptions.cmake @@ -14,10 +14,6 @@ option(ENABLE_PICK "Enable pick and set methods on ManagedArrays" ON) option(ENABLE_PINNED "Enable pinned memory space" ON) option(CARE_ENABLE_PINNED_MEMORY_FOR_SCANS "Use pinned memory for scan lengths" ON) option(CARE_GPU_MEMORY_IS_ACCESSIBLE_ON_CPU "Allows default memory spaces for ZERO_COPY and PAGEABLE to be the GPU memory space" OFF) -# Option to disable implicit conversion between host_device_ptr and raw arrays in CARE. -option(CARE_ENABLE_IMPLICIT_CONVERSIONS "Enable implicit conversions to-from raw pointers" ON) -# CHAI must also be configured with the same settings for implicit conversions. -set(CHAI_ENABLE_IMPLICIT_CONVERSIONS ${CARE_ENABLE_IMPLICIT_CONVERSIONS} CACHE BOOL "Enable implicit conversions to-from raw pointers") option(CARE_LEGACY_COMPATIBILITY_MODE "Enable legacy compatibility mode" OFF) option(CARE_DEEP_COPY_RAW_PTR "Use deep copy for managed array initialization from raw pointer" OFF) option(CARE_ENABLE_MANAGED_PTR "Enable managed_ptr aliases, tests, and reproducer" ON) diff --git a/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake b/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake index 3edbf270..560e9fd1 100644 --- a/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake +++ b/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake @@ -13,5 +13,3 @@ set(ENABLE_HIP ON CACHE BOOL "Enable Hip") set(ROCM_PATH "/usr/tce/packages/rocmcc/rocmcc-6.1.0-magic" CACHE PATH "") set(CMAKE_HIP_ARCHITECTURES "gfx942:xnack+" CACHE STRING "") set(AMDGPU_TARGETS "gfx942:xnack+" CACHE STRING "") - -set(CARE_ENABLE_IMPLICIT_CONVERSIONS OFF CACHE BOOL "Enable implicit conversions") diff --git a/src/care/KeyValueSorter_decl.h b/src/care/KeyValueSorter_decl.h index 8fd0101c..a5fc9d9c 100644 --- a/src/care/KeyValueSorter_decl.h +++ b/src/care/KeyValueSorter_decl.h @@ -174,31 +174,6 @@ class CARE_DLL_API KeyValueSorter { setKeyValueArraysFromManagedArray(m_keys, m_values, len, arr); } -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - - /////////////////////////////////////////////////////////////////////////// - /// @author Alan Dayton - /// - /// @brief Constructor - /// - /// Allocates space and initializes the KeyValueSorter by copying - /// elements and ordering from the given managed array - /// - /// @note This overload is needed to prevent ambiguity when implicit - /// casts are enabled - /// - /// @param[in] len - The number of elements to allocate space for - /// @param[in] arr - The managed array to copy elements from - /// - /// @return a KeyValueSorter instance - /////////////////////////////////////////////////////////////////////////// - KeyValueSorter(const size_t len, const host_device_ptr & arr) - : KeyValueSorter(len, host_device_ptr(arr)) - { - } - -#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /////////////////////////////////////////////////////////////////////////// /// @author Alan Dayton /// @brief (Shallow) Copy constructor @@ -758,32 +733,6 @@ class CARE_DLL_API KeyValueSorter { setKeyValueArraysFromManagedArray(m_keyValues, len, arr); } -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - - /////////////////////////////////////////////////////////////////////////// - /// @author Alan Dayton - /// - /// @brief Constructor - /// - /// Allocates space and initializes the KeyValueSorter by copying - /// elements and ordering from the given managed array - /// - /// @note This overload is needed to prevent ambiguity when implicit - /// casts are enabled - /// - /// @param[in] len - The number of elements to allocate space for - /// @param[in] arr - The managed array to copy elements from - /// - /// @return a KeyValueSorter instance - /// - /////////////////////////////////////////////////////////////////////////// - KeyValueSorter(const size_t len, const host_device_ptr & arr) - : KeyValueSorter(len, host_device_ptr(arr)) - { - } - -#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /////////////////////////////////////////////////////////////////////////// /// @author Alan Dayton /// @brief (Shallow) Copy constructor diff --git a/src/care/algorithm_decl.h b/src/care/algorithm_decl.h index 93765e21..11a200d4 100644 --- a/src/care/algorithm_decl.h +++ b/src/care/algorithm_decl.h @@ -250,16 +250,6 @@ CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr& array, c const bool allowDuplicates = false, const bool warnOnFailure = true); -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - -template -CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr& array, const int len, - const char* name, const char* argname, - const bool allowDuplicates = false, - const bool warnOnFailure = true); - -#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - template CARE_HOST_DEVICE CARE_DLL_API int BinarySearch(const mapType *map, const int start, diff --git a/src/care/algorithm_impl.h b/src/care/algorithm_impl.h index c3a42247..f77c38db 100644 --- a/src/care/algorithm_impl.h +++ b/src/care/algorithm_impl.h @@ -103,21 +103,6 @@ CARE_HOST_DEVICE CARE_INLINE bool checkSorted(const care::host_device_ptr(array.data(), len, name, argname, allowDuplicates, warnOnFailure); } -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - -template -CARE_HOST_DEVICE CARE_INLINE bool checkSorted(const care::host_device_ptr& array, - const int len, - const char* name, - const char* argname, - const bool allowDuplicates, - const bool warnOnFailure) -{ - return checkSorted(care::host_device_ptr(array), len, name, argname, allowDuplicates, warnOnFailure); -} - -#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /************************************************************************ * Function : IntersectArrays * Author(s) : Peter Robinson, based on IntersectGlobalIDArrays by Al Nichols diff --git a/src/care/care_inst.h b/src/care/care_inst.h index b8d8480b..d9d82775 100644 --- a/src/care/care_inst.h +++ b/src/care/care_inst.h @@ -100,21 +100,6 @@ CARE_EXTERN template CARE_DLL_API CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr&, const int, const char*, const char*, const bool, const bool) ; #endif -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - -CARE_EXTERN template CARE_DLL_API -CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr&, const int, const char*, const char*, const bool, const bool) ; -CARE_EXTERN template CARE_DLL_API -CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr&, const int, const char*, const char*, const bool, const bool) ; -CARE_EXTERN template CARE_DLL_API -CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr&, const int, const char*, const char*, const bool, const bool) ; -#if CARE_HAVE_LLNL_GLOBALID -CARE_EXTERN template CARE_DLL_API -CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr&, const int, const char*, const char*, const bool, const bool) ; -#endif - -#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /////////////////////////////////////////////////////////////////////////////// #ifdef CARE_PARALLEL_DEVICE diff --git a/src/care/config.h.in b/src/care/config.h.in index b03790ae..24e99a64 100644 --- a/src/care/config.h.in +++ b/src/care/config.h.in @@ -15,7 +15,6 @@ #cmakedefine CARE_ENABLE_BOUNDS_CHECKING #cmakedefine01 CARE_ENABLE_GPU_SIMULATION_MODE #cmakedefine CARE_NEVER_USE_RAJA_PARALLEL_SCAN -#cmakedefine CARE_ENABLE_IMPLICIT_CONVERSIONS #ifndef CARE_LEGACY_COMPATIBILITY_MODE #cmakedefine01 CARE_LEGACY_COMPATIBILITY_MODE #endif diff --git a/src/care/host_device_ptr.h b/src/care/host_device_ptr.h index 3dfe40f4..633d3a1d 100644 --- a/src/care/host_device_ptr.h +++ b/src/care/host_device_ptr.h @@ -97,22 +97,6 @@ namespace care { /// CARE_HOST_DEVICE host_device_ptr(std::nullptr_t from) noexcept : MA (from) {} -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /// - /// @author Peter Robinson - /// - /// Construct from a raw pointer - /// - /// @note Only safe if the raw pointer is already registered with CHAI - /// - template - CARE_HOST_DEVICE host_device_ptr( - T * from, //!< Raw pointer to construct from - chai::CHAIDISAMBIGUATE name=chai::CHAIDISAMBIGUATE(), //!< Used to disambiguate this constructor - bool foo=Q) //!< Used to disambiguate this constructor - : MA(from, name, foo) {} -#endif - /// /// @author Peter Robinson /// diff --git a/src/care/host_ptr.h b/src/care/host_ptr.h index 8b455199..65d2cb2b 100644 --- a/src/care/host_ptr.h +++ b/src/care/host_ptr.h @@ -123,15 +123,6 @@ namespace care { return m_ptr[index]; } -#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS) - /// - /// @author Peter Robinson - /// - /// Convert to a raw pointer - /// - operator T*() const { return m_ptr; } -#endif - /// /// @author Peter Robinson ///