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