def test_get_devices_with_device_type_str(device_type_str): num_devices = dpctl.get_num_devices(device_type=device_type_str) if num_devices > 0: devices = dpctl.get_devices(device_type=device_type_str) assert len(devices) == num_devices dty = string_to_device_type(device_type_str) check_if_device_type_matches(devices, dty) check_if_device_type_is_valid(devices) # check for consistency of ordering between filter selector # where backend is omitted, but device type and id is specified for i in range(num_devices): dev = dpctl.SyclDevice(":".join((device_type_str, str(i)))) assert dev == devices[i] else: pytest.skip()
def has_cpu(backend="opencl"): return bool(dpctl.get_num_devices(backend=backend, device_type="cpu"))
def has_opencl_cpu(): """ Checks if dpctl is able to select an OpenCL CPU device. """ return bool(dpctl.get_num_devices(backend="opencl", device_type="cpu"))
def has_level_zero(): """ Checks if dpctl is able to select a Level Zero GPU device. """ return bool(dpctl.get_num_devices(backend="level_zero", device_type="gpu"))
def has_cpu_queues(backend="opencl"): """ Checks if dpctl is able to select a CPU device that defaults to an OpenCL CPU. """ return bool(dpctl.get_num_devices(backend=backend, device_type="cpu"))