numr 0.6.0-beta.1

High-performance numerical computing with multi-backend GPU acceleration (CPU/CUDA/WebGPU)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Shared parsing helpers for CUDA runtime tuning environment variables.

/// Resolve a byte-valued tuning knob from an environment variable whose value is
/// expressed in MiB, falling back to `default_bytes` when unset or unparseable.
///
/// Used by the allocator (free-list cap) and the client (memory-pool release
/// threshold) so the MiB→bytes conversion lives in exactly one place.
pub(super) fn env_mib_to_bytes(var: &str, default_bytes: u64) -> u64 {
    std::env::var(var)
        .ok()
        .and_then(|s| s.trim().parse::<u64>().ok())
        .map(|mib| mib.saturating_mul(1024 * 1024))
        .unwrap_or(default_bytes)
}