Skip to content

Commit 53fced1

Browse files
[SYCL] UR enum values are already typed, avoid explicit casts (#18287)
Apparently, `get_info<info::device::opencl_c_version>` was returning garbage because its `UrCode` is `__SYCL_TRAIT_HANDLED_IN_RT` while no special handling was in fact done for it. Since it's deprecated anyway I'm not trying to fix that but just throw an exception instead. Before this change: ``` $ llvm-lit -a Basic/info.cpp 2>&1 | grep 'OpenCL C version:' # | OpenCL C version: ^C # | OpenCL C version: ^D # | OpenCL C version: ^E # | OpenCL C version: ^C $ sycl-ls [level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Data Center GPU Max 1550 12.60.7 [1.6.31294.120000] [level_zero:gpu][level_zero:1] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Data Center GPU Max 1550 12.60.7 [1.6.31294.120000] [opencl:fpga][opencl:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device OpenCL 1.2 [2024.18.10.0.08_160000] [opencl:cpu][opencl:1] Intel(R) OpenCL, Genuine Intel(R) CPU 0000%@ OpenCL 3.0 (Build 0) [2024.18.10.0.08_160000] [opencl:gpu][opencl:2] Intel(R) OpenCL Graphics, Intel(R) Data Center GPU Max 1550 OpenCL 3.0 NEO [24.39.31294.12] [opencl:gpu][opencl:3] Intel(R) OpenCL Graphics, Intel(R) Data Center GPU Max 1550 OpenCL 3.0 NEO [24.39.31294.12] ```
1 parent 874ee86 commit 53fced1

File tree

3 files changed

+21
-44
lines changed

3 files changed

+21
-44
lines changed

sycl/source/detail/device_info.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,15 @@ struct get_device_info_impl<
10571057
}
10581058
};
10591059

1060+
template <>
1061+
struct get_device_info_impl<std::string, info::device::opencl_c_version> {
1062+
static std::string get(const device_impl &) {
1063+
throw sycl::exception(
1064+
errc::feature_not_supported,
1065+
"Deprecated interface that hasn't been working for some time already");
1066+
}
1067+
};
1068+
10601069
template <>
10611070
struct get_device_info_impl<
10621071
size_t, ext::oneapi::experimental::info::device::max_global_work_groups> {

sycl/source/detail/ur_info_code.hpp

+6-42
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,30 @@ template <typename T> struct UrInfoCode;
1919

2020
#define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, UrCode) \
2121
template <> struct UrInfoCode<info::DescType::Desc> { \
22-
static constexpr ur_##DescType##_info_t value = \
23-
static_cast<ur_##DescType##_info_t>(UrCode); \
22+
static constexpr auto value = UrCode; \
2423
};
2524
#include <sycl/info/context_traits.def>
25+
#include <sycl/info/event_profiling_traits.def>
2626
#include <sycl/info/event_traits.def>
27+
#include <sycl/info/kernel_device_specific_traits.def>
2728
#include <sycl/info/kernel_traits.def>
2829
#include <sycl/info/platform_traits.def>
2930
#include <sycl/info/queue_traits.def>
30-
#undef __SYCL_PARAM_TRAITS_SPEC
31-
32-
#define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, UrCode) \
33-
template <> struct UrInfoCode<info::DescType::Desc> { \
34-
static constexpr ur_profiling_info_t value = UrCode; \
35-
};
36-
#include <sycl/info/event_profiling_traits.def>
37-
#undef __SYCL_PARAM_TRAITS_SPEC
38-
39-
#define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, UrCode) \
40-
template <> struct UrInfoCode<info::DescType::Desc> { \
41-
static constexpr typename std::conditional< \
42-
IsSubGroupInfo<info::DescType::Desc>::value, \
43-
ur_kernel_sub_group_info_t, \
44-
std::conditional<IsKernelInfo<info::DescType::Desc>::value, \
45-
ur_kernel_info_t, \
46-
ur_kernel_group_info_t>::type>::type value = UrCode; \
47-
};
48-
#include <sycl/info/kernel_device_specific_traits.def>
49-
#undef __SYCL_PARAM_TRAITS_SPEC
50-
51-
#define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, UrCode) \
52-
template <> struct UrInfoCode<info::DescType::Desc> { \
53-
static constexpr ur_device_info_t value = \
54-
static_cast<ur_device_info_t>(UrCode); \
55-
};
5631
#define __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED(DescType, Desc, ReturnT, PiCode) \
5732
__SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode)
58-
5933
#include <sycl/info/device_traits.def>
60-
61-
#undef __SYCL_PARAM_TRAITS_SPEC
6234
#undef __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED
35+
#undef __SYCL_PARAM_TRAITS_SPEC
6336

6437
#define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, UrCode) \
6538
template <> struct UrInfoCode<Namespace::info::DescType::Desc> { \
66-
static constexpr ur_device_info_t value = \
67-
static_cast<ur_device_info_t>(UrCode); \
39+
static constexpr auto value = UrCode; \
6840
};
6941

7042
#include <sycl/info/ext_codeplay_device_traits.def>
7143
#include <sycl/info/ext_intel_device_traits.def>
72-
#include <sycl/info/ext_oneapi_device_traits.def>
73-
#undef __SYCL_PARAM_TRAITS_SPEC
74-
75-
#define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, UrCode) \
76-
template <> struct UrInfoCode<Namespace::info::DescType::Desc> { \
77-
static constexpr ur_kernel_info_t value = \
78-
static_cast<ur_kernel_info_t>(UrCode); \
79-
};
80-
8144
#include <sycl/info/ext_intel_kernel_info_traits.def>
45+
#include <sycl/info/ext_oneapi_device_traits.def>
8246
#undef __SYCL_PARAM_TRAITS_SPEC
8347

8448
} // namespace detail

sycl/test-e2e/Basic/info.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,12 @@ int main() {
342342
print_info<info::device::version, std::string>(dev, "Version");
343343
print_info<info::device::backend_version, std::string>(dev,
344344
"Backend version");
345-
print_info<info::device::opencl_c_version, std::string>(dev,
346-
"OpenCL C version");
345+
try {
346+
print_info<info::device::opencl_c_version, std::string>(dev,
347+
"OpenCL C version");
348+
} catch (const sycl::exception &e) {
349+
assert(e.code() == sycl::errc::feature_not_supported);
350+
}
347351
print_info<info::device::extensions, std::vector<std::string>>(dev,
348352
"Extensions");
349353
print_info<info::device::printf_buffer_size, size_t>(dev,

0 commit comments

Comments
 (0)