rusticl/platform: add perf debug option
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30324>
This commit is contained in:
@@ -1119,6 +1119,8 @@ Rusticl environment variables
|
|||||||
|
|
||||||
- ``allow_invalid_spirv`` disables validation of any input SPIR-V
|
- ``allow_invalid_spirv`` disables validation of any input SPIR-V
|
||||||
- ``clc`` dumps all OpenCL C source being compiled
|
- ``clc`` dumps all OpenCL C source being compiled
|
||||||
|
- ``perf`` prints a warning when hitting slow paths once
|
||||||
|
- ``perfspam`` same as perf, but doesn't skip same warnings
|
||||||
- ``program`` dumps compilation logs to stderr
|
- ``program`` dumps compilation logs to stderr
|
||||||
- ``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
|
||||||
|
@@ -17,9 +17,16 @@ pub struct Platform {
|
|||||||
pub devs: Vec<Device>,
|
pub devs: Vec<Device>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum PerfDebugLevel {
|
||||||
|
None,
|
||||||
|
Once,
|
||||||
|
Spam,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PlatformDebug {
|
pub struct PlatformDebug {
|
||||||
pub allow_invalid_spirv: bool,
|
pub allow_invalid_spirv: bool,
|
||||||
pub clc: bool,
|
pub clc: bool,
|
||||||
|
pub perf: PerfDebugLevel,
|
||||||
pub program: bool,
|
pub program: bool,
|
||||||
pub max_grid_size: u64,
|
pub max_grid_size: u64,
|
||||||
pub sync_every_event: bool,
|
pub sync_every_event: bool,
|
||||||
@@ -66,6 +73,7 @@ static mut PLATFORM: Platform = Platform {
|
|||||||
static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
|
static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
|
||||||
allow_invalid_spirv: false,
|
allow_invalid_spirv: false,
|
||||||
clc: false,
|
clc: false,
|
||||||
|
perf: PerfDebugLevel::None,
|
||||||
program: false,
|
program: false,
|
||||||
max_grid_size: 0,
|
max_grid_size: 0,
|
||||||
sync_every_event: false,
|
sync_every_event: false,
|
||||||
@@ -84,6 +92,8 @@ fn load_env() {
|
|||||||
match flag {
|
match flag {
|
||||||
"allow_invalid_spirv" => debug.allow_invalid_spirv = true,
|
"allow_invalid_spirv" => debug.allow_invalid_spirv = true,
|
||||||
"clc" => debug.clc = true,
|
"clc" => debug.clc = true,
|
||||||
|
"perf" => debug.perf = PerfDebugLevel::Once,
|
||||||
|
"perfspam" => debug.perf = PerfDebugLevel::Spam,
|
||||||
"program" => debug.program = true,
|
"program" => debug.program = true,
|
||||||
"sync" => debug.sync_every_event = true,
|
"sync" => debug.sync_every_event = true,
|
||||||
"validate" => debug.validate_spirv = true,
|
"validate" => debug.validate_spirv = true,
|
||||||
@@ -169,3 +179,23 @@ impl GetPlatformRef for cl_platform_id {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! perf_warning {
|
||||||
|
(@PRINT $format:tt, $($arg:tt)*) => {
|
||||||
|
eprintln!(std::concat!("=== Rusticl perf warning: ", $format, " ==="), $($arg)*)
|
||||||
|
};
|
||||||
|
|
||||||
|
($format:tt $(, $arg:tt)*) => {
|
||||||
|
match $crate::core::platform::Platform::dbg().perf {
|
||||||
|
$crate::core::platform::PerfDebugLevel::Once => {
|
||||||
|
static PERF_WARN_ONCE: std::sync::Once = std::sync::Once::new();
|
||||||
|
PERF_WARN_ONCE.call_once(|| {
|
||||||
|
perf_warning!(@PRINT $format, $($arg)*);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
$crate::core::platform::PerfDebugLevel::Spam => perf_warning!(@PRINT $format, $($arg)*),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user