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

Đang mở
#3,118 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
32/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, rust
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Cuda
Star
902
Fork
267
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
57

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/cuvs

Tất cả issue của NVIDIA/cuvs

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.