Skip to main content

ActivitySession

Struct ActivitySession 

Source
pub struct ActivitySession { /* private fields */ }
Expand description

A host-side model of CUPTI’s asynchronous Activity buffer protocol.

The real flow is: the tool registers a requested callback (CUPTI calls it to obtain an empty buffer) and a completed callback (CUPTI calls it to hand back a full buffer for draining), enables one or more CuptiActivityKinds, runs GPU work (which fills buffers), then calls cuptiActivityFlushAll to force any partial buffer to be completed.

This struct reproduces that ownership dance deterministically: record fills the pending buffer, flush (and a full buffer) moves records into the completed queue which ActivitySession::drain empties — modelling the completed-buffer callback delivering records to the tool.

Implementations§

Source§

impl ActivitySession

Source

pub const DEFAULT_BUFFER_CAPACITY: usize = 256

Default per-buffer record capacity, echoing CUPTI’s habit of using a few-MB buffer that holds many fixed-size records.

Source

pub fn new() -> Self

Create an idle session with no kinds enabled and no callbacks set.

Source

pub fn with_buffer_capacity(buffer_capacity: usize) -> Self

Create a session with an explicit per-buffer record capacity.

Source

pub fn register_callbacks(&mut self)

Model cuptiActivityRegisterCallbacks: install the buffer request / complete hooks. Idempotent.

Source

pub fn callbacks_registered(&self) -> bool

Whether buffer callbacks have been registered.

Source

pub fn enable( &mut self, kind: CuptiActivityKind, ) -> Result<(), CuptiActivityError>

Model cuptiActivityEnable(kind): turn a record kind on.

§Errors

CuptiActivityError::CallbacksNotRegistered — CUPTI rejects enabling activity before buffer callbacks exist (there would be nowhere to put the records).

Source

pub fn disable(&mut self, kind: CuptiActivityKind)

Model cuptiActivityDisable(kind): turn a record kind off.

Source

pub fn is_enabled(&self, kind: CuptiActivityKind) -> bool

Whether the given kind is currently enabled.

Source

pub fn enabled_kinds(&self) -> &[CuptiActivityKind]

The set of currently enabled kinds.

Source

pub fn record( &mut self, record: ActivityRecord, ) -> Result<(), CuptiActivityError>

Emit one activity record into the pending buffer.

Models the GPU filling a buffer obtained from the requested callback. If the record’s kind is not enabled it is silently dropped (CUPTI does the same) and counted in ActivitySession::dropped_records.

§Errors
Source

pub fn flush(&mut self) -> Result<usize, CuptiActivityError>

Model cuptiActivityFlushAll: move every pending record into the completed queue, as CUPTI does when it hands a full / forced buffer to the completed callback. Returns the number of records flushed.

§Errors

CuptiActivityError::CallbacksNotRegistered if no callbacks exist — cuptiActivityFlushAll is meaningless without a completed callback to deliver buffers to.

Source

pub fn drain(&mut self) -> Vec<ActivityRecord>

Drain the completed queue, returning all records delivered to the tool since the last drain. Models the tool consuming the completed buffer.

Source

pub fn pending_len(&self) -> usize

Number of records currently waiting in the (un-flushed) pending buffer.

Source

pub fn completed_len(&self) -> usize

Number of records flushed and waiting to be drained.

Source

pub fn dropped_records(&self) -> u64

Count of records dropped because their kind was disabled.

Trait Implementations§

Source§

impl Debug for ActivitySession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActivitySession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more