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 
15 namespace sycl {
16 namespace ext {
17 namespace oneapi {
18 namespace experimental {
19 namespace detail {
20 
21 // Base class for property values with a single type value.
23 
24 // Base class for properties with 0 or more than 1 values.
26 
27 // Base class for property values with a single non-type value
28 template <typename T> struct SingleNontypePropertyValueBase {
29  static constexpr auto value = T::value;
30 };
31 
32 // Helper class for property values with a single value
33 template <typename T>
35  : public sycl::detail::conditional_t<HasValue<T>::value,
36  SingleNontypePropertyValueBase<T>,
37  SingleTypePropertyValueBase> {
38  using value_t = T;
39 };
40 
41 } // namespace detail
42 
43 template <typename PropertyT, typename T = void, typename... Ts>
44 struct property_value
46  sizeof...(Ts) == 0 && !std::is_same<T, void>::value,
47  detail::SinglePropertyValue<T>, detail::EmptyPropertyValueBase> {
48  using key_t = PropertyT;
49 };
50 
51 #if __cplusplus >= 201703L // pack fold expressions
52 template <typename PropertyT, typename... A, typename... B>
53 constexpr std::enable_if_t<detail::IsCompileTimeProperty<PropertyT>::value,
54  bool>
57  return (std::is_same<A, B>::value && ...);
58 }
59 
60 template <typename PropertyT, typename... A, typename... B>
61 constexpr std::enable_if_t<detail::IsCompileTimeProperty<PropertyT>::value,
62  bool>
63 operator!=(const property_value<PropertyT, A...> &,
64  const property_value<PropertyT, B...> &) {
65  return (!std::is_same<A, B>::value || ...);
66 }
67 #endif // __cplusplus >= 201703L
68 
69 template <typename V, typename = void> struct is_property_value {
70  static constexpr bool value =
72 };
73 template <typename V, typename O, typename = void> struct is_property_value_of {
74  static constexpr bool value =
76 };
77 // Specialization for compile-time-constant properties
78 template <typename V>
79 struct is_property_value<V, sycl::detail::void_t<typename V::key_t>>
80  : is_property_key<typename V::key_t> {};
81 template <typename V, typename O>
82 struct is_property_value_of<V, O, sycl::detail::void_t<typename V::key_t>>
83  : is_property_key_of<typename V::key_t, O> {};
84 
85 namespace detail {
86 
87 // Specialization of PropertyID for propagating IDs through property_value.
88 template <typename PropertyT, typename... PropertyValueTs>
89 struct PropertyID<property_value<PropertyT, PropertyValueTs...>>
90  : PropertyID<PropertyT> {};
91 
92 // Specialization of IsCompileTimePropertyValue for property values.
93 template <typename PropertyT, typename... PropertyValueTs>
94 struct IsCompileTimePropertyValue<property_value<PropertyT, PropertyValueTs...>>
95  : IsCompileTimeProperty<PropertyT> {};
96 
97 } // namespace detail
98 } // namespace experimental
99 } // namespace oneapi
100 } // namespace ext
101 } // namespace sycl
102 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::ext::oneapi::experimental::is_property_key
Definition: property.hpp:201
cl::sycl::ext::oneapi::experimental::detail::SinglePropertyValue
Definition: property_value.hpp:34
conditional_t
cl::sycl::operator!=
bool operator!=(const multi_ptr< ElementType, Space > &lhs, const multi_ptr< ElementType, Space > &rhs)
Definition: multi_ptr.hpp:632
cl::sycl::ext::oneapi::experimental::detail::IsRuntimeProperty
Definition: property.hpp:186
cl::sycl::ext::oneapi::experimental::is_property_key_of
Definition: property.hpp:202
cl::sycl::ext::oneapi::experimental::detail::SinglePropertyValue::value_t
T value_t
Definition: property_value.hpp:38
cl::sycl::ext::oneapi::experimental::property_value::key_t
PropertyT key_t
Definition: property_value.hpp:48
cl::sycl::ext::oneapi::experimental::detail::PropertyID
Definition: property.hpp:180
sycl
Definition: invoke_simd.hpp:68
cl::sycl::detail::void_t
void void_t
Definition: stl_type_traits.hpp:42
cl::sycl::ext::oneapi::experimental::detail::IsCompileTimeProperty
Definition: property.hpp:189
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:582
cl::sycl::ext::oneapi::experimental::detail::SingleNontypePropertyValueBase
Definition: property_value.hpp:28
cl::sycl::ext::oneapi::experimental::detail::SingleTypePropertyValueBase
Definition: property_value.hpp:22
cl::sycl::ext::oneapi::experimental::is_property_value
Definition: property_value.hpp:69
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::ext::oneapi::experimental::detail::EmptyPropertyValueBase
Definition: property_value.hpp:25
cl::sycl::ext::oneapi::experimental::detail::IsCompileTimePropertyValue
Definition: property_utils.hpp:58
property_utils.hpp
property.hpp
cl::sycl::ext::oneapi::experimental::is_property_value_of
Definition: property_value.hpp:73
cl::sycl::ext::oneapi::experimental::property_value
Definition: property_utils.hpp:23
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:11