DPC++ Runtime
Runtime libraries for oneAPI DPC++
accessor_properties.hpp
Go to the documentation of this file.
1 //==----------- accessor_properties.hpp --- SYCL accessor properties -------==//
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 
11 #include <sycl/access/access.hpp>
12 #include <sycl/detail/common.hpp>
13 #include <sycl/detail/defines.hpp>
18 
19 #include <type_traits>
20 
21 namespace sycl {
22 inline namespace _V1 {
23 namespace property {
24 
25 class no_init : public detail::DataLessProperty<detail::NoInit> {};
26 
27 class __SYCL2020_DEPRECATED("spelling is now: no_init") noinit
28  : public detail::DataLessProperty<detail::NoInit> {};
29 
30 } // namespace property
31 
32 inline constexpr property::no_init no_init;
33 
34 __SYCL2020_DEPRECATED("spelling is now: no_init")
35 inline constexpr property::noinit noinit;
36 
37 namespace ext::intel {
38 namespace property {
39 struct __SYCL_TYPE(buffer_location) buffer_location {
40  template <int A = 0> struct instance {
41  template <int B>
42  constexpr bool operator==(const buffer_location::instance<B> &) const {
43  return A == B;
44  }
45  template <int B>
46  constexpr bool operator!=(const buffer_location::instance<B> &) const {
47  return A != B;
48  }
49  int get_location() { return A; }
50  };
51 };
52 } // namespace property
53 
54 template <int A>
55 inline constexpr property::buffer_location::instance<A> buffer_location{};
56 } // namespace ext::intel
57 
58 namespace ext::oneapi {
59 namespace property {
60 struct no_offset {
61  template <bool B = true> struct instance {
62  constexpr bool operator==(const no_offset::instance<B> &) const {
63  return true;
64  }
65  constexpr bool operator!=(const no_offset::instance<B> &) const {
66  return false;
67  }
68  };
69 };
70 struct __SYCL_TYPE(no_alias) no_alias {
71  template <bool B = true> struct instance {
72  constexpr bool operator==(const no_alias::instance<B> &) const {
73  return true;
74  }
75  constexpr bool operator!=(const no_alias::instance<B> &) const {
76  return false;
77  }
78  };
79 };
80 } // namespace property
81 
83 inline constexpr property::no_alias::instance<> no_alias;
84 
85 template <>
87  : std::true_type {};
88 template <>
90  : std::true_type {};
91 template <>
93  : std::true_type {};
94 } // namespace ext::oneapi
95 
96 // Forward declaration
97 template <typename DataT, int Dimensions, access::mode AccessMode,
99  typename PropertyListT>
100 class accessor;
101 template <typename DataT, int Dimensions, access::mode AccessMode>
102 class host_accessor;
103 template <typename DataT, int Dimensions>
104 class __SYCL_EBO
106 template <typename DataT, int Dimensions, access::mode AccessMode,
109 template <typename DataT, int Dimensions, access_mode AccessMode,
110  image_target AccessTarget>
112 template <typename DataT, int Dimensions, image_target AccessTarget>
114 template <typename DataT, int Dimensions, access_mode AccessMode>
116 template <typename DataT, int Dimensions> class host_sampled_image_accessor;
117 
118 namespace detail::acc_properties {
119 template <typename T> struct is_accessor : std::false_type {};
120 template <typename DataT, int Dimensions, access::mode AccessMode,
122  typename PropertyListT>
123 struct is_accessor<accessor<DataT, Dimensions, AccessMode, AccessTarget,
124  IsPlaceholder, PropertyListT>> : std::true_type {};
125 template <typename T>
126 inline constexpr bool is_accessor_v = is_accessor<T>::value;
127 
128 template <typename T> struct is_sycl2020_image_accessor : std::false_type {};
129 template <typename DataT, int Dimensions, access_mode AccessMode,
130  image_target AccessTarget>
132  unsampled_image_accessor<DataT, Dimensions, AccessMode, AccessTarget>>
133  : std::true_type {};
134 template <typename DataT, int Dimensions, image_target AccessTarget>
136  sampled_image_accessor<DataT, Dimensions, AccessTarget>> : std::true_type {
137 };
138 template <typename T>
139 inline constexpr bool is_sycl2020_image_accessor_v =
141 
142 template <typename T>
143 struct is_sycl2020_image_host_accessor : std::false_type {};
144 template <typename DataT, int Dimensions, access_mode AccessMode>
147  : std::true_type {};
148 template <typename DataT, int Dimensions>
150  host_sampled_image_accessor<DataT, Dimensions>> : std::true_type {};
151 template <typename T>
152 inline constexpr bool is_sycl2020_image_host_accessor_v =
154 
155 template <typename T> struct is_host_accessor : std::false_type {};
156 template <typename DataT, int Dimensions, access::mode AccessMode>
158  : std::true_type {};
159 template <typename T>
161 
162 template <typename T> struct is_local_accessor : std::false_type {};
163 template <typename T, int Dimensions>
164 struct is_local_accessor<local_accessor<T, Dimensions>> : std::true_type {};
165 template <typename T>
167 
168 template <typename T> struct is_image_accessor : std::false_type {};
169 template <typename T, int Dimensions, access::mode AccessMode,
170  access::placeholder IsPlaceholder, typename PropertyListT>
172  accessor<T, Dimensions, AccessMode, access::target::image, IsPlaceholder,
173  PropertyListT>> : std::true_type {};
174 template <typename T, int Dimensions, access::mode AccessMode,
178  : std::true_type {};
179 template <typename T>
181 } // namespace detail::acc_properties
182 
183 // Accessor property trait specializations
184 template <>
185 struct is_property<ext::oneapi::property::no_offset> : std::true_type {};
186 template <>
187 struct is_property<ext::oneapi::property::no_alias> : std::true_type {};
188 template <>
189 struct is_property<ext::intel::property::buffer_location> : std::true_type {};
190 
191 template <typename T>
192 struct is_property_of<property::noinit, T>
193  : std::bool_constant<detail::acc_properties::is_accessor<T>::value ||
194  detail::acc_properties::is_host_accessor<T>::value> {};
195 
196 template <typename T>
197 struct is_property_of<property::no_init, T>
198  : std::bool_constant<
199  detail::acc_properties::is_accessor_v<T> ||
200  detail::acc_properties::is_host_accessor_v<T> ||
201  detail::acc_properties::is_sycl2020_image_accessor_v<T> ||
202  detail::acc_properties::is_sycl2020_image_host_accessor_v<T>> {};
203 
204 template <typename T>
206  : std::bool_constant<detail::acc_properties::is_accessor<T>::value> {};
207 
208 template <typename T>
210  : std::bool_constant<detail::acc_properties::is_accessor<T>::value> {};
211 
212 template <typename T>
214  : std::bool_constant<detail::acc_properties::is_accessor<T>::value> {};
215 
216 namespace detail {
217 template <int I>
219  ext::intel::property::buffer_location::instance<I>> : std::true_type {};
220 template <>
222  ext::oneapi::property::no_alias::instance<>> : std::true_type {};
223 template <>
225  ext::oneapi::property::no_offset::instance<>> : std::true_type {};
226 } // namespace detail
227 } // namespace _V1
228 } // namespace sycl
#define __SYCL_SPECIAL_CLASS
Definition: defines.hpp:29
#define __SYCL_EBO
Definition: common.hpp:175
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor< DataT
Image accessors.
constexpr property::buffer_location::instance< A > buffer_location
constexpr property::no_alias::instance no_alias
constexpr property::no_offset::instance no_offset
constexpr property::noinit noinit
image_target
Definition: access.hpp:74
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
constexpr property::no_init no_init
signed char __SYCL2020_DEPRECATED
Definition: aliases.hpp:94
class __SYCL_EBO __SYCL_SPECIAL_CLASS IsPlaceholder
class __SYCL_EBO __SYCL_SPECIAL_CLASS AccessMode
Definition: access.hpp:18
constexpr bool operator==(const no_offset::instance< B > &) const
constexpr bool operator!=(const no_offset::instance< B > &) const