DPC++ Runtime
Runtime libraries for oneAPI DPC++
generic_type_traits.hpp
Go to the documentation of this file.
1 //==----------- generic_type_traits - SYCL type traits ---------------------==//
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> // for decorated, address_space
12 #include <sycl/aliases.hpp> // for half, cl_char, cl_double
13 #include <sycl/detail/generic_type_lists.hpp> // for nonconst_address_space...
14 #include <sycl/detail/helpers.hpp> // for marray
15 #include <sycl/detail/type_list.hpp> // for is_contained, find_sam...
16 #include <sycl/detail/type_traits.hpp> // for is_gen_based_on_type_s...
17 #include <sycl/half_type.hpp> // for BIsRepresentationT
18 #include <sycl/multi_ptr.hpp> // for multi_ptr, address_spa...
19 
20 #include <cstddef> // for byte
21 #include <cstdint> // for uint8_t
22 #include <limits> // for numeric_limits
23 #include <type_traits> // for enable_if_t, condition...
24 
25 namespace sycl {
26 inline namespace _V1 {
27 namespace detail {
28 template <int N> struct Boolean;
29 
30 template <typename T>
31 inline constexpr bool is_floatn_v = is_contained_v<T, gtl::vector_float_list>;
32 
33 template <typename T>
34 inline constexpr bool is_genfloatf_v = is_contained_v<T, gtl::float_list>;
35 
36 template <typename T>
37 inline constexpr bool is_svgenfloatf_v =
38  is_contained_v<T, gtl::scalar_vector_float_list>;
39 
40 template <typename T>
41 inline constexpr bool is_doublen_v = is_contained_v<T, gtl::vector_double_list>;
42 
43 template <typename T>
44 inline constexpr bool is_genfloatd_v = is_contained_v<T, gtl::double_list>;
45 
46 template <typename T>
47 inline constexpr bool is_svgenfloatd_v =
48  is_contained_v<T, gtl::scalar_vector_double_list>;
49 
50 template <typename T>
51 inline constexpr bool is_halfn_v = is_contained_v<T, gtl::vector_half_list>;
52 
53 template <typename T>
54 inline constexpr bool is_genfloath_v = is_contained_v<T, gtl::half_list>;
55 
56 template <typename T>
57 inline constexpr bool is_half_v = is_contained_v<T, gtl::scalar_half_list>;
58 
59 template <typename T>
60 inline constexpr bool is_bfloat16_v =
61  is_contained_v<T, gtl::scalar_bfloat16_list>;
62 
63 template <typename T>
64 inline constexpr bool is_half_or_bf16_v =
65  is_contained_v<T, gtl::half_bfloat16_list>;
66 
67 template <typename T>
68 inline constexpr bool is_svgenfloath_v =
69  is_contained_v<T, gtl::scalar_vector_half_list>;
70 
71 template <typename T>
72 inline constexpr bool is_genfloat_v = is_contained_v<T, gtl::floating_list>;
73 
74 template <typename T>
75 inline constexpr bool is_sgenfloat_v =
76  is_contained_v<T, gtl::scalar_floating_list>;
77 
78 template <typename T>
79 inline constexpr bool is_vgenfloat_v =
80  is_contained_v<T, gtl::vector_floating_list>;
81 
82 template <typename T>
83 inline constexpr bool is_svgenfloat_v =
84  is_contained_v<T, gtl::scalar_vector_floating_list>;
85 
86 template <typename T>
87 inline constexpr bool is_mgenfloat_v =
88  is_marray_v<T> && is_svgenfloat_v<get_elem_type_t<T>>;
89 
90 template <typename T>
91 inline constexpr bool is_gengeofloat_v = is_contained_v<T, gtl::geo_float_list>;
92 
93 template <typename T>
94 inline constexpr bool is_gengeodouble_v =
95  is_contained_v<T, gtl::geo_double_list>;
96 
97 template <typename T>
98 inline constexpr bool is_gengeomarrayfloat_v =
99  is_contained_v<T, gtl::marray_geo_float_list>;
100 
101 template <typename T>
102 inline constexpr bool is_gengeomarray_v =
103  is_contained_v<T, gtl::marray_geo_list>;
104 
105 template <typename T>
106 inline constexpr bool is_gengeohalf_v = is_contained_v<T, gtl::geo_half_list>;
107 
108 template <typename T>
109 inline constexpr bool is_vgengeofloat_v =
110  is_contained_v<T, gtl::vector_geo_float_list>;
111 
112 template <typename T>
113 inline constexpr bool is_vgengeodouble_v =
114  is_contained_v<T, gtl::vector_geo_double_list>;
115 
116 template <typename T>
117 inline constexpr bool is_vgengeohalf_v =
118  is_contained_v<T, gtl::vector_geo_half_list>;
119 
120 template <typename T>
121 inline constexpr bool is_sgengeo_v = is_contained_v<T, gtl::scalar_geo_list>;
122 
123 template <typename T>
124 inline constexpr bool is_vgengeo_v = is_contained_v<T, gtl::vector_geo_list>;
125 
126 template <typename T>
127 inline constexpr bool is_gencrossfloat_v =
128  is_contained_v<T, gtl::cross_float_list>;
129 
130 template <typename T>
131 inline constexpr bool is_gencrossdouble_v =
132  is_contained_v<T, gtl::cross_double_list>;
133 
134 template <typename T>
135 inline constexpr bool is_gencrosshalf_v =
136  is_contained_v<T, gtl::cross_half_list>;
137 
138 template <typename T>
139 inline constexpr bool is_gencross_v =
140  is_contained_v<T, gtl::cross_floating_list>;
141 
142 template <typename T>
143 inline constexpr bool is_gencrossmarray_v =
144  is_contained_v<T, gtl::cross_marray_list>;
145 
146 template <typename T>
147 inline constexpr bool is_charn_v =
148  is_contained_v<T, gtl::vector_default_char_list>;
149 
150 template <typename T>
151 inline constexpr bool is_scharn_v =
152  is_contained_v<T, gtl::vector_signed_char_list>;
153 
154 template <typename T>
155 inline constexpr bool is_ucharn_v =
156  is_contained_v<T, gtl::vector_unsigned_char_list>;
157 
158 template <typename T>
159 inline constexpr bool is_igenchar_v = is_contained_v<T, gtl::signed_char_list>;
160 
161 template <typename T>
162 inline constexpr bool is_ugenchar_v =
163  is_contained_v<T, gtl::unsigned_char_list>;
164 
165 template <typename T>
166 inline constexpr bool is_genchar_v = is_contained_v<T, gtl::char_list>;
167 
168 template <typename T>
169 inline constexpr bool is_shortn_v =
170  is_contained_v<T, gtl::vector_signed_short_list>;
171 
172 template <typename T>
173 inline constexpr bool is_genshort_v = is_contained_v<T, gtl::signed_short_list>;
174 
175 template <typename T>
176 inline constexpr bool is_ushortn_v =
177  is_contained_v<T, gtl::vector_unsigned_short_list>;
178 
179 template <typename T>
180 inline constexpr bool is_ugenshort_v =
181  is_contained_v<T, gtl::unsigned_short_list>;
182 
183 template <typename T>
184 inline constexpr bool is_uintn_v =
185  is_contained_v<T, gtl::vector_unsigned_int_list>;
186 
187 template <typename T>
188 inline constexpr bool is_ugenint_v = is_contained_v<T, gtl::unsigned_int_list>;
189 
190 template <typename T>
191 inline constexpr bool is_intn_v =
192  is_contained_v<T, gtl::vector_signed_int_list>;
193 
194 template <typename T>
195 inline constexpr bool is_genint_v = is_contained_v<T, gtl::signed_int_list>;
196 
197 template <typename T>
198 inline constexpr bool is_ulonglongn_v =
199  is_contained_v<T, gtl::vector_unsigned_longlong_list>;
200 
201 template <typename T>
202 inline constexpr bool is_ugenlonglong_v =
203  is_contained_v<T, gtl::unsigned_longlong_list>;
204 
205 template <typename T>
206 inline constexpr bool is_longlongn_v =
207  is_contained_v<T, gtl::vector_signed_longlong_list>;
208 
209 template <typename T>
210 inline constexpr bool is_genlonglong_v =
211  is_contained_v<T, gtl::signed_longlong_list>;
212 
213 template <typename T>
214 inline constexpr bool is_igenlonginteger_v =
215  is_contained_v<T, gtl::signed_long_integer_list>;
216 
217 template <typename T>
218 inline constexpr bool is_ugenlonginteger_v =
219  is_contained_v<T, gtl::unsigned_long_integer_list>;
220 
221 template <typename T>
222 inline constexpr bool is_geninteger_v = is_contained_v<T, gtl::integer_list>;
223 
224 template <typename T>
225 using is_geninteger = std::bool_constant<is_geninteger_v<T>>;
226 
227 template <typename T>
228 inline constexpr bool is_igeninteger_v =
229  is_contained_v<T, gtl::signed_integer_list>;
230 
231 template <typename T>
232 using is_igeninteger = std::bool_constant<is_igeninteger_v<T>>;
233 
234 template <typename T>
235 inline constexpr bool is_ugeninteger_v =
236  is_contained_v<T, gtl::unsigned_integer_list>;
237 
238 template <typename T>
239 using is_ugeninteger = std::bool_constant<is_ugeninteger_v<T>>;
240 
241 template <typename T>
242 inline constexpr bool is_sgeninteger_v =
243  is_contained_v<T, gtl::scalar_integer_list>;
244 
245 template <typename T>
246 inline constexpr bool is_vgeninteger_v =
247  is_contained_v<T, gtl::vector_integer_list>;
248 
249 template <typename T>
250 inline constexpr bool is_sigeninteger_v =
251  is_contained_v<T, gtl::scalar_signed_integer_list>;
252 
253 template <typename T>
254 inline constexpr bool is_sugeninteger_v =
255  is_contained_v<T, gtl::scalar_unsigned_integer_list>;
256 
257 template <typename T>
258 inline constexpr bool is_vigeninteger_v =
259  is_contained_v<T, gtl::vector_signed_integer_list>;
260 
261 template <typename T>
262 inline constexpr bool is_vugeninteger_v =
263  is_contained_v<T, gtl::vector_unsigned_integer_list>;
264 
265 template <typename T>
266 inline constexpr bool is_genbool_v = is_contained_v<T, gtl::bool_list>;
267 
268 template <typename T>
269 inline constexpr bool is_gentype_v = is_contained_v<T, gtl::basic_list>;
270 
271 template <typename T>
272 inline constexpr bool is_vgentype_v = is_contained_v<T, gtl::vector_basic_list>;
273 
274 template <typename T>
275 inline constexpr bool is_sgentype_v = is_contained_v<T, gtl::scalar_basic_list>;
276 
277 template <typename T>
278 inline constexpr bool is_igeninteger8bit_v =
279  is_gen_based_on_type_sizeof_v<T, 1, is_igeninteger>;
280 
281 template <typename T>
282 inline constexpr bool is_igeninteger16bit_v =
283  is_gen_based_on_type_sizeof_v<T, 2, is_igeninteger>;
284 
285 template <typename T>
286 inline constexpr bool is_igeninteger32bit_v =
287  is_gen_based_on_type_sizeof_v<T, 4, is_igeninteger>;
288 
289 template <typename T>
290 inline constexpr bool is_igeninteger64bit_v =
291  is_gen_based_on_type_sizeof_v<T, 8, is_igeninteger>;
292 
293 template <typename T>
294 inline constexpr bool is_ugeninteger8bit_v =
295  is_gen_based_on_type_sizeof_v<T, 1, is_ugeninteger>;
296 
297 template <typename T>
298 inline constexpr bool is_ugeninteger16bit_v =
299  is_gen_based_on_type_sizeof_v<T, 2, is_ugeninteger>;
300 
301 template <typename T>
302 inline constexpr bool is_ugeninteger32bit_v =
303  is_gen_based_on_type_sizeof_v<T, 4, is_ugeninteger>;
304 
305 template <typename T>
306 inline constexpr bool is_ugeninteger64bit_v =
307  is_gen_based_on_type_sizeof_v<T, 8, is_ugeninteger>;
308 
309 template <typename T>
310 inline constexpr bool is_geninteger8bit_v =
311  is_gen_based_on_type_sizeof_v<T, 1, is_geninteger>;
312 
313 template <typename T>
314 inline constexpr bool is_geninteger16bit_v =
315  is_gen_based_on_type_sizeof_v<T, 2, is_geninteger>;
316 
317 template <typename T>
318 inline constexpr bool is_geninteger32bit_v =
319  is_gen_based_on_type_sizeof_v<T, 4, is_geninteger>;
320 
321 template <typename T>
322 inline constexpr bool is_geninteger64bit_v =
323  is_gen_based_on_type_sizeof_v<T, 8, is_geninteger>;
324 
325 template <typename T>
326 inline constexpr bool is_genintptr_v =
327  is_pointer_v<T> && is_genint_v<remove_pointer_t<T>> &&
328  is_address_space_compliant_v<T, gvl::nonconst_address_space_list>;
329 
330 template <typename T, access::address_space AddressSpace,
331  access::decorated IsDecorated>
332 inline constexpr bool is_genintptr_marray_v =
333  std::is_same_v<T, sycl::marray<marray_element_t<T>, T::size()>> &&
334  is_genint_v<marray_element_t<remove_pointer_t<T>>> &&
335  is_address_space_compliant_v<multi_ptr<T, AddressSpace, IsDecorated>,
337  (IsDecorated == access::decorated::yes ||
338  IsDecorated == access::decorated::no);
339 
340 template <typename T>
341 inline constexpr bool is_genfloatptr_v =
342  is_pointer_v<T> && is_genfloat_v<remove_pointer_t<T>> &&
343  is_address_space_compliant_v<T, gvl::nonconst_address_space_list>;
344 
345 template <typename T, access::address_space AddressSpace,
346  access::decorated IsDecorated>
347 inline constexpr bool is_genfloatptr_marray_v =
348  is_mgenfloat_v<T> &&
349  is_address_space_compliant_v<multi_ptr<T, AddressSpace, IsDecorated>,
351  (IsDecorated == access::decorated::yes ||
352  IsDecorated == access::decorated::no);
353 
354 template <typename T>
355 inline constexpr bool is_genptr_v =
356  is_pointer_v<T> && is_gentype_v<remove_pointer_t<T>> &&
357  is_address_space_compliant_v<T, gvl::nonconst_address_space_list>;
358 
359 template <typename T>
360 inline constexpr bool is_nan_type_v = is_contained_v<T, gtl::nan_list>;
361 
362 // nan_types
363 template <typename T, typename Enable = void> struct nan_types {
364  // Nonsensical case for types implicitly convertible to scalar to avoid
365  // templated overloads which are SFINAE'd out to cause compilation errors.
366  using ret_type = void;
367  using arg_type = int;
368 };
369 
370 template <typename T>
371 struct nan_types<
372  T, std::enable_if_t<is_contained_v<T, gtl::unsigned_short_list>, T>> {
375 };
376 
377 template <typename T>
378 struct nan_types<
379  T, std::enable_if_t<is_contained_v<T, gtl::unsigned_int_list>, T>> {
382 };
383 
384 template <typename T>
385 struct nan_types<
386  T,
387  std::enable_if_t<is_contained_v<T, gtl::unsigned_long_integer_list>, T>> {
389  using arg_type =
391 };
392 
393 template <typename T> using nan_return_t = typename nan_types<T, T>::ret_type;
394 
395 template <typename T>
397 
398 template <typename T>
400 
401 template <typename T>
403 
404 template <typename T>
407 
408 // TryToGetElementType<T>::type is T::element_type or T::value_type if those
409 // exist, otherwise T.
410 template <typename T> class TryToGetElementType {
411  static T check(...);
412  template <typename A> static typename A::element_type check(const A &);
413  template <typename A> static typename A::value_type check(const A &);
414 
415 public:
416  using type = decltype(check(T()));
417  static constexpr bool value = !std::is_same_v<T, type>;
418 };
419 
420 // select_apply_cl_scalar_t selects from T8/T16/T32/T64 basing on
421 // sizeof(IN). expected to handle scalar types.
422 template <typename T, typename T8, typename T16, typename T32, typename T64>
423 using select_apply_cl_scalar_t = std::conditional_t<
424  sizeof(T) == 1, T8,
425  std::conditional_t<sizeof(T) == 2, T16,
426  std::conditional_t<sizeof(T) == 4, T32, T64>>>;
427 
428 // Shortcuts for selecting scalar int/unsigned int/fp type.
429 template <typename T>
433 
434 template <typename T>
438 
439 // Use SFINAE so that std::complex specialization could be implemented in
440 // include/sycl/stl_wrappers/complex that would only be available if STL's
441 // <complex> is included by users. Note that "function template partial
442 // specialization" is not allowed, so we cannot perform that trick on
443 // convertToOpenCLType function directly.
444 template <typename T, typename = void> struct select_cl_scalar_complex_or_T {
445  using type = T;
446 };
447 
448 template <typename T>
451 
452 template <typename T> auto convertToOpenCLType(T &&x) {
453  using no_ref = std::remove_reference_t<T>;
454  if constexpr (is_multi_ptr_v<no_ref>) {
455  return convertToOpenCLType(x.get_decorated());
456  } else if constexpr (std::is_pointer_v<no_ref>) {
457  // TODO: Below ignores volatile, but we didn't have a need for it yet.
459  using converted_elem_type_no_cv = decltype(convertToOpenCLType(
460  std::declval<std::remove_const_t<elem_type>>()));
461  using converted_elem_type =
462  std::conditional_t<std::is_const_v<elem_type>,
463  const converted_elem_type_no_cv,
464  converted_elem_type_no_cv>;
465 #ifdef __SYCL_DEVICE_ONLY__
466  using result_type =
467  typename DecoratedType<converted_elem_type,
468  deduce_AS<no_ref>::value>::type *;
469 #else
470  using result_type = converted_elem_type *;
471 #endif
472  return reinterpret_cast<result_type>(x);
473  } else if constexpr (is_vec_v<no_ref>) {
474  using ElemTy = typename no_ref::element_type;
475  // sycl::half may convert to _Float16, and we would try to instantiate
476  // vec class with _Float16 DataType, which is not expected there. As
477  // such, leave vector<half, N> as-is.
478  using MatchingVec = vec<std::conditional_t<is_half_v<ElemTy>, ElemTy,
479  decltype(convertToOpenCLType(
480  std::declval<ElemTy>()))>,
481  no_ref::size()>;
482 #ifdef __SYCL_DEVICE_ONLY__
483  // TODO: for some mysterious reasons on NonUniformGroups E2E tests fail if
484  // we use the "else" version only. I suspect that's an issues with
485  // non-uniform groups implementation.
486  if constexpr (std::is_same_v<MatchingVec, no_ref>)
487  return static_cast<typename MatchingVec::vector_t>(x);
488  else
489  return static_cast<typename MatchingVec::vector_t>(
490  x.template as<MatchingVec>());
491 #else
492  return x.template as<MatchingVec>();
493 #endif
494  } else if constexpr (is_boolean_v<no_ref>) {
495 #ifdef __SYCL_DEVICE_ONLY__
496  if constexpr (std::is_same_v<Boolean<1>, no_ref>) {
497  // Or should it be "int"?
498  return std::forward<T>(x);
499  } else {
500  return static_cast<typename no_ref::vector_t>(x);
501  }
502 #else
503  return std::forward<T>(x);
504 #endif
505 #if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
506  } else if constexpr (std::is_same_v<no_ref, std::byte>) {
507  return static_cast<uint8_t>(x);
508 #endif
509  } else if constexpr (std::is_integral_v<no_ref>) {
510  using OpenCLType =
511  std::conditional_t<std::is_signed_v<no_ref>,
514  static_assert(sizeof(OpenCLType) == sizeof(T));
515  return static_cast<OpenCLType>(x);
516  } else if constexpr (is_half_v<no_ref>) {
518  static_assert(sizeof(OpenCLType) == sizeof(T));
519  return static_cast<OpenCLType>(x);
520  } else if constexpr (is_bfloat16_v<no_ref>) {
521  return std::forward<T>(x);
522  } else if constexpr (std::is_floating_point_v<no_ref>) {
523  static_assert(std::is_same_v<no_ref, float> ||
524  std::is_same_v<no_ref, double>,
525  "Other FP types are not expected/supported (yet?)");
526  static_assert(std::is_same_v<float, sycl::opencl::cl_float> &&
527  std::is_same_v<double, sycl::opencl::cl_double>);
528  return std::forward<T>(x);
529  } else {
530  using OpenCLType = select_cl_scalar_complex_or_T_t<no_ref>;
531  static_assert(sizeof(OpenCLType) == sizeof(T));
532  return static_cast<OpenCLType>(x);
533  }
534 }
535 
536 template <typename T>
537 using ConvertToOpenCLType_t = decltype(convertToOpenCLType(std::declval<T>()));
538 
539 template <typename To, typename From> auto convertFromOpenCLTypeFor(From &&x) {
540  if constexpr (std::is_same_v<To, bool> &&
541  std::is_same_v<std::remove_reference_t<From>, bool>) {
542  // FIXME: Something seems to be wrong elsewhere...
543  return x;
544  } else {
545  using OpenCLType = decltype(convertToOpenCLType(std::declval<To>()));
546  static_assert(std::is_same_v<std::remove_reference_t<From>, OpenCLType>);
547  static_assert(sizeof(OpenCLType) == sizeof(To));
548  if constexpr (is_vec_v<To> && is_vec_v<From>)
549  return x.template as<To>();
550  else
551  return static_cast<To>(x);
552  }
553 }
554 
555 // Used for all, any and select relational built-in functions
556 template <typename T> inline constexpr T msbMask(T) {
557  using UT = make_unsigned_t<T>;
558  return T(UT(1) << (sizeof(T) * 8 - 1));
559 }
560 
561 template <typename T> inline constexpr bool msbIsSet(const T x) {
562  return (x & msbMask(x));
563 }
564 
565 // SYCL 2020 4.17.9 (Relation functions), e.g. table 178
566 //
567 // genbool isequal (genfloatf x, genfloatf y)
568 // genbool isequal (genfloatd x, genfloatd y)
569 //
570 // TODO: marray support isn't implemented yet.
571 template <typename T>
573  std::conditional_t<is_vgentype_v<T>, make_singed_integer_t<T>, bool>;
574 
575 // Try to get vector element count or 1 otherwise
576 template <typename T> struct GetNumElements {
577  static constexpr int value = 1;
578 };
579 template <typename Type, int NumElements>
580 struct GetNumElements<typename sycl::vec<Type, NumElements>> {
581  static constexpr int value = NumElements;
582 };
583 template <int N> struct GetNumElements<typename sycl::detail::Boolean<N>> {
584  static constexpr int value = N;
585 };
586 
587 // Used for relational comparison built-in functions
588 template <typename T> struct RelationalReturnType {
589 #ifdef __SYCL_DEVICE_ONLY__
590  static constexpr int N = GetNumElements<T>::value;
591  using type = std::conditional_t<N == 1, bool, Boolean<N>>;
592 #else
594 #endif
595 };
596 
597 // Type representing the internal return type of relational builtins.
598 template <typename T>
600 
601 // Used for any and all built-in functions
602 template <typename T> struct RelationalTestForSignBitType {
603 #ifdef __SYCL_DEVICE_ONLY__
604  using return_type = bool;
605  static constexpr int N = GetNumElements<T>::value;
606  using argument_type = std::conditional_t<N == 1, bool, detail::Boolean<N>>;
607 #else
608  using return_type = int;
609  using argument_type = T;
610 #endif
611 };
612 
613 template <typename T>
616 
617 template <typename T>
620 
621 template <typename T, typename Enable = void> struct RelConverter {
623 #ifdef __SYCL_DEVICE_ONLY__
624  using value_t = bool;
625 #else
626  using value_t = R;
627 #endif
628 
629  static R apply(value_t value) { return value; }
630 };
631 
632 template <typename T>
633 struct RelConverter<T,
634  typename std::enable_if_t<TryToGetElementType<T>::value>> {
635  static const int N = T::size();
636 #ifdef __SYCL_DEVICE_ONLY__
637  using bool_t = typename Boolean<N>::vector_t;
638  using ret_t = common_rel_ret_t<T>;
639 #else
642 #endif
643 
644  static ret_t apply(bool_t value) {
645 #ifdef __SYCL_DEVICE_ONLY__
646  typename ret_t::vector_t result(0);
647  for (size_t I = 0; I < N; ++I) {
648  result[I] = value[I];
649  }
650  return result;
651 #else
652  return value;
653 #endif
654  }
655 };
656 
657 template <typename T> static constexpr T max_v() {
658  return (std::numeric_limits<T>::max)();
659 }
660 
661 template <typename T> static constexpr T min_v() {
662  return (std::numeric_limits<T>::min)();
663 }
664 
665 template <typename T> static constexpr T quiet_NaN() {
667 }
668 
669 // is_same_vector_size
670 template <int FirstSize, typename... Args> class is_same_vector_size_impl;
671 
672 template <int FirstSize, typename T, typename... Args>
673 class is_same_vector_size_impl<FirstSize, T, Args...> {
674  using CurrentT = detail::remove_pointer_t<T>;
675  static constexpr int Size = vector_size<CurrentT>::value;
676  static constexpr bool IsSizeEqual = (Size == FirstSize);
677 
678 public:
679  static constexpr bool value =
680  IsSizeEqual ? is_same_vector_size_impl<FirstSize, Args...>::value : false;
681 };
682 
683 template <int FirstSize>
684 class is_same_vector_size_impl<FirstSize> : public std::true_type {};
685 
686 template <typename T, typename... Args> class is_same_vector_size {
687  using CurrentT = remove_pointer_t<T>;
688  static constexpr int Size = vector_size<CurrentT>::value;
689 
690 public:
691  static constexpr bool value = is_same_vector_size_impl<Size, Args...>::value;
692 };
693 
694 // check_vector_size
695 template <typename... Args> inline void check_vector_size() {
697  "The built-in function arguments must [point to|have] types "
698  "with the same number of elements.");
699 }
700 
701 } // namespace detail
702 } // namespace _V1
703 } // namespace sycl
defined(__INTEL_PREVIEW_BREAKING_CHANGES)
Definition: types.hpp:346
constexpr bool is_vgengeo_v
constexpr bool is_sgeninteger_v
constexpr bool is_halfn_v
constexpr bool is_ugeninteger8bit_v
constexpr bool is_svgenfloatd_v
constexpr bool is_half_v
constexpr bool is_gentype_v
constexpr bool is_scharn_v
std::bool_constant< is_ugeninteger_v< T > > is_ugeninteger
constexpr bool is_longlongn_v
typename change_base_type< T, B >::type change_base_type_t
constexpr bool is_ugeninteger16bit_v
constexpr bool is_ugeninteger64bit_v
constexpr bool is_sugeninteger_v
constexpr bool is_genfloatf_v
constexpr bool is_shortn_v
typename RelationalTestForSignBitType< T >::argument_type rel_sign_bit_test_arg_t
constexpr bool is_ugeninteger_v
make_type_t< T, gtl::scalar_unsigned_integer_list > make_unsinged_integer_t
constexpr bool is_mgenfloat_v
constexpr bool is_igeninteger8bit_v
constexpr bool is_gengeofloat_v
constexpr bool is_genptr_v
static constexpr T min_v()
constexpr bool is_vugeninteger_v
typename remove_pointer< T >::type remove_pointer_t
constexpr bool is_sgengeo_v
constexpr bool is_doublen_v
std::conditional_t< sizeof(T)==1, T8, std::conditional_t< sizeof(T)==2, T16, std::conditional_t< sizeof(T)==4, T32, T64 > >> select_apply_cl_scalar_t
typename make_unsigned< T >::type make_unsigned_t
constexpr bool is_geninteger64bit_v
constexpr bool is_nan_type_v
constexpr bool is_genfloat_v
constexpr bool is_vgengeofloat_v
constexpr bool is_igeninteger_v
make_type_t< T, gtl::scalar_signed_integer_list > make_singed_integer_t
constexpr bool is_ugenlonglong_v
constexpr bool is_ugenint_v
static constexpr T quiet_NaN()
constexpr bool is_bfloat16_v
auto convertFromOpenCLTypeFor(From &&x)
select_apply_cl_scalar_t< T, sycl::opencl::cl_uchar, sycl::opencl::cl_ushort, sycl::opencl::cl_uint, sycl::opencl::cl_ulong > select_cl_scalar_integral_unsigned_t
constexpr bool is_genfloatptr_v
constexpr bool is_svgenfloath_v
constexpr bool is_igenlonginteger_v
constexpr bool is_sgenfloat_v
constexpr bool is_geninteger16bit_v
constexpr bool is_vgeninteger_v
constexpr bool is_genlonglong_v
constexpr bool is_genfloath_v
constexpr bool is_sgentype_v
constexpr bool is_vgentype_v
constexpr bool is_ucharn_v
constexpr bool is_gencrossmarray_v
constexpr bool is_ugenlonginteger_v
constexpr bool is_ugeninteger32bit_v
constexpr bool is_igeninteger32bit_v
constexpr bool is_gencrosshalf_v
constexpr bool is_genshort_v
static constexpr T max_v()
constexpr bool is_igeninteger64bit_v
constexpr bool is_gengeodouble_v
constexpr bool is_genchar_v
constexpr bool is_gencross_v
constexpr bool is_svgenfloatf_v
constexpr bool is_vgenfloat_v
constexpr bool is_ulonglongn_v
std::bool_constant< is_geninteger_v< T > > is_geninteger
constexpr bool is_geninteger_v
constexpr bool is_igenchar_v
typename nan_types< T, T >::arg_type nan_argument_base_t
typename nan_types< T, T >::ret_type nan_return_t
constexpr bool msbIsSet(const T x)
constexpr bool is_geninteger8bit_v
decltype(convertToOpenCLType(std::declval< T >())) ConvertToOpenCLType_t
constexpr bool is_floatn_v
constexpr bool is_gencrossfloat_v
constexpr bool is_genintptr_v
constexpr bool is_genintptr_marray_v
constexpr bool is_vgengeohalf_v
constexpr bool is_svgenfloat_v
find_type_t< TypeList, is_type_size_equal, T > find_same_size_type_t
Definition: type_list.hpp:91
typename RelationalTestForSignBitType< T >::return_type rel_sign_bit_test_ret_t
constexpr bool is_vigeninteger_v
constexpr bool is_half_or_bf16_v
constexpr bool is_gengeomarray_v
std::bool_constant< is_igeninteger_v< T > > is_igeninteger
make_type_t< T, gtl::scalar_floating_list > make_floating_point_t
constexpr bool is_genfloatptr_marray_v
typename select_cl_scalar_complex_or_T< T >::type select_cl_scalar_complex_or_T_t
typename RelationalReturnType< T >::type internal_rel_ret_t
constexpr bool is_vgengeodouble_v
constexpr bool is_gengeohalf_v
constexpr bool is_gencrossdouble_v
typename make_type_impl< T, TL >::type make_type_t
select_apply_cl_scalar_t< T, sycl::opencl::cl_char, sycl::opencl::cl_short, sycl::opencl::cl_int, sycl::opencl::cl_long > select_cl_scalar_integral_signed_t
constexpr bool is_genint_v
constexpr bool is_ugenshort_v
constexpr bool is_gengeomarrayfloat_v
constexpr bool is_ushortn_v
constexpr bool is_igeninteger16bit_v
constexpr bool is_genfloatd_v
constexpr bool is_geninteger32bit_v
constexpr bool is_sigeninteger_v
std::conditional_t< is_vgentype_v< T >, make_singed_integer_t< T >, bool > common_rel_ret_t
constexpr bool is_ugenchar_v
constexpr bool is_genbool_v
std::uint64_t cl_ulong
Definition: aliases.hpp:137
std::int32_t cl_int
Definition: aliases.hpp:134
std::int8_t cl_char
Definition: aliases.hpp:130
std::uint8_t cl_uchar
Definition: aliases.hpp:131
std::uint16_t cl_ushort
Definition: aliases.hpp:133
std::int16_t cl_short
Definition: aliases.hpp:132
std::uint32_t cl_uint
Definition: aliases.hpp:135
std::int64_t cl_long
Definition: aliases.hpp:136
std::conditional_t< std::is_same_v< ElementType, half >, sycl::detail::half_impl::BIsRepresentationT, ElementType > element_type
Definition: multi_ptr.hpp:752
typename remove_decoration< T >::type remove_decoration_t
Definition: access.hpp:325
Definition: access.hpp:18