Skip to content

Revert "[NFC][SYCL] Switch to std::enable_if (#7628)" #7779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 0 additions & 12 deletions libdevice/cmake/modules/SYCLLibdevice.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ set(compile_opts
-sycl-std=2020
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# If we use non-system GCC, need to pass its location when using
# freshly built clang. The system one might be very old.
get_filename_component(gcc_bin_dir ${CMAKE_CXX_COMPILER} DIRECTORY)
get_filename_component(gcc_install_dir ${gcc_bin_dir} DIRECTORY)
# /bin/g++ doesn't need any fixup. We also need to check that ccache is
# not being used.
if (NOT gcc_install_dir STREQUAL "/" AND NOT gcc_bin_dir MATCHES "ccache")
list(APPEND compile_opts "--gcc-toolchain=${gcc_install_dir}")
endif()
endif()

if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
string(APPEND sycl_targets_opt ",nvptx64-nvidia-cuda")
list(APPEND compile_opts
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/CL/__spirv/spirv_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,23 @@ extern SYCL_EXTERNAL TempRetT __spirv_ImageSampleExplicitLod(SampledType,
// of atomic min/max based on the type
#define __SPIRV_ATOMIC_MINMAX(AS, Op) \
template <typename T> \
typename std::enable_if_t< \
typename sycl::detail::enable_if_t< \
std::is_integral<T>::value && std::is_signed<T>::value, T> \
__spirv_Atomic##Op(AS T *Ptr, __spv::Scope::Flag Memory, \
__spv::MemorySemanticsMask::Flag Semantics, \
T Value) { \
return __spirv_AtomicS##Op(Ptr, Memory, Semantics, Value); \
} \
template <typename T> \
typename std::enable_if_t< \
typename sycl::detail::enable_if_t< \
std::is_integral<T>::value && !std::is_signed<T>::value, T> \
__spirv_Atomic##Op(AS T *Ptr, __spv::Scope::Flag Memory, \
__spv::MemorySemanticsMask::Flag Semantics, \
T Value) { \
return __spirv_AtomicU##Op(Ptr, Memory, Semantics, Value); \
} \
template <typename T> \
typename std::enable_if_t<std::is_floating_point<T>::value, T> \
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value, T> \
__spirv_Atomic##Op(AS T *Ptr, __spv::Scope::Flag Memory, \
__spv::MemorySemanticsMask::Flag Semantics, \
T Value) { \
Expand Down
209 changes: 106 additions & 103 deletions sycl/include/sycl/accessor.hpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions sycl/include/sycl/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class __SYCL2020_DEPRECATED(
#ifdef __ENABLE_USM_ADDR_SPACE__
// Create atomic in global_space with one from ext_intel_global_device_space
template <access::address_space _Space = addressSpace,
typename = typename std::enable_if_t<
typename = typename detail::enable_if_t<
_Space == addressSpace &&
addressSpace == access::address_space::global_space>>
atomic(const atomic<T, access::address_space::ext_intel_global_device_space>
Expand All @@ -219,7 +219,7 @@ class __SYCL2020_DEPRECATED(
}

template <access::address_space _Space = addressSpace,
typename = typename std::enable_if_t<
typename = typename detail::enable_if_t<
_Space == addressSpace &&
addressSpace == access::address_space::global_space>>
atomic(
Expand All @@ -235,13 +235,13 @@ class __SYCL2020_DEPRECATED(

#ifdef __SYCL_DEVICE_ONLY__
template <typename T2 = T>
std::enable_if_t<!std::is_same<cl_float, T2>::value, T>
detail::enable_if_t<!std::is_same<cl_float, T2>::value, T>
load(memory_order Order = memory_order::relaxed) const {
return __spirv_AtomicLoad(Ptr, SpirvScope,
detail::getSPIRVMemorySemanticsMask(Order));
}
template <typename T2 = T>
std::enable_if_t<std::is_same<cl_float, T2>::value, T>
detail::enable_if_t<std::is_same<cl_float, T2>::value, T>
load(memory_order Order = memory_order::relaxed) const {
auto *TmpPtr = reinterpret_cast<typename multi_ptr<
cl_int, addressSpace, access::decorated::yes>::pointer>(Ptr);
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/sycl/atomic_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ inline constexpr memory_order getLoadOrder(memory_order order) {
template <typename T, typename = void> struct bit_equal;

template <typename T>
struct bit_equal<T, typename std::enable_if_t<std::is_integral<T>::value>> {
struct bit_equal<T, typename detail::enable_if_t<std::is_integral<T>::value>> {
bool operator()(const T &lhs, const T &rhs) { return lhs == rhs; }
};

Expand Down Expand Up @@ -266,7 +266,7 @@ class atomic_ref_impl
template <typename T, memory_order DefaultOrder, memory_scope DefaultScope,
access::address_space AddressSpace>
class atomic_ref_impl<T, DefaultOrder, DefaultScope, AddressSpace,
typename std::enable_if_t<std::is_integral<T>::value>>
typename detail::enable_if_t<std::is_integral<T>::value>>
: public atomic_ref_base<T, DefaultOrder, DefaultScope, AddressSpace> {

public:
Expand Down Expand Up @@ -414,7 +414,7 @@ template <typename T, memory_order DefaultOrder, memory_scope DefaultScope,
access::address_space AddressSpace>
class atomic_ref_impl<
T, DefaultOrder, DefaultScope, AddressSpace,
typename std::enable_if_t<std::is_floating_point<T>::value>>
typename detail::enable_if_t<std::is_floating_point<T>::value>>
: public atomic_ref_base<T, DefaultOrder, DefaultScope, AddressSpace> {

public:
Expand Down
14 changes: 7 additions & 7 deletions sycl/include/sycl/backend/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice,
const std::string &Extension);

// Construction of SYCL platform.
template <typename T, typename std::enable_if_t<
template <typename T, typename detail::enable_if_t<
std::is_same<T, platform>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_platform free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_platform(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL device.
template <typename T,
typename std::enable_if_t<std::is_same<T, device>::value> * = nullptr>
template <typename T, typename detail::enable_if_t<
std::is_same<T, device>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_device free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_device(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL context.
template <typename T, typename std::enable_if_t<std::is_same<T, context>::value>
* = nullptr>
template <typename T, typename detail::enable_if_t<
std::is_same<T, context>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_context free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_context(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL queue.
template <typename T,
typename std::enable_if_t<std::is_same<T, queue>::value> * = nullptr>
template <typename T, typename detail::enable_if_t<
std::is_same<T, queue>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_queue free function")
T make(const context &Context,
typename detail::interop<backend::opencl, T>::type Interop) {
Expand Down
14 changes: 7 additions & 7 deletions sycl/include/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class __SYCL_EXPORT buffer_plain {
/// \ingroup sycl_api
template <typename T, int dimensions = 1,
typename AllocatorT = buffer_allocator<std::remove_const_t<T>>,
typename __Enabled =
typename std::enable_if_t<(dimensions > 0) && (dimensions <= 3)>>
typename __Enabled = typename detail::enable_if_t<(dimensions > 0) &&
(dimensions <= 3)>>
class buffer : public detail::buffer_plain,
public detail::OwnerLessBase<buffer<T, dimensions, AllocatorT>> {
// TODO check is_device_copyable<T>::value after converting sycl::vec into a
Expand All @@ -155,21 +155,21 @@ class buffer : public detail::buffer_plain,
using const_reference = const value_type &;
using allocator_type = AllocatorT;
template <int dims>
using EnableIfOneDimension = typename std::enable_if_t<1 == dims>;
using EnableIfOneDimension = typename detail::enable_if_t<1 == dims>;
// using same requirement for contiguous container as std::span
template <class Container>
using EnableIfContiguous =
detail::void_t<std::enable_if_t<std::is_convertible<
detail::void_t<detail::enable_if_t<std::is_convertible<
detail::remove_pointer_t<
decltype(std::declval<Container>().data())> (*)[],
const T (*)[]>::value>,
decltype(std::declval<Container>().size())>;
template <class It>
using EnableIfItInputIterator = std::enable_if_t<
using EnableIfItInputIterator = detail::enable_if_t<
std::is_convertible<typename std::iterator_traits<It>::iterator_category,
std::input_iterator_tag>::value>;
template <typename ItA, typename ItB>
using EnableIfSameNonConstIterators = typename std::enable_if_t<
using EnableIfSameNonConstIterators = typename detail::enable_if_t<
std::is_same<ItA, ItB>::value && !std::is_const<ItA>::value, ItA>;

std::array<size_t, 3> rangeToArray(range<3> &r) { return {r[0], r[1], r[2]}; }
Expand Down Expand Up @@ -575,7 +575,7 @@ class buffer : public detail::buffer_plain,
}

template <template <typename WeakT> class WeakPtrT, typename WeakT>
std::enable_if_t<
detail::enable_if_t<
std::is_convertible<WeakPtrT<WeakT>, std::weak_ptr<WeakT>>::value>
set_final_data_internal(WeakPtrT<WeakT> FinalData) {
std::weak_ptr<WeakT> TempFinalData(FinalData);
Expand Down
Loading