[FEA]Expose a pooled pinned host memory resource in the C API

Aperta
#3,118 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, rust
Ambito
api

Direzione di ricerca

Start from the existing host allocation pair cuvsRMMHostAlloc / cuvsRMMHostFree in the C API and from the device-side cuvsRMMPoolMemoryResourceEnable, which is the pattern to copy for the new Enable/Disable functions. Then read the regenerated Rust bindings in cuvs-sys (bindings.rs). Done means the two new functions exist, the alloc/free calls route through a mutex-protected process-wide pinned pool when enabled, and the default path is unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature request

Is your feature request related to a problem? Please describe.
In C++, pinned host memory can be pooled by composing RMM resources
(pool_memory_resource over pinned_host_memory_resource). The C API has no equivalent. It only
offers cuvsRMMHostAlloc / cuvsRMMHostFree, which bypass any pool and perform one cudaMallocHost /
cudaFreeHost per call. Callers that reach cuVS through the C API, including the language bindings
(Rust, Python, Go, Java), cannot get a pinned host pool, and must register memory themselves or write
their own allocator.

The device side already exposes a pooled resource through cuvsRMMPoolMemoryResourceEnable. This
proposes the host-side counterpart.

Describe the solution you'd like
Add a process-wide pinned host pool to the C API:

cuvsError_t cuvsRMMPinnedHostPoolEnable(size_t pool_size_bytes);
cuvsError_t cuvsRMMPinnedHostPoolDisable();
  • cuvsRMMPinnedHostPoolEnable(pool_size_bytes) creates one pool_memory_resource over
    pinned_host_memory_resource, with initial size == maximum size, so the pinning cost is paid once, up
    front.
  • While the pool is enabled, cuvsRMMHostAlloc / cuvsRMMHostFree use it. If the pool is exhausted,
    cuvsRMMHostAlloc returns an error and does not fall back silently, so the caller decides what to do.
  • The pool is held process-wide (mutex-protected) rather than thread_local. A pool is stateful, so a
    per-thread pool would multiply the pinned memory by the number of threads, and memory freed on a
    different thread than the one that allocated it would be returned to the wrong pool.
  • With the pool disabled (the default), behaviour is unchanged: one cudaMallocHost per call.

Regenerated Rust bindings in cuvs-sys (bindings.rs).

Because the pool is opt-in, these costs only apply to callers that enable it:

  • Pinning cost. Enable pins the whole pool up front, which we measured at about 0.3 s per GiB, so the
    pool should be sized to the peak amount in use at once.

Describe alternatives you've considered

  • Change cuvsRMMHostAlloc internally, with no new function. The caller then cannot choose the pool
    size, and existing callers would start holding pinned memory for the life of the process. We prefer an
    explicit opt-in function.
  • Expose the C++ API only. C API users and the bindings still cannot reach it.

Additional context
We have a working patch (C API + Rust bindings) and will open a new PR.

Lingua principale
Cuda
Stelle
902
Fork
267
Merge medio
2g 21h
PR unite (30g)
57

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cuvs

Tutte le issue di NVIDIA/cuvs

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.