Skip to content

Commit 7af8c96

Browse files
committed
[SYCL] Add support for info::device::sub_group_sizes
Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent 39c82eb commit 7af8c96

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

sycl/include/CL/sycl/detail/device_info.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,24 @@ struct get_device_info_cl<T, info::device::parent_device> {
265265
}
266266
};
267267

268+
// Specialization for supported subgroup sizes
269+
template <>
270+
struct get_device_info_cl<vector_class<size_t>,
271+
info::device::sub_group_sizes> {
272+
static vector_class<size_t> _(cl_device_id dev) {
273+
size_t resultSize = 0;
274+
CHECK_OCL_CODE(
275+
clGetDeviceInfo(dev, (cl_device_info)info::device::sub_group_sizes,
276+
0, nullptr, &resultSize));
277+
vector_class<size_t> result(resultSize);
278+
CHECK_OCL_CODE(
279+
clGetDeviceInfo(dev, (cl_device_info)info::device::sub_group_sizes,
280+
resultSize, result.data(), nullptr));
281+
return result;
282+
}
283+
};
284+
285+
268286
// SYCL host device information
269287

270288
// Default template is disabled, all possible instantiations are
@@ -471,6 +489,9 @@ template <> cl_uint get_device_info_host<info::device::reference_count>();
471489

472490
template <> cl_uint get_device_info_host<info::device::max_num_sub_groups>();
473491

492+
template <>
493+
vector_class<size_t> get_device_info_host<info::device::sub_group_sizes>();
494+
474495
template <>
475496
bool get_device_info_host<
476497
info::device::sub_group_independent_forward_progress>();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ enum class device : cl_device_info {
118118
max_num_sub_groups = CL_DEVICE_MAX_NUM_SUB_GROUPS,
119119
sub_group_independent_forward_progress =
120120
CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
121+
sub_group_sizes = CL_DEVICE_SUB_GROUP_SIZES_INTEL,
121122
partition_type_property
122123
};
123124

@@ -323,6 +324,7 @@ PARAM_TRAITS_SPEC(device, partition_type_affinity_domain,
323324
PARAM_TRAITS_SPEC(device, reference_count, cl_uint)
324325
PARAM_TRAITS_SPEC(device, max_num_sub_groups, cl_uint)
325326
PARAM_TRAITS_SPEC(device, sub_group_independent_forward_progress, bool)
327+
PARAM_TRAITS_SPEC(device, sub_group_sizes, vector_class<size_t>)
326328

327329
PARAM_TRAITS_SPEC(context, reference_count, cl_uint)
328330
PARAM_TRAITS_SPEC(context, platform, cl::sycl::platform)

sycl/source/detail/device_info.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ template <> cl_uint get_device_info_host<info::device::max_num_sub_groups>() {
466466
throw runtime_error("Sub-group feature is not supported on HOST device.");
467467
}
468468

469+
template <> vector_class<size_t>
470+
get_device_info_host<info::device::sub_group_sizes>() {
471+
// TODO update once subgroups are enabled
472+
throw runtime_error("Sub-group feature is not supported on HOST device.");
473+
}
474+
469475
template <>
470476
bool get_device_info_host<
471477
info::device::sub_group_independent_forward_progress>() {

sycl/test/sub_group/info.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,39 @@ int main() {
2828
return 1;
2929
} catch (runtime_error e) {
3030
/* Expected exception. */
31+
}
32+
try {
33+
Device.get_info<info::device::sub_group_independent_forward_progress>();
34+
std::cout << "Expected exception has not been generated\n";
35+
return 1;
36+
} catch (runtime_error e) {
37+
/* Expected exception. */
38+
}
39+
try {
40+
Device.get_info<info::device::sub_group_sizes>();
41+
std::cout << "Expected exception has not been generated\n";
42+
return 1;
43+
} catch (runtime_error e) {
44+
/* Expected exception. */
45+
}
46+
} else {
47+
Device.get_info<info::device::sub_group_independent_forward_progress>();
48+
Device.get_info<info::device::max_num_sub_groups>();
49+
// There is no support on CPU and accelerator devices for now.
50+
if ( Device.get_info<info::device::device_type>() == info::device_type::cpu ||
51+
Device.get_info<info::device::device_type>() ==
52+
info::device_type::accelerator) {
3153
try {
32-
Device.get_info<info::device::sub_group_independent_forward_progress>();
54+
Device.get_info<info::device::sub_group_sizes>();
3355
std::cout << "Expected exception has not been generated\n";
3456
return 1;
3557
} catch (runtime_error e) {
36-
/* Expected exception - do nothing. */
58+
/* Expected exception. */
3759
}
60+
} else {
61+
Device.get_info<info::device::sub_group_sizes>();
3862
}
3963

40-
} else {
41-
Device.get_info<info::device::sub_group_independent_forward_progress>();
42-
Device.get_info<info::device::max_num_sub_groups>();
43-
4464
/* Basic sub-group functionality is supported as part of cl_khr_subgrou
4565
* extension or as core OpenCL 2.1 feature. */
4666
if (!core_sg_supported(Device)) {

0 commit comments

Comments
 (0)