rusticl: use div_ceil

It got stabilized with 1.73

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30414>
This commit is contained in:
Karol Herbst 2024-07-29 16:00:29 +02:00 committed by Marge Bot
parent cc37ecc7ba
commit fb82c253da
3 changed files with 7 additions and 22 deletions

View file

@ -1293,9 +1293,9 @@ impl Kernel {
.map(|val| cmp::min(val, u32::MAX as usize))
.collect();
for z in 0..div_round_up(grid[2], hw_max_grid[2]) {
for y in 0..div_round_up(grid[1], hw_max_grid[1]) {
for x in 0..div_round_up(grid[0], hw_max_grid[0]) {
for z in 0..grid[2].div_ceil(hw_max_grid[2]) {
for y in 0..grid[1].div_ceil(hw_max_grid[1]) {
for x in 0..grid[0].div_ceil(hw_max_grid[0]) {
if let Some(workgroup_id_offset_loc) = workgroup_id_offset_loc {
let this_offsets =
[x * hw_max_grid[0], y * hw_max_grid[1], z * hw_max_grid[2]];
@ -1479,8 +1479,8 @@ impl Kernel {
return 0;
}
let threads = block.iter().product();
div_round_up(threads, subgroup_size)
let threads: usize = block.iter().product();
threads.div_ceil(subgroup_size)
}
pub fn subgroup_size_for_block(&self, dev: &Device, block: &[usize]) -> usize {

View file

@ -16,7 +16,6 @@ use mesa_rust::pipe::resource::*;
use mesa_rust::pipe::screen::ResourceType;
use mesa_rust::pipe::transfer::*;
use mesa_rust_gen::*;
use mesa_rust_util::math::*;
use mesa_rust_util::properties::Properties;
use mesa_rust_util::ptr::AllocSize;
use mesa_rust_util::ptr::TrackedPointers;
@ -1271,8 +1270,8 @@ impl Image {
// make sure we allocate multiples of 4 bytes so drivers don't read out of bounds or
// unaligned.
// TODO: use div_ceil once it's available
let pixel_size = self.image_format.pixel_size().unwrap().into();
let mut new_pattern: Vec<u32> = vec![0; div_round_up(pixel_size, size_of::<u32>())];
let pixel_size: usize = self.image_format.pixel_size().unwrap().into();
let mut new_pattern: Vec<u32> = vec![0; pixel_size.div_ceil(size_of::<u32>())];
// we don't support CL_DEPTH for now
assert!(pattern.len() == 4);

View file

@ -1,5 +1,4 @@
use std::ops::Add;
use std::ops::Div;
use std::ops::Rem;
use std::ops::Sub;
@ -35,19 +34,6 @@ where
}
}
pub fn div_round_up<T>(a: T, b: T) -> T
where
T: Copy,
T: Add<Output = T>,
T: Div<Output = T>,
T: Sub<Output = T>,
{
#[allow(clippy::eq_op)]
let one = b / b;
(a + b - one) / b
}
pub struct SetBitIndices<T> {
val: T,
}