Crate memonitor

Source
Expand description

Memonitor is a lightweight library that allows querying information from various CPU and GPU devices. The main purpose is the ability to query memory related information, like how much local memory a device has and how much is currently available to be allocated.

This is achieved by dynamically loading, if present, various device APIs found in the system, and querying them directly.

§Example

use memonitor::{list_all_devices, list_backends};

// Print every backend that has been found
for backend in list_backends().iter() {
    println!("Backend found: {}", backend.name());
}

// Print every device found from every backend, as well as current memory statistics
for device in list_all_devices().iter() {
    let stats = device.current_memory_stats();
    println!(
        "Device found: {} ({}) - Memory stats: {} bytes used out of {}, {} are free",
        device.name(),
        device.kind(),
        stats.used,
        stats.total,
        stats.available
    );
}

§Features

  • vulkan - enables the Vulkan backend, enabled by default.

Structs§

Backend
High-level abstraction over a backend.
Device
High-level abstraction over a hardware device.
MemoryStats
Memory information of a device at some point in time.
SliceGuard
A type emulating a slice that holds a RwLockReadGuard of the inner context.

Enums§

BackendId
A backend identifier.
DeviceKind
The hardware type of a Device.
GPUKind
The type of a Graphics Card.

Constants§

CPU_NAME
The name of the always present CPU backend.
CUDA_NAME
The name of the Cuda backend.
VULKAN_NAME
The name of the Vulkan backend.

Traits§

BackendHandle
Trait for internal backend handles.
DeviceHandle
Trait for internal device handles.

Functions§

list_all_devices
Returns a slice containing every Device found. Depending on the Backends present, there may be several representations for the same hardware device.
list_backends
Returns a slice containing every Backend found.