Skip to content

Commit

Permalink
Remove implicit conversions (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
adayton1 authored Nov 22, 2024
1 parent f818cc3 commit 25fd008
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 123 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions cmake/SetupOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
51 changes: 0 additions & 51 deletions src/care/KeyValueSorter_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,31 +174,6 @@ class CARE_DLL_API KeyValueSorter<KeyType, ValueType, RAJADeviceExec> {
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<KeyType, ValueType, RAJADeviceExec>(const size_t len, const host_device_ptr<ValueType> & arr)
: KeyValueSorter<KeyType, ValueType, RAJADeviceExec>(len, host_device_ptr<const ValueType>(arr))
{
}

#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

///////////////////////////////////////////////////////////////////////////
/// @author Alan Dayton
/// @brief (Shallow) Copy constructor
Expand Down Expand Up @@ -758,32 +733,6 @@ class CARE_DLL_API KeyValueSorter<KeyType, ValueType, RAJA::seq_exec> {
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<KeyType, ValueType, RAJA::seq_exec>(const size_t len, const host_device_ptr<ValueType> & arr)
: KeyValueSorter<KeyType, ValueType, RAJA::seq_exec>(len, host_device_ptr<const ValueType>(arr))
{
}

#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

///////////////////////////////////////////////////////////////////////////
/// @author Alan Dayton
/// @brief (Shallow) Copy constructor
Expand Down
10 changes: 0 additions & 10 deletions src/care/algorithm_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,6 @@ CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr<const T>& array, c
const bool allowDuplicates = false,
const bool warnOnFailure = true);

#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

template <typename T>
CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr<T>& 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<typename mapType>
CARE_HOST_DEVICE CARE_DLL_API int BinarySearch(const mapType *map,
const int start,
Expand Down
15 changes: 0 additions & 15 deletions src/care/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,6 @@ CARE_HOST_DEVICE CARE_INLINE bool checkSorted(const care::host_device_ptr<const
return checkSorted<T>(array.data(), len, name, argname, allowDuplicates, warnOnFailure);
}

#if defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

template <typename T>
CARE_HOST_DEVICE CARE_INLINE bool checkSorted(const care::host_device_ptr<T>& array,
const int len,
const char* name,
const char* argname,
const bool allowDuplicates,
const bool warnOnFailure)
{
return checkSorted(care::host_device_ptr<const T>(array), len, name, argname, allowDuplicates, warnOnFailure);
}

#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

/************************************************************************
* Function : IntersectArrays<A,RAJAExec>
* Author(s) : Peter Robinson, based on IntersectGlobalIDArrays by Al Nichols
Expand Down
15 changes: 0 additions & 15 deletions src/care/care_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ CARE_EXTERN template CARE_DLL_API
CARE_HOST_DEVICE bool checkSorted(const care::host_device_ptr<const globalID>&, 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<int>&, 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<float>&, 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<double>&, 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<globalID>&, const int, const char*, const char*, const bool, const bool) ;
#endif

#endif // defined(CARE_ENABLE_IMPLICIT_CONVERSIONS)

///////////////////////////////////////////////////////////////////////////////

#ifdef CARE_PARALLEL_DEVICE
Expand Down
1 change: 0 additions & 1 deletion src/care/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions src/care/host_device_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,6 @@ namespace care {
///
CARE_HOST_DEVICE host_device_ptr<T>(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 <bool Q = 0>
CARE_HOST_DEVICE host_device_ptr<T>(
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
///
Expand Down
9 changes: 0 additions & 9 deletions src/care/host_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit 25fd008

Please sign in to comment.