Module: Mesa
Branch: main
Commit: c07b8a54c5f73410bb08bb4893e0b6c7697f8901
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c07b8a54c5f73410bb08bb4893e0b6c7697f8901

Author: norablackcat <[email protected]>
Date:   Sat May 20 09:06:02 2023 -0600

rusticl/device: implement cl_khr_device_uuid

Reviewed-by: Karol Herbst <[email protected]>
Tested-by: Andrey Alekseenko <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23147>

---

 src/gallium/frontends/rusticl/api/device.rs  | 15 +++++++++++++++
 src/gallium/frontends/rusticl/core/device.rs |  8 ++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/gallium/frontends/rusticl/api/device.rs 
b/src/gallium/frontends/rusticl/api/device.rs
index 8fe6368d05e..72c92c1b887 100644
--- a/src/gallium/frontends/rusticl/api/device.rs
+++ b/src/gallium/frontends/rusticl/api/device.rs
@@ -138,6 +138,12 @@ impl CLInfo<cl_device_info> for cl_device_id {
             CL_DEVICE_LOCAL_MEM_SIZE => 
cl_prop::<cl_ulong>(dev.local_mem_size()),
             // TODO add query for CL_LOCAL vs CL_GLOBAL
             CL_DEVICE_LOCAL_MEM_TYPE => 
cl_prop::<cl_device_local_mem_type>(CL_GLOBAL),
+            CL_DEVICE_LUID_KHR => cl_prop::<[cl_uchar; CL_LUID_SIZE_KHR as 
usize]>(
+                dev.screen().device_luid().unwrap_or_default(),
+            ),
+            CL_DEVICE_LUID_VALID_KHR => {
+                cl_prop::<cl_bool>(dev.screen().device_luid().is_some().into())
+            }
             CL_DEVICE_MAX_CLOCK_FREQUENCY => 
cl_prop::<cl_uint>(dev.max_clock_freq()),
             CL_DEVICE_MAX_COMPUTE_UNITS => 
cl_prop::<cl_uint>(dev.max_compute_units()),
             // TODO atm implemented as mem_const
@@ -178,6 +184,9 @@ impl CLInfo<cl_device_info> for cl_device_id {
             CL_DEVICE_NATIVE_VECTOR_WIDTH_INT => cl_prop::<cl_uint>(1),
             CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG => cl_prop::<cl_uint>(1),
             CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT => cl_prop::<cl_uint>(1),
+            CL_DEVICE_NODE_MASK_KHR => {
+                
cl_prop::<cl_uint>(dev.screen().device_node_mask().unwrap_or_default())
+            }
             CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT => cl_prop::<bool>(false),
             CL_DEVICE_NUMERIC_VERSION => cl_prop::<cl_version>(dev.cl_version 
as cl_version),
             // TODO subdevice support
@@ -244,9 +253,15 @@ impl CLInfo<cl_device_info> for cl_device_id {
                 )
             }
             CL_DEVICE_TYPE => 
cl_prop::<cl_device_type>(dev.device_type(false)),
+            CL_DEVICE_UUID_KHR => cl_prop::<[cl_uchar; CL_UUID_SIZE_KHR as 
usize]>(
+                dev.screen().device_uuid().unwrap_or_default(),
+            ),
             CL_DEVICE_VENDOR => cl_prop(dev.screen().device_vendor()),
             CL_DEVICE_VENDOR_ID => cl_prop::<cl_uint>(dev.vendor_id()),
             CL_DEVICE_VERSION => cl_prop::<String>(format!("OpenCL {} ", 
dev.cl_version.api_str())),
+            CL_DRIVER_UUID_KHR => cl_prop::<[cl_char; CL_UUID_SIZE_KHR as 
usize]>(
+                dev.screen().driver_uuid().unwrap_or_default(),
+            ),
             CL_DRIVER_VERSION => cl_prop::<&CStr>(unsafe { 
CStr::from_ptr(mesa_version_string()) }),
             CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT => 
cl_prop::<bool>(false),
             // CL_INVALID_VALUE if param_name is not one of the supported 
values
diff --git a/src/gallium/frontends/rusticl/core/device.rs 
b/src/gallium/frontends/rusticl/core/device.rs
index 68abf7871e5..e2742d1a5b6 100644
--- a/src/gallium/frontends/rusticl/core/device.rs
+++ b/src/gallium/frontends/rusticl/core/device.rs
@@ -15,6 +15,7 @@ use mesa_rust::pipe::resource::*;
 use mesa_rust::pipe::screen::*;
 use mesa_rust::pipe::transfer::*;
 use mesa_rust_gen::*;
+use mesa_rust_util::static_assert;
 use rusticl_opencl_gen::*;
 
 use std::cmp::max;
@@ -540,6 +541,13 @@ impl Device {
             add_ext(1, 0, 0, "cl_khr_pci_bus_info");
         }
 
+        if self.screen().device_uuid().is_some() && 
self.screen().driver_uuid().is_some() {
+            static_assert!(PIPE_UUID_SIZE == CL_UUID_SIZE_KHR);
+            static_assert!(PIPE_LUID_SIZE == CL_LUID_SIZE_KHR);
+
+            add_ext(1, 0, 0, "cl_khr_device_uuid");
+        }
+
         if self.svm_supported() {
             add_ext(1, 0, 0, "cl_arm_shared_virtual_memory");
         }

Reply via email to