Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
* Removed stale `select_host_device` and `has_host_device` names from `dpctl.__all__`, which made `from dpctl import *` fail with `AttributeError` [gh-2410](https://github.com/IntelPython/dpctl/pull/2410)
* `dpctl.SyclPlatform.get_devices` no longer prints Unified Runtime warnings for `device_type="custom"` on non-OpenCL platforms, where custom devices are not supported [gh-2306](https://github.com/IntelPython/dpctl/pull/2306)

### Maintenance

Expand Down
6 changes: 4 additions & 2 deletions dpctl/_sycl_platform.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ cdef class SyclPlatform(_SyclPlatform):
device_type (str, :class:`dpctl.device_type`, optional):
A :class:`dpctl.device_type` enum value or a string that
specifies a SYCL device type. Currently, accepted values are:
"gpu", "cpu", "accelerator", or "all", and their equivalent
``dpctl.device_type`` enumerators.
"gpu", "cpu", "accelerator", "automatic", "custom", or "all",
and their equivalent ``dpctl.device_type`` enumerators.
Only OpenCL platforms support custom devices; for other
platforms, "custom" returns an empty tuple.
Default: ``dpctl.device_type.all``.

Returns:
Expand Down
18 changes: 18 additions & 0 deletions dpctl/tests/test_sycl_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ def test_platform_get_devices_enum_device_type():
assert (d.device_type == dty for d in devices)


@pytest.mark.parametrize("dty", ["custom", device_type.custom])
def test_platform_get_devices_custom_non_opencl(dty, capfd):
platforms = [
p
for p in dpctl.get_platforms()
if p.backend != dpctl.backend_type.opencl
]
if not platforms:
pytest.skip("No non-OpenCL platforms available")
capfd.readouterr()
for p in platforms:
assert len(p.get_devices(device_type=dty)) == 0
out, err = capfd.readouterr()
# e.g., the Level Zero adapter warns on device_type::custom
assert out == ""
assert err == ""


def test_platform_get_composite_devices():
platforms = dpctl.get_platforms()
if platforms:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ size_t DPCTLPlatform_Hash(__dpctl_keep const DPCTLSyclPlatformRef PRef);
* @brief Returns a vector of devices associated with sycl::platform referenced
* by DPCTLSyclPlatformRef object.
*
* Only OpenCL platforms support custom devices; for other platforms,
* DPCTL_CUSTOM returns an empty vector.
*
* @param PRef The DPCTLSyclPlatformRef pointer.
* @param DTy A DPCTLSyclDeviceType enum value.
* @return A DPCTLDeviceVectorRef with devices associated with given PRef.
Expand Down
9 changes: 9 additions & 0 deletions libsyclinterface/source/dpctl_sycl_platform_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ DPCTLPlatform_GetDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef,
return wrap<vecTy>(DevicesVectorPtr);
}

// Only OpenCL supports custom devices; other backends may warn when asked
// for them (e.g., the Unified Runtime Level Zero adapter)
if (DTy == DPCTLSyclDeviceType::DPCTL_CUSTOM &&
DPCTL_SyclBackendToDPCTLBackendType(P->get_backend()) !=
DPCTLSyclBackendType::DPCTL_OPENCL)
{
return wrap<vecTy>(DevicesVectorPtr);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to cover that in the test?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't obvious how to capture the UR warnings. It might be possible by some gymnastics capturing all stdout, but, then it only applies for Level Zero. I can test a few things first though

}

try {
auto SyclDTy = DPCTL_DPCTLDeviceTypeToSyclDeviceType(DTy);
auto Devices = P->get_devices(SyclDTy);
Expand Down
Loading