DPC++ Runtime
Runtime libraries for oneAPI DPC++
device_aspect_traits.hpp
Go to the documentation of this file.
1 //==------------------- device_aspect_traits.hpp - SYCL device -------------==//
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 "device_aspect_macros.hpp" // for __SYCL_ALL_DEVICES_HAVE_* macro
12 #include <sycl/aspects.hpp> // for aspect
13 
14 #include <type_traits> // for bool_constant
15 
16 // This macro creates an alias from an aspect to another. To avoid
17 // redeclarations, we need to define it empty for this file, otherwise we would
18 // have multiple declarations of `any_device_has` and `all_devices_have`, one
19 // for the original declaration of the aspect, and a subsequent one when finding
20 // the alias.
21 #define __SYCL_ASPECT_DEPRECATED_ALIAS(ASPECT, ID, MESSAGE)
22 
23 namespace sycl {
24 template <aspect Aspect> struct all_devices_have;
25 
26 // Macro to define `all_devices_have` traits for entries in aspects.def and
27 // aspects_deprecated.def.
28 #define __SYCL_ASPECT(ASPECT, ASPECT_VAL) \
29  template <> \
30  struct all_devices_have<aspect::ASPECT> \
31  : std::bool_constant<__SYCL_ALL_DEVICES_HAVE_##ASPECT##__> {};
32 
33 #include <sycl/info/aspects.def>
34 
35 #undef __SYCL_ASPECT
36 
37 #define __SYCL_ASPECT_DEPRECATED(ASPECT, ASPECT_VAL, MSG) \
38  template <> \
39  struct all_devices_have<aspect::ASPECT> \
40  : std::bool_constant<__SYCL_ALL_DEVICES_HAVE_##ASPECT##__> {};
41 #include <sycl/info/aspects_deprecated.def>
42 
43 #undef __SYCL_ASPECT_DEPRECATED
44 
45 #ifdef __SYCL_ANY_DEVICE_HAS_ANY_ASPECT__
46 // Special case where `any_device_has` is trivially true.
47 template <aspect Aspect> struct any_device_has : std::true_type {};
48 #else
49 template <aspect Aspect> struct any_device_has;
50 
51 // Macro to define `any_device_has` traits for entries in aspects.def and
52 // aspects_deprecated.def.
53 #define __SYCL_ASPECT(ASPECT, ASPECT_VAL) \
54  template <> \
55  struct any_device_has<aspect::ASPECT> \
56  : std::bool_constant<__SYCL_ANY_DEVICE_HAS_##ASPECT##__> {};
57 
58 #include <sycl/info/aspects.def>
59 
60 #undef __SYCL_ASPECT
61 
62 #define __SYCL_ASPECT_DEPRECATED(ASPECT, ASPECT_VAL, MSG) \
63  template <> \
64  struct any_device_has<aspect::ASPECT> \
65  : std::bool_constant<__SYCL_ANY_DEVICE_HAS_##ASPECT##__> {};
66 #include <sycl/info/aspects_deprecated.def>
67 
68 #undef __SYCL_ASPECT_DEPRECATED
69 #endif // __SYCL_ANY_DEVICE_HAS_ANY_ASPECT__
70 
71 template <aspect Aspect>
73 template <aspect Aspect>
75 } // namespace sycl
76 
77 #undef __SYCL_ASPECT_DEPRECATED_ALIAS
Definition: access.hpp:18
constexpr bool all_devices_have_v
constexpr bool any_device_has_v