Resources Module

View as Markdown

Rust module: cuvs::resources

Source: rust/cuvs/src/resources.rs

GPU resource management with RAII semantics.

ResourcesError

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ResourcesError {
/* variants omitted */
}

Error type for resource operations.

Source: rust/cuvs/src/resources.rs:19

Resources

#[derive(Debug)]
pub struct Resources {
/* private fields */
}

Resources are objects that are shared between function calls, and includes things like CUDA streams, cuBLAS handles and other resources that are expensive to create.

Methods

NameSource
newrust/cuvs/src/resources.rs:38
with_memory_trackingrust/cuvs/src/resources.rs:55
with_streamrust/cuvs/src/resources.rs:82
streamrust/cuvs/src/resources.rs:91
sync_streamrust/cuvs/src/resources.rs:100

new

pub fn new() -> Result<Resources>

Creates a new resources handle bound to the current CUDA device.

Source: rust/cuvs/src/resources.rs:38

with_memory_tracking

pub fn with_memory_tracking(
csv_path: impl AsRef<Path>,
sample_interval: Option<Duration>,
) -> Result<Resources>

Returns a new Resources object whose memory allocations are tracked and written as CSV samples to csv_path from a background thread.

The handle wraps all reachable memory resources (host, pinned, managed, device, workspace, large_workspace) with allocation-tracking adaptors and replaces the global host and device memory resources for the lifetime of the handle. The CSV reporter is stopped and the global memory resources are restored when the handle is dropped.

sample_interval controls the minimum time between successive CSV samples; when None, the C++ default of 10 ms is used.

Source: rust/cuvs/src/resources.rs:55

with_stream

pub unsafe fn with_stream(stream: ffi::cudaStream_t) -> Result<Resources>

Creates a resources handle that enqueues work on stream instead of the default internal stream.

The stream is bound once, at construction.

Safety

stream must be a valid CUDA stream for the current device and must remain valid for as long as this handle uses it.

Source: rust/cuvs/src/resources.rs:82

stream

pub fn stream(&self) -> Result<ffi::cudaStream_t>

Returns the current CUDA stream associated with this handle.

Source: rust/cuvs/src/resources.rs:91

sync_stream

pub fn sync_stream(&self) -> Result<()>

Blocks until all operations on the current CUDA stream have completed.

Source: rust/cuvs/src/resources.rs:100

Source: rust/cuvs/src/resources.rs:32