Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testing] match dpctl attribute get_device_id attribute in backend SyclDevice object #2292

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions onedal/common/sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ void instantiate_sycl_interfaces(py::module& m) {
}
return py::str(filter + ":") + py::str(py::int_(outidx));
})
.def_property_readonly("device_id",
[](const sycl::device& device) {
// assumes we are not working with accelerators
std::string filter = get_device_name(device);
return get_device_id(device).value();
})
.def("get_device_id",
[](const sycl::device& device) {
return get_device_id(device).value();
})
.def_property_readonly("is_cpu", &sycl::device::is_cpu)
.def_property_readonly("is_gpu", &sycl::device::is_gpu);
}
Expand Down
16 changes: 16 additions & 0 deletions onedal/common/tests/test_sycl.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,19 @@ def test_backend_queue():
assert all([queue.sycl_device.is_cpu for queue in q_array])
assert all([not queue.sycl_device.is_gpu for queue in q_array])
assert all(["cpu" in queue.sycl_device.filter_string for queue in q_array])


@pytest.mark.skipif(
not _is_dpc_backend or not dpctl_available, reason="requires dpc backend and dpctl"
)
def test_backend_device_id():
"""verify dpctl device id matches our internal device id"""
import dpctl

for i in range(dpctl.get_num_devices()):
device = dpctl.SyclDevice(str(i))
if device.is_gpu or device.is_cpu:
backend_device = _backend.SyclDevice(i)
assert (
i == backend_device.get_device_id()
), f"_backend id does not match device_id: {i}"
Loading