Skip to content

Commit b3cbda5

Browse files
[SYCL][ABI-break] Switch to struct information descriptors (#6467)
This patch changes information descriptors from enum class elements to structs in accordance with SYCL 2020 spec. Additionally, it removes some deprecated information queries that were dropped in either SYCL 2020 or the corresponding extension and deprecates those listed as such in SYCL 2020 spec.
1 parent 221f9c8 commit b3cbda5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1259
-1430
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include(SYCLUtils)
2828
set(SYCL_MAJOR_VERSION 5)
2929
set(SYCL_MINOR_VERSION 7)
3030
set(SYCL_PATCH_VERSION 0)
31-
set(SYCL_DEV_ABI_VERSION 3)
31+
set(SYCL_DEV_ABI_VERSION 4)
3232
if (SYCL_ADD_DEV_VERSION_POSTFIX)
3333
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
3434
endif()

sycl/include/sycl/accessor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ class image_accessor
444444
static_assert(Dimensions > 0 && Dimensions <= 3,
445445
"Dimensions can be 1/2/3 for image accessor.");
446446

447-
template <info::device param>
447+
template <typename Param>
448448
void checkDeviceFeatureSupported(const device &Device) {
449-
if (!Device.get_info<param>())
449+
if (!Device.get_info<Param>())
450450
throw feature_not_supported("Images are not supported by this device.",
451451
PI_ERROR_INVALID_OPERATION);
452452
}

sycl/include/sycl/context.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <sycl/detail/cl.h>
1313
#include <sycl/detail/common.hpp>
1414
#include <sycl/detail/export.hpp>
15+
#include <sycl/detail/info_desc_helpers.hpp>
1516
#include <sycl/detail/stl_type_traits.hpp>
1617
#include <sycl/exception_list.hpp>
1718
#include <sycl/info/info_desc.hpp>
@@ -159,9 +160,8 @@ class __SYCL_EXPORT context {
159160
/// Queries this SYCL context for information.
160161
///
161162
/// The return type depends on information being queried.
162-
template <info::context param>
163-
typename info::param_traits<info::context, param>::return_type
164-
get_info() const;
163+
template <typename Param>
164+
typename detail::is_context_info_desc<Param>::return_type get_info() const;
165165

166166
context(const context &rhs) = default;
167167

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

sycl/include/sycl/device.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <sycl/detail/cl.h>
1414
#include <sycl/detail/common.hpp>
1515
#include <sycl/detail/export.hpp>
16+
#include <sycl/detail/info_desc_helpers.hpp>
1617
#include <sycl/info/info_desc.hpp>
1718
#include <sycl/platform.hpp>
1819
#include <sycl/stl.hpp>
@@ -160,9 +161,8 @@ class __SYCL_EXPORT device {
160161
/// type associated with the param parameter.
161162
///
162163
/// \return device info of type described in Table 4.20.
163-
template <info::device param>
164-
typename info::param_traits<info::device, param>::return_type
165-
get_info() const;
164+
template <typename Param>
165+
typename detail::is_device_info_desc<Param>::return_type get_info() const;
166166

167167
/// Check SYCL extension support by device
168168
///

sycl/include/sycl/event.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <sycl/detail/cl.h>
1313
#include <sycl/detail/common.hpp>
1414
#include <sycl/detail/export.hpp>
15+
#include <sycl/detail/info_desc_helpers.hpp>
1516
#include <sycl/info/info_desc.hpp>
1617
#include <sycl/stl.hpp>
1718

@@ -110,8 +111,8 @@ class __SYCL_EXPORT event {
110111
/// Queries this SYCL event for information.
111112
///
112113
/// \return depends on the information being requested.
113-
template <info::event param>
114-
typename info::param_traits<info::event, param>::return_type get_info() const;
114+
template <typename Param>
115+
typename detail::is_event_info_desc<Param>::return_type get_info() const;
115116

116117
/// Queries this SYCL event for profiling information.
117118
///
@@ -124,8 +125,8 @@ class __SYCL_EXPORT event {
124125
/// exception is thrown.
125126
///
126127
/// \return depends on template parameter.
127-
template <info::event_profiling param>
128-
typename info::param_traits<info::event_profiling, param>::return_type
128+
template <typename Param>
129+
typename detail::is_event_profiling_info_desc<Param>::return_type
129130
get_profiling_info() const;
130131

131132
/// Returns the backend associated with this platform.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
__SYCL_PARAM_TRAITS_SPEC(context, reference_count, uint32_t)
2-
__SYCL_PARAM_TRAITS_SPEC(context, platform, sycl::platform)
3-
__SYCL_PARAM_TRAITS_SPEC(context, devices, std::vector<sycl::device>)
4-
__SYCL_PARAM_TRAITS_SPEC(context, atomic_memory_order_capabilities, std::vector<sycl::memory_order>)
5-
__SYCL_PARAM_TRAITS_SPEC(context, atomic_memory_scope_capabilities, std::vector<sycl::memory_scope>)
1+
__SYCL_PARAM_TRAITS_SPEC(context, reference_count, uint32_t, PI_CONTEXT_INFO_REFERENCE_COUNT)
2+
__SYCL_PARAM_TRAITS_SPEC(context, platform, sycl::platform, PI_CONTEXT_INFO_PLATFORM)
3+
__SYCL_PARAM_TRAITS_SPEC(context, devices, std::vector<sycl::device>, PI_CONTEXT_INFO_DEVICES)
4+
__SYCL_PARAM_TRAITS_SPEC(context, atomic_memory_order_capabilities, std::vector<sycl::memory_order>, PI_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES)
5+
__SYCL_PARAM_TRAITS_SPEC(context, atomic_memory_scope_capabilities, std::vector<sycl::memory_scope>, PI_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES)

0 commit comments

Comments
 (0)