diff --git a/doc/runtime_platform.rst b/doc/runtime_platform.rst index 6ee8fb661a842e60696019d43aef91be65981e77..77ceafbf3c7166ef691cd4e3adc651bbdf3c8910 100644 --- a/doc/runtime_platform.rst +++ b/doc/runtime_platform.rst @@ -58,6 +58,18 @@ Device .. automethod:: from_int_ptr .. autoattribute:: int_ptr + .. attribute :: hashable_model_and_version_identifier + + An unspecified data type that can be used to (as precisely as possible, + given identifying information available in OpenCL) identify a given + model and software stack version of a compute device. Note that this + identifier does not differentiate between different instances of the + same device installed in a single host. + + The returned data type is hashable. + + .. versionadded:: 2020.1 + .. method:: create_sub_devices(properties) *properties* is an array of one (or more) of the forms:: diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 4255f92805bd19cf9ae7dc18054e94f1bb79e4e2..7f276a814ff6e37a9f3854009c8d3bc1f89c55c7 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -633,13 +633,22 @@ def _add_functionality(): return "" % ( self.name.strip(), self.platform.name.strip(), self.int_ptr) + def device_hashable_model_and_version_identifier(self): + return ("v1", self.vendor, self.vendor_id, self.name, self.version) + def device_persistent_unique_id(self): - return (self.vendor, self.vendor_id, self.name, self.version) + from warnings import warn + warn("Device.persistent_unique_id is deprecated. " + "Use Device.hashable_model_and_version_identifier instead.", + DeprecationWarning, stacklevel=2) + return device_hashable_model_and_version_identifier(self) Device.__repr__ = device_repr # undocumented for now: Device._get_cl_version = generic_get_cl_version + Device.hashable_model_and_version_identifier = property( + device_hashable_model_and_version_identifier) Device.persistent_unique_id = property(device_persistent_unique_id) # }}} diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 75b39b495feab12b18f89b99d3e85bd53ea08849..dc5772de57ae5d7c05040cdc98117dbed8d53301 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -56,6 +56,9 @@ def test_get_info(ctx_factory): device, = ctx.devices platform = device.platform + device.persistent_unique_id + device.hashable_model_and_version_identifier + failure_count = [0] pocl_quirks = [