From 54b37078ebf491e21b313885bb31232ca9a40a7e Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 22 Aug 2023 21:17:33 +0200 Subject: [PATCH] rusticl: add debug option to sync every event Part-of: --- docs/envvars.rst | 1 + src/gallium/frontends/rusticl/core/platform.rs | 3 +++ src/gallium/frontends/rusticl/core/queue.rs | 10 +++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/envvars.rst b/docs/envvars.rst index 4ec1fd7..2c30e57 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -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: diff --git a/src/gallium/frontends/rusticl/core/platform.rs b/src/gallium/frontends/rusticl/core/platform.rs index 7b2080e..24f60f2 100644 --- a/src/gallium/frontends/rusticl/core/platform.rs +++ b/src/gallium/frontends/rusticl/core/platform.rs @@ -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), } } diff --git a/src/gallium/frontends/rusticl/core/queue.rs b/src/gallium/frontends/rusticl/core/queue.rs index 22d37aa..934ffc8 100644 --- a/src/gallium/frontends/rusticl/core/queue.rs +++ b/src/gallium/frontends/rusticl/core/queue.rs @@ -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); } } -- 2.7.4