pub trait KernelTrace:
Send
+ Sync
+ 'static {
// Provided methods
fn before_enqueue(&self, info: &KernelInfo<'_>) { ... }
fn after_enqueue(
&self,
info: &KernelInfo<'_>,
result: Result<(), &GpuError>,
) { ... }
fn before_complete(&self, info: &KernelInfo<'_>) { ... }
fn after_complete(
&self,
info: &KernelInfo<'_>,
result: Result<(), &GpuError>,
latency: Duration,
) { ... }
}Expand description
Lifecycle hook receiver. All four methods have empty default bodies, so a custom trace can override only the events it cares about.
The trait is always compiled; no feature flag is required. When no
trace is attached to a KernelEnvelope, the envelope skips every
call and adds zero runtime cost beyond a single Option::is_some
check (which the optimizer typically folds away).
Provided Methods§
Sourcefn before_enqueue(&self, info: &KernelInfo<'_>)
fn before_enqueue(&self, info: &KernelInfo<'_>)
Fires immediately before the synchronous enqueue closure runs.
Sourcefn after_enqueue(&self, info: &KernelInfo<'_>, result: Result<(), &GpuError>)
fn after_enqueue(&self, info: &KernelInfo<'_>, result: Result<(), &GpuError>)
Fires immediately after the synchronous enqueue closure
returns. result is Ok(()) on success or Err(&GpuError) if
the enqueue body failed.
Sourcefn before_complete(&self, info: &KernelInfo<'_>)
fn before_complete(&self, info: &KernelInfo<'_>)
Fires just before the completion future is awaited (i.e. after a successful enqueue, on the spawned Tokio task).
Sourcefn after_complete(
&self,
info: &KernelInfo<'_>,
result: Result<(), &GpuError>,
latency: Duration,
)
fn after_complete( &self, info: &KernelInfo<'_>, result: Result<(), &GpuError>, latency: Duration, )
Fires after the completion future resolves. latency is the
wall-clock duration between before_complete and the resolved
completion (i.e. host-observed completion latency, not GPU
time).