rusticl: add RUSTICL_MAX_WORK_GROUPS

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27666>
This commit is contained in:
Karol Herbst
2023-12-18 23:06:11 +01:00
committed by Marge Bot
parent 91552bb4ec
commit 6bcc300e00
3 changed files with 19 additions and 2 deletions

View File

@@ -1085,6 +1085,11 @@ Rusticl environment variables
- ``sync`` waits on the GPU to complete after every event - ``sync`` waits on the GPU to complete after every event
- ``validate`` validates any internally generated SPIR-Vs, e.g. through compiling OpenCL C code - ``validate`` validates any internally generated SPIR-Vs, e.g. through compiling OpenCL C code
.. envvar:: RUSTICL_MAX_WORK_GROUPS
Limits the amount of threads per dimension in a work-group. Useful for splitting up long running
tasks to increase responsiveness or to simulate the lowering of huge global sizes for testing.
.. _clc-env-var: .. _clc-env-var:
clc environment variables clc environment variables

View File

@@ -893,8 +893,13 @@ impl Device {
} }
pub fn max_grid_size(&self) -> Vec<u64> { pub fn max_grid_size(&self) -> Vec<u64> {
self.screen let v: Vec<u64> = self
.compute_param(pipe_compute_cap::PIPE_COMPUTE_CAP_MAX_GRID_SIZE) .screen
.compute_param(pipe_compute_cap::PIPE_COMPUTE_CAP_MAX_GRID_SIZE);
v.into_iter()
.map(|a| min(a, Platform::dbg().max_grid_size))
.collect()
} }
pub fn max_clock_freq(&self) -> cl_uint { pub fn max_clock_freq(&self) -> cl_uint {

View File

@@ -21,6 +21,7 @@ pub struct PlatformDebug {
pub allow_invalid_spirv: bool, pub allow_invalid_spirv: bool,
pub clc: bool, pub clc: bool,
pub program: bool, pub program: bool,
pub max_grid_size: u64,
pub sync_every_event: bool, pub sync_every_event: bool,
pub validate_spirv: bool, pub validate_spirv: bool,
} }
@@ -66,6 +67,7 @@ static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
allow_invalid_spirv: false, allow_invalid_spirv: false,
clc: false, clc: false,
program: false, program: false,
max_grid_size: 0,
sync_every_event: false, sync_every_event: false,
validate_spirv: false, validate_spirv: false,
}; };
@@ -91,6 +93,11 @@ fn load_env() {
} }
} }
debug.max_grid_size = env::var("RUSTICL_MAX_WORK_GROUPS")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(u64::MAX);
// SAFETY: no other references exist at this point // SAFETY: no other references exist at this point
let features = unsafe { &mut *addr_of_mut!(PLATFORM_FEATURES) }; let features = unsafe { &mut *addr_of_mut!(PLATFORM_FEATURES) };
if let Ok(feature_flags) = env::var("RUSTICL_FEATURES") { if let Ok(feature_flags) = env::var("RUSTICL_FEATURES") {