[FEA] Add MPSC/MPMC concurrent queue
メンテナーはふだん 2 日以内に返信
@sleeepyjack がすでに取り組んでいます。
2026年1月22日 から。
評価
この issue はまだ評価されていません。
説明
Disclaimer: Work in progress. Community input is appreciated to refine the feature details and requirements.
Overview
We want a cuco::queue data structure implementing producer-consumer data exchange inspired by an
internal prototype that supports GPU producers and flexible consumers.
The prototype implementation provides a multiple producer single consumer (MPSC) queue with a
notifier abstraction ("doorbell") that batches submissions efficiently on the producer side and
can be adapted to different notification mechanisms.
The core ideas are:
- A circular queue layout as a linear array in memory
- A queue control block with atomic head and tail
- Device side push operations that reserve slots and write entries
- A notifier (doorbell) that aggregates submissions so consumers can observe progress efficiently
The doorbell concept is a small state machine that tracks the next visible position and allows
producers to publish contiguous ranges while consumers poll or wait on progress updates.
This concept can be used to optimize for different message passing scenarios listed below.
Potential message passing scenarios:
- GPU to CPU (already implemented in the prototype)
- GPU to GPU (NVLink or network)
- CTA to CTA (via global memory)
- Warp to warp (via shared memory for warp specialized workloads)
Goals
- Provide a cuco queue API with owning and non-owning reference types.
- Provide MPSC as the first supported mode with a clear path to MPMC.
- Provide doorbell/notifier policies that batch submissions efficiently for different message passing scenarios.
- Support device side push and pop plus host side bulk or polling operations.
- Keep storage layout and control layout explicit and allocator driven.
Proposed API surface
namespace cuco {
enum class queue_mode { mpsc, mpmc };
struct queue_policy {
static constexpr queue_mode mode = queue_mode::mpsc;
static constexpr cuda::thread_scope scope = cuda::thread_scope_device;
using notifier = cuco::queue_notifier::thread;
};
template <class T,
class Policy = cuco::queue_policy,
class Allocator = cuco::cuda_allocator<cuda::std::byte>>
class queue;
template <class T,
class Policy = cuco::queue_policy>
class queue_ref;
} // namespace cuco
Queue and storage construction and refs
queue_storage<T, Policy> storage(...)owning storage classqueue_storage_ref<T, Policy> storage_ref(...)non-owning storage classqueue(size_type capacity, cuda_thread_scope<Policy::scope> = {}, Policy const& = {}, Allocator = {}, cuda::stream_ref = {})queue_ref<T, Policy> queue_ref(queue_storage_ref<T, Policy> const& storage)
Device side operations (queue_ref)
__device__ bool try_push(T const& value)template <class CG> __device__ bool try_push(CG group, T const& value)group-cooperative push (cooperative slot reservation)__device__ bool try_pop(T& out)template <class CG> __device__ bool try_pop(CG group, T& out)__device__ void push(T const& value)blocking pushtemplate <class CG> __device__ void push(CG group, T const& value)__device__ T pop()template <class CG> __device__ T pop(CG group)
Host side operations (queue)
size_type pop_bulk(OutputIt out, size_type max_items, cuda::stream_ref)size_type pop_bulk_async(OutputIt out, size_type max_items, cuda::stream_ref)void wait(size_type min_items, cuda::stream_ref)wait formin_itemsto be availablevoid wait_async(size_type min_items, cuda::stream_ref)
Policy and notifier
queue_policy bundles behavior that affects concurrency semantics and notification strategy:
modeselects MPSC or MPMC behavior.scopeselects the CUDA thread scope for atomics.notifierselects how producers publish progress to consumers (the doorbell).
Potential constraints and risks
- The prototype uses
length - 1usable entries to avoid notifier overflow. This affects capacity
semantics and should be surfaced in cuco docs or compensated by an internal padding slot. - The prototype uses busy wait and nanosleep in alloc and ring; host side polling should allow
configurable backoff to avoid CPU spin. - The prototype notifier assumes contiguous submission, which may be harder in MPMC pops where
multiple consumers race. We need to decide whether MPMC uses a different notifier policy
or an alternative pop algorithm. - The prototype
bitmapnotifier uses a bitmap sized to queue length. For large queues this
may add memory overhead. Consider a chunked bitmap or compile time policy selection. - The prototype uses custom
umemallocators and device types. cuco must map this to its allocator
and memory resource model.
Open questions
- Looking for more use cases and scenarios.
- Should MPMC be in scope for the first version, or do we ship MPSC first and extend later.
- Should the notifier policy be user facing or hidden behind template defaults.
- 主要言語
- Cuda
- スター
- 674
- フォーク
- 123
- 平均マージ
- 4日 19時間
- マージ済み PR(30日)
- 10
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/cuCollections のほかの issue
-
Add cuco::detail::stream_sync(cuda::stream_ref) to centralize CCCL version-specific API naming再び着手できるかも @0z5a が 27 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NVIDIA/cuCollections#840 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
nvidia-runners
難易度 1/5 1〜3時間 初心者へのやさしさ 25/100
NVIDIA/cuCollections#853 ·
メンテナーはふだん 2 日以内に返信
-
topic: performance type: feature request
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
NVIDIA/cuCollections#817 · コメント 7 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
good first issue P2: Nice to have type: improvement
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
NVIDIA/cuCollections#805 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
-
good first issue helps: rapids P1: Should have topic: performance type: improvement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
NVIDIA/cuCollections#785 · コメント 5 件 ·
メンテナーはふだん 2 日以内に返信