rusticl/device: implement cl_khr_device_uuid

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Tested-by: Andrey Alekseenko <al42and@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23147>
This commit is contained in:
norablackcat 2023-05-20 09:06:02 -06:00 committed by Marge Bot
parent 536283555e
commit c07b8a54c5
2 changed files with 23 additions and 0 deletions

View file

@ -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

View file

@ -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");
}