From 7eb919651033804c737d40fd91280b7a94dbf87b Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Mon, 19 Sep 2022 14:21:36 +0200 Subject: [PATCH] Unshadow device re-exports In the `device` module, all public items from `cl3::device` are re-exported. They even [show up as public in the documentation]. Nonetheless they aren't actually public. To reproduce this issue, try to import `opencl3::device::CL_UUID_SIZE_KHR`, you will get an error like: error[E0603]: constant `CL_UUID_SIZE_KHR` is private --> src/device.rs:2209:30 | 2209 | opencl3::device::CL_UUID_SIZE_KHR, | ^^^^^^^^^^^^^^^^ private constant | note: the constant `CL_UUID_SIZE_KHR` is defined here --> /home/vmx/src/pl/filecoin/upstream/opencl3/src/device.rs:45:23 | 45 | CL_LUID_SIZE_KHR, CL_UUID_SIZE_KHR, | ^^^^^^^^^^^^^^^^ The private imports at https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L18 shadow the previous public re-exports https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L15 As most of the private imports are a subset of the public re-exports, we can just import the missing ones, which in this case is only `cl_device_feature_capabilities_intel`. In order verify the subset, you can copy the list of [imports from `cl3::ext`] and the [`cl3::device` re-exports from `opencl-sys`] into two fiels and run ` tr ',' '\n|awk '{$1=$1;print}'|sort` on each of them and finally diff the results. [show up as public in the documentation]: https://docs.rs/opencl3/0.9.0/opencl3/device/constant.CL_UUID_SIZE_KHR.html [imports from `cl3::ext`]: https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L19-L45 [`cl3::device` re-exports from `opencl-sys`]: https://github.com/kenba/cl3/blob/9c97521ab27dd709e2ec9482855023ef0c5d4838/src/device.rs#L21-L106 --- src/device.rs | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/device.rs b/src/device.rs index 87b077b..e23a31a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -14,36 +14,7 @@ pub use cl3::device::*; -#[allow(unused_imports)] -use cl3::ext::{ - cl_amd_device_topology, cl_device_feature_capabilities_intel, - cl_device_integer_dot_product_acceleration_properties_khr, - CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR, - CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD, CL_DEVICE_BOARD_NAME_AMD, - CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, - CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, - CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, - CL_DEVICE_FEATURE_CAPABILITIES_INTEL, CL_DEVICE_GFXIP_MAJOR_AMD, CL_DEVICE_GFXIP_MINOR_AMD, - CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, - CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, - CL_DEVICE_GPU_OVERLAP_NV, CL_DEVICE_ID_INTEL, - CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, - CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, CL_DEVICE_INTEGRATED_MEMORY_NV, - CL_DEVICE_IP_VERSION_INTEL, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, CL_DEVICE_LOCAL_MEM_BANKS_AMD, - CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, CL_DEVICE_LUID_KHR, CL_DEVICE_LUID_VALID_KHR, - CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD, CL_DEVICE_NODE_MASK_KHR, - CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, CL_DEVICE_NUM_SLICES_INTEL, - CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL, CL_DEVICE_NUM_THREADS_PER_EU_INTEL, - CL_DEVICE_PCIE_ID_AMD, CL_DEVICE_PCI_BUS_ID_NV, CL_DEVICE_PCI_BUS_INFO_KHR, - CL_DEVICE_PCI_SLOT_ID_NV, CL_DEVICE_PREFERRED_CONSTANT_BUFFER_SIZE_AMD, - CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_AMD, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, - CL_DEVICE_REGISTERS_PER_BLOCK_NV, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, - CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, CL_DEVICE_SEMAPHORE_TYPES_KHR, - CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, - CL_DEVICE_SIMD_WIDTH_AMD, CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD, CL_DEVICE_TOPOLOGY_AMD, - CL_DEVICE_UUID_KHR, CL_DEVICE_WARP_SIZE_NV, CL_DEVICE_WAVEFRONT_WIDTH_AMD, CL_DRIVER_UUID_KHR, - CL_LUID_SIZE_KHR, CL_UUID_SIZE_KHR, -}; +pub use cl3::ext::cl_device_feature_capabilities_intel; use super::platform::get_platforms; use super::Result; @@ -2203,4 +2174,13 @@ mod tests { ), }; } + + #[test] + fn test_public_re_export() { + assert_eq!( + opencl3::device::CL_UUID_SIZE_KHR, + 16, + "Constant is accessible" + ); + } }