DPC++ Runtime
Runtime libraries for oneAPI DPC++
property_value.hpp
Go to the documentation of this file.
1 //==------ property_value.hpp --- SYCL compile-time property values --------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
13 
14 namespace sycl {
16 namespace ext::oneapi::experimental {
17 namespace detail {
18 
19 // Base class for property values with a single non-type value
20 template <typename T, typename = void> struct SingleNontypePropertyValueBase {};
21 
22 template <typename T>
23 struct SingleNontypePropertyValueBase<T, std::enable_if_t<HasValue<T>::value>> {
24  static constexpr auto value = T::value;
25 };
26 
27 // Helper base class for property_value.
28 template <typename... Ts> struct PropertyValueBase {};
29 
30 template <typename T>
32  using value_t = T;
33 };
34 
35 } // namespace detail
36 
37 template <typename PropertyT, typename... Ts>
38 struct property_value : public detail::PropertyValueBase<Ts...> {
39  using key_t = PropertyT;
40 };
41 
42 template <typename PropertyT, typename... A, typename... B>
43 constexpr std::enable_if_t<detail::IsCompileTimeProperty<PropertyT>::value,
44  bool>
47  return (std::is_same<A, B>::value && ...);
48 }
49 
50 template <typename PropertyT, typename... A, typename... B>
51 constexpr std::enable_if_t<detail::IsCompileTimeProperty<PropertyT>::value,
52  bool>
55  return (!std::is_same<A, B>::value || ...);
56 }
57 
58 template <typename V, typename = void> struct is_property_value {
59  static constexpr bool value =
61 };
62 template <typename V, typename O, typename = void> struct is_property_value_of {
63  static constexpr bool value =
65 };
66 // Specialization for compile-time-constant properties
67 template <typename V>
68 struct is_property_value<V, sycl::detail::void_t<typename V::key_t>>
69  : is_property_key<typename V::key_t> {};
70 template <typename V, typename O>
71 struct is_property_value_of<V, O, sycl::detail::void_t<typename V::key_t>>
72  : is_property_key_of<typename V::key_t, O> {};
73 
74 namespace detail {
75 
76 // Specialization of PropertyID for propagating IDs through property_value.
77 template <typename PropertyT, typename... PropertyValueTs>
78 struct PropertyID<property_value<PropertyT, PropertyValueTs...>>
79  : PropertyID<PropertyT> {};
80 
81 // Specialization of IsCompileTimePropertyValue for property values.
82 template <typename PropertyT, typename... PropertyValueTs>
83 struct IsCompileTimePropertyValue<property_value<PropertyT, PropertyValueTs...>>
84  : IsCompileTimeProperty<PropertyT> {};
85 
86 } // namespace detail
87 } // namespace ext::oneapi::experimental
88 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
89 } // namespace sycl
sycl::_V1::ext::oneapi::experimental::detail::PropertyValueBase
Definition: property_value.hpp:28
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::ext::oneapi::experimental::detail::IsCompileTimeProperty
Definition: property.hpp:209
sycl::_V1::ext::oneapi::experimental::detail::IsRuntimeProperty
Definition: property.hpp:206
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::ext::oneapi::experimental::detail::PropertyValueBase< T >::value_t
T value_t
Definition: property_value.hpp:32
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:313
sycl::_V1::ext::oneapi::experimental::is_property_key_of
Definition: property.hpp:222
sycl::_V1::ext::oneapi::experimental::detail::IsCompileTimePropertyValue
Definition: property_utils.hpp:57
sycl::_V1::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
sycl::_V1::ext::oneapi::experimental::property_value::key_t
PropertyT key_t
Definition: property_value.hpp:39
sycl::_V1::ext::oneapi::experimental::detail::SingleNontypePropertyValueBase
Definition: property_value.hpp:20
sycl::_V1::ext::oneapi::experimental::detail::PropertyID
Definition: property.hpp:200
std
Definition: accessor.hpp:3230
property_utils.hpp
sycl::_V1::ext::oneapi::experimental::is_property_value
Definition: property_value.hpp:58
sycl::_V1::ext::oneapi::experimental::operator!=
constexpr std::enable_if_t< detail::IsCompileTimeProperty< PropertyT >::value, bool > operator!=(const property_value< PropertyT, A... > &, const property_value< PropertyT, B... > &)
Definition: property_value.hpp:53
property.hpp
sycl::_V1::ext::oneapi::experimental::property_value
Definition: property_utils.hpp:22
sycl::_V1::ext::oneapi::experimental::is_property_value_of
Definition: property_value.hpp:62
sycl::_V1::ext::oneapi::experimental::is_property_key
Definition: property.hpp:221
sycl::_V1::detail::void_t
void void_t
Definition: stl_type_traits.hpp:42