Skip to main content

tensor_wasm_mem/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Craton Software Company
3
4//! CUDA Unified Memory allocator and Wasmtime `MemoryCreator` integration.
5//!
6//! Two byte-buffer types:
7//! - [`unified::UnifiedBuffer`] — CUDA Unified Memory when the
8//!   `unified-memory` feature is enabled; a heap buffer otherwise.
9//! - [`pinned_host::GuardedHostBuffer`] — guarded host memory for the
10//!   explicit-fallback path used by `cargo build --no-default-features`.
11//!   On all hosts the buffer is bracketed by `PROT_NONE` / `PAGE_NOACCESS`
12//!   guard pages catching OOB reads/writes at the OS level. The managed
13//!   memory path (`UnifiedBuffer` on CUDA hosts) still cannot use guard
14//!   pages — that limitation is unchanged. The previous name
15//!   `PinnedHostBuffer` is preserved as a deprecated alias.
16//!
17//! Pools (`pool::UnifiedMemoryPool`) amortise the cost of CUDA allocations
18//! by carving sub-slices from a single slab. Hints (`advise`) forward to
19//! `cudaMemAdvise` on CUDA hosts and are no-ops otherwise.
20#![deny(missing_docs)]
21
22pub mod advise;
23#[cfg(feature = "cudarc-backend")]
24pub mod cuda_mem_pool;
25#[cfg(feature = "cuda-oxide-backend")]
26pub mod cuda_oxide_backend;
27#[cfg(feature = "cudarc-backend")]
28pub mod cudarc_backend;
29pub mod isolation;
30#[cfg(feature = "mock-cuda")]
31pub mod mock_cuda;
32pub mod pinned_host;
33pub mod pool;
34pub mod unified;
35pub mod wasm_memory;