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

オープン
#3,118 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
32/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, rust
領域
api

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Cuda
スター
902
フォーク
267
平均マージ
2日 21時間
マージ済み PR(30日)
57

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/cuvs のほかの issue

NVIDIA/cuvs の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。