Skip to content

Commit 3607e0e

Browse files
[SYCL] Mark deprecated aspects for removal (#22534)
fixes: #22476 --------- Co-authored-by: Nikita Kornev <nikita.kornev@intel.com>
1 parent 183168e commit 3607e0e

8 files changed

Lines changed: 61 additions & 12 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
2+
// TODO: Remove this file once preview-breaking changes become the default ABI.
13
__SYCL_ASPECT_DEPRECATED(host, 0, "removed in SYCL 2020, 'host' device has been removed")
24
__SYCL_ASPECT_DEPRECATED(int64_base_atomics, 7, "use atomic64 instead")
35
__SYCL_ASPECT_DEPRECATED(int64_extended_atomics, 8, "use atomic64 instead")
46
__SYCL_ASPECT_DEPRECATED(usm_restricted_shared_allocations, 16, "deprecated in SYCL 2020")
7+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

sycl/source/detail/device_impl.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,12 @@ class device_impl {
12301230
return MCache.get<AspectDesc<Aspect>>();
12311231
}
12321232
#define CASE(ASPECT) else if constexpr (Aspect == aspect::ASPECT)
1233+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
12331234
CASE(host) {
12341235
// Deprecated
12351236
return false;
12361237
}
1238+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
12371239
CASE(cpu) { return is_cpu(); }
12381240
CASE(gpu) { return is_gpu(); }
12391241
CASE(accelerator) { return is_accelerator(); }
@@ -1242,12 +1244,14 @@ class device_impl {
12421244
CASE(host_debuggable) { return false; }
12431245
CASE(fp16) { return has_extension("cl_khr_fp16"); }
12441246
CASE(fp64) { return has_extension("cl_khr_fp64"); }
1247+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
12451248
CASE(int64_base_atomics) {
12461249
return has_extension("cl_khr_int64_base_atomics");
12471250
}
12481251
CASE(int64_extended_atomics) {
12491252
return has_extension("cl_khr_int64_extended_atomics");
12501253
}
1254+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
12511255
CASE(atomic64) { return get_info_impl<UR_DEVICE_INFO_ATOMIC_64>(); }
12521256
CASE(image) { return get_info<info::device::image_support>(); }
12531257
CASE(online_compiler) {
@@ -1277,9 +1281,11 @@ class device_impl {
12771281
return (get_info_impl<UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT>() &
12781282
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS);
12791283
}
1284+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
12801285
CASE(usm_restricted_shared_allocations) {
12811286
return get_info<info::device::usm_restricted_shared_allocations>();
12821287
}
1288+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
12831289
CASE(usm_system_allocations) {
12841290
return get_info<info::device::usm_system_allocations>();
12851291
}
@@ -2367,9 +2373,14 @@ class device_impl {
23672373
EagerCache<InfoInitializer>, //
23682374
CallOnceCache<InfoInitializer,
23692375
ext::oneapi::experimental::info::device::architecture>, //
2376+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
23702377
AspectCache<EagerCache, aspect::fp16, aspect::fp64,
23712378
aspect::int64_base_atomics, aspect::int64_extended_atomics,
23722379
aspect::ext_oneapi_atomic16>,
2380+
#else
2381+
AspectCache<EagerCache, aspect::fp16, aspect::fp64,
2382+
aspect::ext_oneapi_atomic16>,
2383+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
23732384
AspectCache<
23742385
CallOnceCache,
23752386
// Slow, >100ns (for baseline cached ~30..40ns):

sycl/source/device_aspect_macros_generator.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
1+
# !__INTEL_PREVIEW_BREAKING_CHANGES
12
# This script is intended to generate "device_aspect_macros.h" from "aspects.def" and "aspects_deprecated.def".
3+
# else
4+
# This script is intended to generate "device_aspect_macros.h" from "aspects.def".
5+
# end !__INTEL_PREVIEW_BREAKING_CHANGES
26

37
import os
48
import sys
59

10+
11+
# !__INTEL_PREVIEW_BREAKING_CHANGES
612
def process_aspects(file_path, is_deprecated=False):
13+
# else
14+
# def process_aspects(file_path):
15+
# end !__INTEL_PREVIEW_BREAKING_CHANGES
716
with open(file_path, "r") as file:
817
content = file.read()
918
lines = content.strip().splitlines()
1019

1120
output = ""
1221
for line in lines:
22+
# !__INTEL_PREVIEW_BREAKING_CHANGES
23+
stripped_line = line.strip()
24+
if (
25+
not stripped_line
26+
or stripped_line.startswith("#")
27+
or stripped_line.startswith("//")
28+
):
29+
continue
1330
if is_deprecated:
14-
aspect_macro = (
15-
line.strip().replace("__SYCL_ASPECT_DEPRECATED(", "").replace(")", "")
16-
)
31+
aspect_macro = stripped_line.replace(
32+
"__SYCL_ASPECT_DEPRECATED(", ""
33+
).replace(")", "")
1734
aspect_name, aspect_number, _ = aspect_macro.split(
1835
", ", 2
1936
) # ignore the third parameter (message)
2037
output += f"// __SYCL_ASPECT_DEPRECATED({aspect_name}, {aspect_number})\n"
2138
else:
22-
aspect_macro = line.strip().replace("__SYCL_ASPECT(", "").replace(")", "")
39+
aspect_macro = stripped_line.replace("__SYCL_ASPECT(", "").replace(")", "")
2340
aspect_name, aspect_number = aspect_macro.split(", ")
2441
output += f"// __SYCL_ASPECT({aspect_name}, {aspect_number})\n"
42+
# else !__INTEL_PREVIEW_BREAKING_CHANGES
43+
# aspect_macro = line.strip().replace("__SYCL_ASPECT(", "").replace(")", "")
44+
# aspect_name, aspect_number = aspect_macro.split(", ")
45+
# output += f"// __SYCL_ASPECT({aspect_name}, {aspect_number})\n"
46+
# end !__INTEL_PREVIEW_BREAKING_CHANGES
2547

2648
output += f"#ifndef __SYCL_ALL_DEVICES_HAVE_{aspect_name}__\n"
2749
output += f"#define __SYCL_ALL_DEVICES_HAVE_{aspect_name}__ 0\n"
@@ -32,6 +54,7 @@ def process_aspects(file_path, is_deprecated=False):
3254

3355
return output
3456

57+
3558
header_output = """//==------------------- device_aspect_macros.hpp - SYCL device -------------==//
3659
//
3760
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -49,9 +72,15 @@ def process_aspects(file_path, is_deprecated=False):
4972
"""
5073

5174
include_sycl_dir = sys.argv[1]
52-
header_output += process_aspects(os.path.join(include_sycl_dir, "info/aspects_deprecated.def"), is_deprecated=True)
75+
# !__INTEL_PREVIEW_BREAKING_CHANGES
76+
header_output += process_aspects(
77+
os.path.join(include_sycl_dir, "info/aspects_deprecated.def"), is_deprecated=True
78+
)
79+
# end !__INTEL_PREVIEW_BREAKING_CHANGES
5380
header_output += process_aspects(os.path.join(include_sycl_dir, "info/aspects.def"))
5481

5582
build_include_sycl_dir = sys.argv[2]
56-
with open(os.path.join(build_include_sycl_dir, "device_aspect_macros.hpp"), "w") as header_file:
83+
with open(
84+
os.path.join(build_include_sycl_dir, "device_aspect_macros.hpp"), "w"
85+
) as header_file:
5786
header_file.write(header_output)

sycl/test/basic_tests/device_config_file_aspects.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int main() {
2424

2525
#undef __SYCL_ASPECT
2626

27+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
2728
auto testDeprecatedAspects =
2829
DeviceConfigFile::TargetTable.find("__TestDeprecatedAspectList");
2930
assert(testDeprecatedAspects != DeviceConfigFile::TargetTable.end());
@@ -36,6 +37,7 @@ int main() {
3637
#include <sycl/info/aspects_deprecated.def>
3738

3839
#undef __SYCL_ASPECT_DEPRECATED
40+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
3941
}
4042

4143
#undef __SYCL_ASPECT_DEPRECATED_ALIAS

sycl/test/check_device_code/device_has_func.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SYCL_EXTERNAL [[sycl::device_has(sycl::aspect::cpu)]] void kernel_name_1() {
4040
func1();
4141
func2();
4242
func3();
43-
func4<sycl::aspect::host>();
43+
func4<sycl::aspect::fp64>();
4444
func5();
4545
func6();
4646
}
@@ -54,6 +54,6 @@ SYCL_EXTERNAL [[sycl::device_has(sycl::aspect::gpu)]] void kernel_name_2() {}
5454
// CHECK-ASPECTS-DAG: [[ASPECTS2]] = !{![[ASPECTFP16:[0-9]+]], ![[ASPECTGPU:[0-9]+]]}
5555
// CHECK-ASPECTS-DAG: [[ASPECTFP16]] = !{!"fp16", i32 5}
5656
// CHECK-ASPECTS-DAG: [[ASPECTGPU]] = !{!"gpu", i32 2}
57-
// CHECK-ASPECTS-DAG: [[ASPECTS3]] = !{![[ASPECTHOST:[0-9]+]]}
58-
// CHECK-ASPECTS-DAG: [[ASPECTHOST]] = !{!"host", i32 0}
57+
// CHECK-ASPECTS-DAG: [[ASPECTS3]] = !{![[ASPECTFP64:[0-9]+]]}
58+
// CHECK-ASPECTS-DAG: [[ASPECTFP64]] = !{!"fp64", i32 6}
5959
// CHECK-ASPECTS-DAG: [[ASPECTS4]] = !{![[ASPECTGPU]]}

sycl/test/check_device_code/device_has_kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class KernelFunctor {
4343
func1();
4444
func2();
4545
func3();
46-
func4<sycl::aspect::host>();
46+
func4<sycl::aspect::fp64>();
4747
func5();
4848
func6();
4949
}
@@ -65,6 +65,6 @@ void foo() {
6565
// CHECK-ASPECTS-DAG: [[ASPECTS2]] = !{![[ASPECTFP16:[0-9]+]], ![[ASPECTGPU:[0-9]+]]}
6666
// CHECK-ASPECTS-DAG: [[ASPECTFP16]] = !{!"fp16", i32 5}
6767
// CHECK-ASPECTS-DAG: [[ASPECTGPU]] = !{!"gpu", i32 2}
68-
// CHECK-ASPECTS-DAG: [[ASPECTS3]] = !{![[ASPECTHOST:[0-9]+]]}
69-
// CHECK-ASPECTS-DAG: [[ASPECTHOST]] = !{!"host", i32 0}
68+
// CHECK-ASPECTS-DAG: [[ASPECTS3]] = !{![[ASPECTFP64:[0-9]+]]}
69+
// CHECK-ASPECTS-DAG: [[ASPECTFP64]] = !{!"fp64", i32 6}
7070
// CHECK-ASPECTS-DAG: [[ASPECTS4]] = !{![[ASPECTGPU]]}

sycl/test/warnings/sycl_2020_deprecations.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ int main() {
2222
(void)Device.get();
2323
// expected-warning@+1 {{'has_extension' is deprecated: use device::has() function with aspects APIs instead}}
2424
(void)Device.has_extension("abc");
25+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
2526
// expected-warning@+1{{'host' is deprecated: removed in SYCL 2020, 'host' device has been removed}}
2627
(void)Device.has(sycl::aspect::host);
28+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
2729

2830
cl_event ClEvent;
2931
// expected-error@+1 {{no matching constructor for initialization of 'sycl::event'}}

sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ TEST(DeviceGetInfo, SupportedDeviceAspects) {
3838
EXPECT_TRUE(containsAspect(DeviceAspects, aspect::fp16));
3939
EXPECT_TRUE(containsAspect(DeviceAspects, aspect::fp64));
4040

41+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
4142
EXPECT_FALSE(containsAspect(DeviceAspects, aspect::host));
43+
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
4244
EXPECT_FALSE(containsAspect(DeviceAspects, aspect::cpu));
4345
}

0 commit comments

Comments
 (0)