DPC++ Runtime
Runtime libraries for oneAPI DPC++
info_desc_helpers.hpp
Go to the documentation of this file.
1 //==---- info_desc_helpers.hpp - SYCL information descriptor helpers -------==//
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/aspects.hpp>
12 #include <sycl/detail/pi.hpp>
13 #include <sycl/info/info_desc.hpp>
14 
15 namespace sycl {
17 namespace detail {
18 template <typename T> struct PiInfoCode;
19 template <typename T> struct is_platform_info_desc : std::false_type {};
20 template <typename T> struct is_context_info_desc : std::false_type {};
21 template <typename T> struct is_device_info_desc : std::false_type {};
22 template <typename T> struct is_queue_info_desc : std::false_type {};
23 template <typename T> struct is_kernel_info_desc : std::false_type {};
24 template <typename T>
25 struct is_kernel_device_specific_info_desc : std::false_type {};
26 template <typename T> struct is_event_info_desc : std::false_type {};
27 template <typename T> struct is_event_profiling_info_desc : std::false_type {};
28 // Normally we would just use std::enable_if to limit valid get_info template
29 // arguments. However, there is a mangling mismatch of
30 // "std::enable_if<is*_desc::value>::type" between gcc clang (it appears that
31 // gcc lacks a E terminator for unresolved-qualifier-level sequence). As a
32 // workaround, we use return_type alias from is_*info_desc that doesn't run into
33 // the same problem.
34 // TODO remove once this gcc/clang discrepancy is resolved
35 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
36  template <> struct PiInfoCode<info::DescType::Desc> { \
37  static constexpr pi_##DescType##_info value = PiCode; \
38  }; \
39  template <> \
40  struct is_##DescType##_info_desc<info::DescType::Desc> : std::true_type { \
41  using return_type = info::DescType::Desc::return_type; \
42  };
43 #include <sycl/info/context_traits.def>
44 #include <sycl/info/event_traits.def>
45 #include <sycl/info/kernel_traits.def>
46 #include <sycl/info/platform_traits.def>
47 #include <sycl/info/queue_traits.def>
48 #undef __SYCL_PARAM_TRAITS_SPEC
49 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
50  template <> struct PiInfoCode<info::DescType::Desc> { \
51  static constexpr pi_profiling_info value = PiCode; \
52  }; \
53  template <> \
54  struct is_##DescType##_info_desc<info::DescType::Desc> : std::true_type { \
55  using return_type = info::DescType::Desc::return_type; \
56  };
57 #include <sycl/info/event_profiling_traits.def>
58 #undef __SYCL_PARAM_TRAITS_SPEC
59 
60 template <typename Param> struct IsSubGroupInfo : std::false_type {};
61 template <>
62 struct IsSubGroupInfo<info::kernel_device_specific::max_num_sub_groups>
63  : std::true_type {};
64 template <>
65 struct IsSubGroupInfo<info::kernel_device_specific::compile_num_sub_groups>
66  : std::true_type {};
67 template <>
68 struct IsSubGroupInfo<info::kernel_device_specific::max_sub_group_size>
69  : std::true_type {};
70 template <>
71 struct IsSubGroupInfo<info::kernel_device_specific::compile_sub_group_size>
72  : std::true_type {};
73 
74 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
75  template <> struct PiInfoCode<info::DescType::Desc> { \
76  static constexpr \
77  typename std::conditional<IsSubGroupInfo<info::DescType::Desc>::value, \
78  pi_kernel_sub_group_info, \
79  pi_kernel_group_info>::type value = PiCode; \
80  }; \
81  template <> \
82  struct is_##DescType##_info_desc<info::DescType::Desc> : std::true_type { \
83  using return_type = info::DescType::Desc::return_type; \
84  };
85 #include <sycl/info/kernel_device_specific_traits.def>
86 #undef __SYCL_PARAM_TRAITS_SPEC
87 // Need a static_cast here since piDeviceGetInfo can also accept
88 // pi_usm_capability_query values.
89 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
90  template <> struct PiInfoCode<info::DescType::Desc> { \
91  static constexpr pi_device_info value = \
92  static_cast<pi_device_info>(PiCode); \
93  }; \
94  template <> \
95  struct is_##DescType##_info_desc<info::DescType::Desc> : std::true_type { \
96  using return_type = info::DescType::Desc::return_type; \
97  };
98 #define __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED(DescType, Desc, ReturnT, PiCode) \
99  __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode)
100 
101 #include <sycl/info/device_traits.def>
102 
103 #undef __SYCL_PARAM_TRAITS_SPEC
104 #undef __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED
105 
106 #define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, PiCode) \
107  template <> struct PiInfoCode<Namespace::info::DescType::Desc> { \
108  static constexpr pi_device_info value = \
109  static_cast<pi_device_info>(PiCode); \
110  }; \
111  template <> \
112  struct is_##DescType##_info_desc<Namespace::info::DescType::Desc> \
113  : std::true_type { \
114  using return_type = Namespace::info::DescType::Desc::return_type; \
115  };
116 #include <sycl/info/ext_codeplay_device_traits.def>
117 #include <sycl/info/ext_intel_device_traits.def>
118 #include <sycl/info/ext_oneapi_device_traits.def>
119 #undef __SYCL_PARAM_TRAITS_SPEC
120 
121 } // namespace detail
122 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
123 } // namespace sycl
sycl::_V1::detail::IsSubGroupInfo
Definition: info_desc_helpers.hpp:60
aspects.hpp
sycl::_V1::detail::is_device_info_desc
Definition: info_desc_helpers.hpp:21
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::detail::PiInfoCode
Definition: info_desc_helpers.hpp:18
pi.hpp
sycl::_V1::detail::is_kernel_device_specific_info_desc
Definition: info_desc_helpers.hpp:25
sycl::_V1::detail::is_context_info_desc
Definition: info_desc_helpers.hpp:20
sycl::_V1::detail::is_kernel_info_desc
Definition: info_desc_helpers.hpp:23
sycl::_V1::detail::is_platform_info_desc
Definition: info_desc_helpers.hpp:19
info_desc.hpp
sycl::_V1::detail::is_event_info_desc
Definition: info_desc_helpers.hpp:26
sycl::_V1::detail::is_event_profiling_info_desc
Definition: info_desc_helpers.hpp:27
sycl::_V1::detail::is_queue_info_desc
Definition: info_desc_helpers.hpp:22