diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 2e8395aee34..7596813587d 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -14,7 +14,6 @@ use rusticl_proc_macros::cl_info_entrypoint; use std::cmp::min; use std::ffi::c_char; use std::ffi::CStr; -use std::mem::size_of; use std::ptr; const SPIRV_SUPPORT_STRING: &CStr = diff --git a/src/gallium/frontends/rusticl/api/icd.rs b/src/gallium/frontends/rusticl/api/icd.rs index 6afc5bbcba4..5f341cbd2ad 100644 --- a/src/gallium/frontends/rusticl/api/icd.rs +++ b/src/gallium/frontends/rusticl/api/icd.rs @@ -31,7 +31,7 @@ const CL_ICD2_TAG_KHR: isize = 0x434C3331; const CL_ICD2_TAG_KHR: isize = 0x4F50454E434C3331; const fn cl_icd_dispatch_default() -> cl_icd_dispatch { - const ELEMS: usize = mem::size_of::() / mem::size_of::>(); + const ELEMS: usize = size_of::() / size_of::>(); // SAFETY: cl_icd_dispatch is a list of function pointers and we set them all to None unsafe { mem::transmute([None::; ELEMS]) } diff --git a/src/gallium/frontends/rusticl/api/kernel.rs b/src/gallium/frontends/rusticl/api/kernel.rs index 84db0545fb6..0cc04f76254 100644 --- a/src/gallium/frontends/rusticl/api/kernel.rs +++ b/src/gallium/frontends/rusticl/api/kernel.rs @@ -16,7 +16,6 @@ use rusticl_proc_macros::cl_info_entrypoint; use std::cmp; use std::ffi::CStr; -use std::mem; use std::os::raw::c_void; use std::ptr; use std::slice; @@ -164,7 +163,7 @@ unsafe impl CLInfoObj(); + let usize_byte = size_of::(); // first we have to convert the input to a proper thing let input: &[usize] = match q { CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE | CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE => { @@ -382,13 +381,13 @@ fn set_kernel_arg( | KernelArgType::Image | KernelArgType::RWImage | KernelArgType::Texture => { - if arg_size != std::mem::size_of::() { + if arg_size != size_of::() { return Err(CL_INVALID_ARG_SIZE); } } KernelArgType::Sampler => { - if arg_size != std::mem::size_of::() { + if arg_size != size_of::() { return Err(CL_INVALID_ARG_SIZE); } } diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 146d1c5b540..f2ab763167b 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -21,7 +21,6 @@ use rusticl_proc_macros::cl_info_entrypoint; use std::cmp; use std::cmp::Ordering; -use std::mem; use std::num::NonZeroU64; use std::os::raw::c_void; use std::ptr; @@ -2379,7 +2378,7 @@ pub fn svm_alloc( // When alignment is 0, the size of the largest supported type is used. // In the case of the full profile, that's `long16`. let alignment = NonZeroU64::new(alignment.into()) - .unwrap_or(NonZeroU64::new(mem::size_of::<[u64; 16]>() as u64).unwrap()); + .unwrap_or(NonZeroU64::new(size_of::<[u64; 16]>() as u64).unwrap()); // size is 0 or > CL_DEVICE_MAX_MEM_ALLOC_SIZE value for any device in context. let size = NonZeroU64::new(size as u64).ok_or(CL_INVALID_VALUE)?; @@ -2677,8 +2676,8 @@ fn enqueue_svm_mem_fill_impl( struct Pattern([u8; $bytesize]); // Just to make sure the compiler didn't generate anything weird. - static_assert!($bytesize == mem::size_of::()); - static_assert!($bytesize == mem::align_of::()); + static_assert!($bytesize == size_of::()); + static_assert!($bytesize == align_of::()); // CAST: We don't know exactly which type `pattern` points to, but we know it's an // Application Scalar Data Type (cl_char, cl_ulong, etc.) or an Application Vector Data diff --git a/src/gallium/frontends/rusticl/api/util.rs b/src/gallium/frontends/rusticl/api/util.rs index 4713f07517e..19f077d0b7e 100644 --- a/src/gallium/frontends/rusticl/api/util.rs +++ b/src/gallium/frontends/rusticl/api/util.rs @@ -6,13 +6,13 @@ use crate::core::queue::*; use mesa_rust_util::properties::Properties; use rusticl_opencl_gen::*; +use std::cmp; use std::convert::TryInto; use std::ffi::{c_void, CStr}; use std::iter::zip; use std::mem::MaybeUninit; use std::ops::BitAnd; use std::sync::Arc; -use std::{cmp, mem}; // TODO: use MaybeUninit::copy_from_slice once stable pub fn maybe_uninit_copy_from_slice(this: &mut [MaybeUninit], src: &[T]) @@ -81,7 +81,7 @@ impl CLInfoValue<'_> { /// Used to read from the application provided data. pub fn input(&self) -> CLResult<&[MaybeUninit]> { if let Some(param_value) = &self.param_value { - let count = param_value.len() / mem::size_of::(); + let count = param_value.len() / size_of::(); unsafe { cl_slice::from_raw_parts(param_value.as_ptr().cast(), count) } } else { Ok(&[]) @@ -106,7 +106,7 @@ impl CLInfoValue<'_> { /// All types implementing [CLProp] are supported. pub fn write(self, t: T) -> CLResult { let count = t.count(); - let bytes = count * mem::size_of::(); + let bytes = count * size_of::(); // param_value is a pointer to memory where the appropriate result being queried is // returned. If param_value is NULL, it is ignored. @@ -143,7 +143,7 @@ impl CLInfoValue<'_> { /// `CL_PROGRAM_BINARIES`. In that case it's meaningless to write back the same pointers. This /// function can be used to skip those writes. pub fn write_len_only(self, len: usize) -> CLResult { - let bytes = len * mem::size_of::(); + let bytes = len * size_of::(); // param_value_size_ret returns the actual size in bytes of data being queried by // param_name. If param_value_size_ret is NULL, it is ignored. @@ -166,7 +166,7 @@ impl CLInfoValue<'_> { iter: impl ExactSizeIterator, ) -> CLResult { let count = iter.len(); - let bytes = count * mem::size_of::(); + let bytes = count * size_of::(); // param_value is a pointer to memory where the appropriate result being queried is // returned. If param_value is NULL, it is ignored. @@ -554,14 +554,13 @@ pub mod cl_slice { use mesa_rust_util::ptr::addr; use rusticl_opencl_gen::CL_INVALID_VALUE; use std::ffi::c_void; - use std::mem; use std::slice; /// Wrapper around [`std::slice::from_raw_parts`] that returns `Err(CL_INVALID_VALUE)` if any of these conditions is met: /// - `data` is null /// - `data` is not correctly aligned for `T` - /// - `len * std::mem::size_of::()` is larger than `isize::MAX` - /// - `data` + `len * std::mem::size_of::()` wraps around the address space + /// - `len * size_of::()` is larger than `isize::MAX` + /// - `data` + `len * size_of::()` wraps around the address space /// /// # Safety /// The behavior is undefined if any of the other requirements imposed by @@ -587,7 +586,7 @@ pub mod cl_slice { data: *const c_void, len: usize, ) -> CLResult<&'a [T]> { - let size = mem::size_of::(); + let size = size_of::(); if len % size != 0 { return Err(CL_INVALID_VALUE); } @@ -599,8 +598,8 @@ pub mod cl_slice { /// Wrapper around [`std::slice::from_raw_parts_mut`] that returns `Err(CL_INVALID_VALUE)` if any of these conditions is met: /// - `data` is null /// - `data` is not correctly aligned for `T` - /// - `len * std::mem::size_of::()` is larger than `isize::MAX` - /// - `data` + `len * std::mem::size_of::()` wraps around the address space + /// - `len * size_of::()` is larger than `isize::MAX` + /// - `data` + `len * size_of::()` wraps around the address space /// /// # Safety /// The behavior is undefined if any of the other requirements imposed by @@ -621,7 +620,7 @@ pub mod cl_slice { #[must_use] fn allocation_obviously_invalid(data: *const T, len: usize) -> bool { - let Some(total_size) = mem::size_of::().checked_mul(len) else { + let Some(total_size) = size_of::().checked_mul(len) else { return true; }; data.is_null() diff --git a/src/gallium/frontends/rusticl/core/context.rs b/src/gallium/frontends/rusticl/core/context.rs index f57a3b09620..3fb65d5776c 100644 --- a/src/gallium/frontends/rusticl/core/context.rs +++ b/src/gallium/frontends/rusticl/core/context.rs @@ -512,7 +512,7 @@ impl Context { ctx.clear_buffer(res, &pattern, offset as u32, size as u32); } else { let slice = unsafe { - slice::from_raw_parts_mut(svm_ptr as *mut _, size / mem::size_of_val(&pattern)) + slice::from_raw_parts_mut(svm_ptr as *mut _, size / size_of_val(&pattern)) }; slice.fill(pattern); diff --git a/src/gallium/frontends/rusticl/core/memory.rs b/src/gallium/frontends/rusticl/core/memory.rs index f52a0d72186..83cfb87898c 100644 --- a/src/gallium/frontends/rusticl/core/memory.rs +++ b/src/gallium/frontends/rusticl/core/memory.rs @@ -32,7 +32,6 @@ use std::convert::TryInto; use std::fmt::Debug; use std::hash::Hash; use std::mem; -use std::mem::size_of; use std::num::NonZeroU64; use std::ops::Deref; use std::os::raw::c_void; diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index a8fb0b9d706..9ff363be053 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -16,7 +16,6 @@ use rusticl_opencl_gen::*; use std::collections::HashMap; use std::collections::HashSet; use std::ffi::CString; -use std::mem::size_of; use std::ptr::addr_of; use std::slice; use std::sync::Arc; diff --git a/src/gallium/frontends/rusticl/mesa/pipe/context.rs b/src/gallium/frontends/rusticl/mesa/pipe/context.rs index 781ed5fe8dc..149988f6a28 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/context.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/context.rs @@ -8,7 +8,6 @@ use mesa_rust_gen::pipe_fd_type::*; use mesa_rust_gen::*; use mesa_rust_util::has_required_feature; -use std::mem::size_of; use std::os::raw::*; use std::ptr; use std::ptr::*; diff --git a/src/gallium/frontends/rusticl/util/serialize.rs b/src/gallium/frontends/rusticl/util/serialize.rs index 8d9c688c5d3..370f3cb5b54 100644 --- a/src/gallium/frontends/rusticl/util/serialize.rs +++ b/src/gallium/frontends/rusticl/util/serialize.rs @@ -6,6 +6,6 @@ /// T must not contain any uninitialized bytes such as padding. #[inline] pub unsafe fn as_byte_slice(t: &[T]) -> &[u8] { - let new_len = core::mem::size_of_val(t) / core::mem::size_of::(); + let new_len = size_of_val(t) / size_of::(); unsafe { core::slice::from_raw_parts(t.as_ptr().cast(), new_len) } }