Skip to content

Commit 4b1a4bc

Browse files
authored
[SYCL][CUDA] Add backend_version device property (#5802)
Adds `backend_version` device property that can be queried vie `device.get_info()` and implements it for CUDA to return compute capability.
1 parent 9808525 commit 4b1a4bc

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

sycl/include/CL/sycl/detail/pi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ typedef enum {
311311
PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 0x10111,
312312
PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 0x11000,
313313
PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 0x10112,
314+
PI_DEVICE_INFO_BACKEND_VERSION = 0x10113,
314315
PI_EXT_ONEAPI_DEVICE_INFO_MAX_GLOBAL_WORK_GROUPS = 0x20000,
315316
PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_1D = 0x20001,
316317
PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D = 0x20002,

sycl/include/CL/sycl/info/device_traits.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ __SYCL_PARAM_TRAITS_SPEC(device, max_num_sub_groups, pi_uint32)
8686
__SYCL_PARAM_TRAITS_SPEC(device, sub_group_independent_forward_progress, bool)
8787
__SYCL_PARAM_TRAITS_SPEC(device, sub_group_sizes, std::vector<size_t>)
8888
__SYCL_PARAM_TRAITS_SPEC(device, kernel_kernel_pipe_support, bool)
89+
__SYCL_PARAM_TRAITS_SPEC(device, backend_version, std::string)
8990
__SYCL_PARAM_TRAITS_SPEC(device, usm_device_allocations, bool)
9091
__SYCL_PARAM_TRAITS_SPEC(device, usm_host_allocations, bool)
9192
__SYCL_PARAM_TRAITS_SPEC(device, usm_shared_allocations, bool)

sycl/include/CL/sycl/info/info_desc.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ enum class device : cl_device_info {
142142
partition_type_property,
143143
kernel_kernel_pipe_support,
144144
built_in_kernel_ids,
145+
backend_version = PI_DEVICE_INFO_BACKEND_VERSION,
145146
// USM
146147
usm_device_allocations = PI_USM_DEVICE_SUPPORT,
147148
usm_host_allocations = PI_USM_HOST_SUPPORT,

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,15 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
17321732
}
17331733
return getInfo(param_value_size, param_value, param_value_size_ret, value);
17341734
}
1735+
case PI_DEVICE_INFO_BACKEND_VERSION: {
1736+
int major =
1737+
getAttribute(device, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR);
1738+
int minor =
1739+
getAttribute(device, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR);
1740+
std::string result = std::to_string(major) + "." + std::to_string(minor);
1741+
return getInfo(param_value_size, param_value, param_value_size_ret,
1742+
result.c_str());
1743+
}
17351744

17361745
// TODO: Investigate if this information is available on CUDA.
17371746
case PI_DEVICE_INFO_PCI_ADDRESS:

sycl/source/detail/device_info.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,13 @@ inline bool get_device_info_host<info::device::kernel_kernel_pipe_support>() {
11551155
return false;
11561156
}
11571157

1158+
template <>
1159+
inline std::string get_device_info_host<info::device::backend_version>() {
1160+
throw runtime_error(
1161+
"Backend version feature is not supported on HOST device.",
1162+
PI_INVALID_DEVICE);
1163+
}
1164+
11581165
template <>
11591166
inline bool get_device_info_host<info::device::usm_device_allocations>() {
11601167
return true;

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,6 +4287,7 @@ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65575EEENS3_12param_traitsIS4_XT_
42874287
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65808EEENS3_12param_traitsIS4_XT_EE11return_typeEv
42884288
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65809EEENS3_12param_traitsIS4_XT_EE11return_typeEv
42894289
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65810EEENS3_12param_traitsIS4_XT_EE11return_typeEv
4290+
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65811EEENS3_12param_traitsIS4_XT_EE11return_typeEv
42904291
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE69632EEENS3_12param_traitsIS4_XT_EE11return_typeEv
42914292
_ZNK2cl4sycl6device9getNativeEv
42924293
_ZNK2cl4sycl6kernel11get_backendEv

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
??$get_info@$0BABBB@@device@sycl@cl@@QEBA?AV?$vector@W4memory_order@sycl@cl@@V?$allocator@W4memory_order@sycl@cl@@@std@@@std@@XZ
5353
??$get_info@$0BABBC@@device@sycl@cl@@QEBAIXZ
5454
??$get_info@$0BABBC@@kernel@sycl@cl@@QEBAIAEBVdevice@12@@Z
55+
??$get_info@$0BABBD@@device@sycl@cl@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ
5556
??$get_info@$0BABC@@device@sycl@cl@@QEBA_KXZ
5657
??$get_info@$0BABD@@device@sycl@cl@@QEBA_KXZ
5758
??$get_info@$0BABE@@device@sycl@cl@@QEBA_KXZ

0 commit comments

Comments
 (0)