From 0d972d0f9165b177e5253ef172b404cec2caa26d Mon Sep 17 00:00:00 2001 From: "[6~" Date: Tue, 28 Jan 2020 17:21:47 -0600 Subject: [PATCH] Add Device.hashable_model_and_version_identifier, deprecate Device.persistent_unique_id (closes gh-327) --- doc/runtime_platform.rst | 12 ++++++++++++ pyopencl/__init__.py | 11 ++++++++++- test/test_wrapper.py | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/runtime_platform.rst b/doc/runtime_platform.rst index 6ee8fb66..77ceafbf 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 4255f928..7f276a81 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 75b39b49..dc5772de 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 = [ -- GitLab