rusticl: add debug option to sync every event

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24868>
This commit is contained in:
Karol Herbst 2023-08-22 21:17:33 +02:00 committed by Marge Bot
parent 43fe842b92
commit 54b37078eb
3 changed files with 11 additions and 3 deletions

View file

@ -1009,6 +1009,7 @@ Rusticl environment variables
- ``allow_invalid_spirv`` disables validation of any input SPIR-V
- ``clc`` dumps all OpenCL C source being compiled
- ``program`` dumps compilation logs to stderr
- ``sync`` waits on the GPU to complete after every event
.. _clc-env-var:

View file

@ -20,6 +20,7 @@ pub struct PlatformDebug {
pub allow_invalid_spirv: bool,
pub clc: bool,
pub program: bool,
pub sync_every_event: bool,
}
pub struct PlatformFeatures {
@ -62,6 +63,7 @@ static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
allow_invalid_spirv: false,
clc: false,
program: false,
sync_every_event: false,
};
static mut PLATFORM_FEATURES: PlatformFeatures = PlatformFeatures {
fp16: false,
@ -76,6 +78,7 @@ fn load_env() {
"allow_invalid_spirv" => debug.allow_invalid_spirv = true,
"clc" => debug.clc = true,
"program" => debug.program = true,
"sync" => debug.sync_every_event = true,
_ => eprintln!("Unknown RUSTICL_DEBUG flag found: {}", flag),
}
}

View file

@ -2,6 +2,7 @@ use crate::api::icd::*;
use crate::core::context::*;
use crate::core::device::*;
use crate::core::event::*;
use crate::core::platform::*;
use crate::impl_cl_type_trait;
use mesa_rust::pipe::context::PipeContext;
@ -96,9 +97,7 @@ impl Queue {
e.call(&pipe);
if !e.is_user() {
flushed.push(e);
} else {
if e.is_user() {
// On each user event we flush our events as application might
// wait on them before signaling user events.
flush_events(&mut flushed, &pipe);
@ -106,6 +105,11 @@ impl Queue {
// Wait on user events as they are synchronization points in the
// application's control.
e.wait();
} else if Platform::dbg().sync_every_event {
flushed.push(e);
flush_events(&mut flushed, &pipe);
} else {
flushed.push(e);
}
}