Module: Mesa
Branch: main
Commit: 6052e58bf6ad1f36fa88974c5b4218df1154aa0c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6052e58bf6ad1f36fa88974c5b4218df1154aa0c

Author: Dr. David Alan Gilbert <[email protected]>
Date:   Thu Jul  6 01:52:06 2023 +0100

rusticl/core: Add profiling time storage (queued) to event

Add the first, of a few, profiling time values to the Event,
with access methods.  This is defined as

   'when the command identified by event is enqueued in a command-queue
    by the host'

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24101>

---

 src/gallium/frontends/rusticl/core/event.rs | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/gallium/frontends/rusticl/core/event.rs 
b/src/gallium/frontends/rusticl/core/event.rs
index 879e99a8373..34310fb47d4 100644
--- a/src/gallium/frontends/rusticl/core/event.rs
+++ b/src/gallium/frontends/rusticl/core/event.rs
@@ -25,10 +25,16 @@ static_assert!(CL_QUEUED == 3);
 
 pub type EventSig = Box<dyn Fn(&Arc<Queue>, &PipeContext) -> CLResult<()>>;
 
+pub enum EventTimes {
+    Queued = CL_PROFILING_COMMAND_QUEUED as isize,
+}
+
+#[derive(Default)]
 struct EventMutState {
     status: cl_int,
     cbs: [Vec<(EventCB, *mut c_void)>; 3],
     work: Option<EventSig>,
+    time_queued: cl_ulong,
 }
 
 pub struct Event {
@@ -62,8 +68,8 @@ impl Event {
             deps: deps,
             state: Mutex::new(EventMutState {
                 status: CL_QUEUED as cl_int,
-                cbs: [Vec::new(), Vec::new(), Vec::new()],
                 work: Some(work),
+                ..Default::default()
             }),
             cv: Condvar::new(),
         })
@@ -78,8 +84,7 @@ impl Event {
             deps: Vec::new(),
             state: Mutex::new(EventMutState {
                 status: CL_SUBMITTED as cl_int,
-                cbs: [Vec::new(), Vec::new(), Vec::new()],
-                work: None,
+                ..Default::default()
             }),
             cv: Condvar::new(),
         })
@@ -127,6 +132,21 @@ impl Event {
         self.cmd_type == CL_COMMAND_USER
     }
 
+    pub fn set_time(&self, which: EventTimes, value: cl_ulong) {
+        let mut lock = self.state();
+        match which {
+            EventTimes::Queued => lock.time_queued = value,
+        }
+    }
+
+    pub fn get_time(&self, which: EventTimes) -> cl_ulong {
+        let lock = self.state();
+
+        match which {
+            EventTimes::Queued => lock.time_queued,
+        }
+    }
+
     pub fn add_cb(&self, state: cl_int, cb: EventCB, data: *mut c_void) {
         let mut lock = self.state();
         let status = lock.status;

Reply via email to