Skip to content

Commit b7028f3

Browse files
Extended examples/pybind11/use_dpctl_syclqueue/use_queue_device
Added a function that retrieves sub_group_sizes property of the device.
1 parent 8ff1e33 commit b7028f3

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

examples/pybind11/use_dpctl_syclqueue/tests/test_queue_device.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ def test_offload_array_mod():
5555
Ynp = X % modulus_p
5656

5757
assert np.array_equal(Y, Ynp)
58+
59+
60+
def test_get_sub_group_sizes():
61+
d = dpctl.SyclDevice()
62+
szs = uqd.get_sub_group_sizes(d)
63+
assert type(szs) is list
64+
assert all(type(el) is int for el in szs)
65+
szs == d.sub_group_sizes

examples/pybind11/use_dpctl_syclqueue/use_queue_device/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
get_device_global_mem_size,
2121
get_device_local_mem_size,
2222
get_max_compute_units,
23+
get_sub_group_sizes,
2324
offloaded_array_mod,
2425
)
2526

@@ -28,6 +29,7 @@
2829
"get_device_global_mem_size",
2930
"get_device_local_mem_size",
3031
"offloaded_array_mod",
32+
"get_sub_group_sizes",
3133
]
3234

3335
__doc__ = """

examples/pybind11/use_dpctl_syclqueue/use_queue_device/_example.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <cstdint>
3232
#include <pybind11/numpy.h>
3333
#include <pybind11/pybind11.h>
34+
#include <pybind11/stl.h>
3435

3536
namespace py = pybind11;
3637

@@ -84,6 +85,11 @@ offloaded_array_mod(sycl::queue q,
8485
return res;
8586
}
8687

88+
std::vector<std::size_t> get_sub_group_sizes(const sycl::device &d)
89+
{
90+
return d.get_info<sycl::info::device::sub_group_sizes>();
91+
}
92+
8793
PYBIND11_MODULE(_use_queue_device, m)
8894
{
8995
m.def(
@@ -100,4 +106,6 @@ PYBIND11_MODULE(_use_queue_device, m)
100106
"Computes amount of local memory of the given dpctl.SyclDevice");
101107
m.def("offloaded_array_mod", &offloaded_array_mod,
102108
"Compute offloaded modular reduction of integer-valued NumPy array");
109+
m.def("get_sub_group_sizes", &get_sub_group_sizes,
110+
"Gets info::device::sub_group_sizes property of given device");
103111
}

0 commit comments

Comments
 (0)