diff --git a/kernel_tuner/backends/hip/hip.py b/kernel_tuner/backends/hip/hip.py index 848b4d46..c32a18e1 100644 --- a/kernel_tuner/backends/hip/hip.py +++ b/kernel_tuner/backends/hip/hip.py @@ -104,7 +104,10 @@ def __init__(self, device=0, iterations=7, compiler_options=None, observers=None env["pci_bus_id"] = props.pciBusID env["pci_domain_id"] = props.pciDomainID env["pci_device_id"] = props.pciDeviceID - env["uuid"] = str(uuid.UUID(bytes=props.uuid.bytes)) + # GPUs without a UUID (e.g. iGPUs) report a placeholder that is shorter than the UUID buffer + env["uuid"] = None + if len(props.uuid.bytes) == props.uuid.c_sizeof(): + env["uuid"] = str(uuid.UUID(bytes=props.uuid.bytes)) env["hip_driver_version"] = hip_check(hip.hipDriverGetVersion()) env["hip_runtime_version"] = hip_check(hip.hipRuntimeGetVersion()) env["device_properties"] = extract_safe_properties(props) diff --git a/test/test_hip_functions.py b/test/test_hip_functions.py index e192223e..eaaa184e 100644 --- a/test/test_hip_functions.py +++ b/test/test_hip_functions.py @@ -1,4 +1,6 @@ import ctypes +import uuid + import numpy as np import pytest @@ -159,4 +161,12 @@ def test_smem_args(env): smem_args=dict(size=lambda p: p['block_size_x'] * 4), verbose=True, lang="HIP") tune_params = env[-1] - assert len(result) == len(tune_params["block_size_x"]) \ No newline at end of file + assert len(result) == len(tune_params["block_size_x"]) + +@skip_if_no_hip +def test_device_uuid(): + """The device UUID is either valid or None, for GPUs that do not report one (e.g. iGPUs).""" + dev = kt_hip.HipFunctions(0) + + device_uuid = dev.env["uuid"] + assert device_uuid is None or isinstance(uuid.UUID(device_uuid), uuid.UUID)