rusticl: add debug option to sync every event
authorKarol Herbst <git@karolherbst.de>
Tue, 22 Aug 2023 19:17:33 +0000 (21:17 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Aug 2023 12:03:28 +0000 (12:03 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24868>

docs/envvars.rst
src/gallium/frontends/rusticl/core/platform.rs
src/gallium/frontends/rusticl/core/queue.rs

index 4ec1fd7..2c30e57 100644 (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:
 
index 7b2080e..24f60f2 100644 (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),
             }
         }
index 22d37aa..934ffc8 100644 (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);
                             }
                         }