Skip to content

Commit ce3ac09

Browse files
authored
[SYCL] Add support for USM aspects. (#2706)
This patch adds support for the USM-related aspects and the custom aspect. All device aspects defined by the SYCL 2020 Provisional Specification are now supported. Signed-off-by: Gail Lyons <[email protected]>
1 parent ecd0adb commit ce3ac09

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

sycl/source/detail/device_impl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ bool device_impl::has(aspect Aspect) const {
225225
return is_gpu();
226226
case aspect::accelerator:
227227
return is_accelerator();
228+
case aspect::custom:
229+
return false;
228230
case aspect::fp16:
229231
return has_extension("cl_khr_fp16");
230232
case aspect::fp64:
@@ -241,6 +243,16 @@ bool device_impl::has(aspect Aspect) const {
241243
return get_info<info::device::is_linker_available>();
242244
case aspect::queue_profiling:
243245
return get_info<info::device::queue_profiling>();
246+
case aspect::usm_device_allocations:
247+
return get_info<info::device::usm_device_allocations>();
248+
case aspect::usm_host_allocations:
249+
return get_info<info::device::usm_host_allocations>();
250+
case aspect::usm_shared_allocations:
251+
return get_info<info::device::usm_shared_allocations>();
252+
case aspect::usm_restricted_shared_allocations:
253+
return get_info<info::device::usm_restricted_shared_allocations>();
254+
case aspect::usm_system_allocator:
255+
return get_info<info::device::usm_system_allocator>();
244256
default:
245257
throw runtime_error("This device aspect has not been implemented yet.",
246258
PI_INVALID_DEVICE);

sycl/test/basic_tests/aspects.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ int main() {
2525
pltIdx++;
2626
if (plt.has(aspect::host)) {
2727
std::cout << "Platform #" << pltIdx
28-
<< " type: host supports:" << std::endl;
28+
<< " type: Host supports:" << std::endl;
2929
} else if (plt.has(aspect::cpu)) {
3030
std::cout << "Platform #" << pltIdx
31-
<< " type: cpu supports:" << std::endl;
31+
<< " type: CPU supports:" << std::endl;
3232
} else if (plt.has(aspect::gpu)) {
3333
std::cout << "Platform #" << pltIdx
34-
<< " type: gpu supports:" << std::endl;
34+
<< " type: GPU supports:" << std::endl;
3535
} else if (plt.has(aspect::accelerator)) {
3636
std::cout << "Platform #" << pltIdx
37-
<< " type: accelerator supports:" << std::endl;
37+
<< " type: Accelerator supports:" << std::endl;
38+
} else if (plt.has(aspect::custom)) {
39+
std::cout << "Platform #" << pltIdx
40+
<< " type: Custom supports:" << std::endl;
3841
} else {
3942
failed = true;
4043
std::cout << "Failed: platform #" << pltIdx << " type: unknown"
@@ -66,6 +69,21 @@ int main() {
6669
if (plt.has(aspect::queue_profiling)) {
6770
std::cout << " queue profiling" << std::endl;
6871
}
72+
if (plt.has(aspect::usm_device_allocations)) {
73+
std::cout << " USM allocations" << std::endl;
74+
}
75+
if (plt.has(aspect::usm_host_allocations)) {
76+
std::cout << " USM host allocations" << std::endl;
77+
}
78+
if (plt.has(aspect::usm_shared_allocations)) {
79+
std::cout << " USM shared allocations" << std::endl;
80+
}
81+
if (plt.has(aspect::usm_restricted_shared_allocations)) {
82+
std::cout << " USM restricted shared allocations" << std::endl;
83+
}
84+
if (plt.has(aspect::usm_system_allocator)) {
85+
std::cout << " USM system allocator" << std::endl;
86+
}
6987
}
7088
std::cout << "Passed." << std::endl;
7189
return 0;

0 commit comments

Comments
 (0)