Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Per-actor *Dispatch traits + their *DispatchCtx bundles (Phase 0.3).

Each kernel actor (cuBLAS, cuBLASLt, cuDNN, cuFFT, cuRAND, cuSOLVER, cuSPARSE, cuTENSOR, NCCL, NVRTC) eventually exposes a typed public API like:

blas_actor.tell(BlasMsg::gemm::<f16>(GemmRequest { ... }));

Internally, the request is boxed as Box<dyn GemmDispatch> and the actor’s handle loop calls dispatch(self, &ctx) which carries the cuBLAS handle, stream, and completion strategy. This avoids the N-fold (op × dtype) variant explosion in the actor’s Msg enum without giving up typed GpuRef<T> requests on the public API.

§Status

In Phase 0.3 only NVRTC actually adopts the pattern: see NvrtcLaunchDispatch + NvrtcDispatchCtx and the migrated NvrtcActor. The remaining actor traits (GemmDispatch, BlasLtDispatch, …) ship as stub trait declarations with *DispatchCtx<'a> placeholder structs whose handle fields are PhantomData until the matching actor migrates in a follow-up PR (per the migration order in the Phase 0 plan).

The shared kernel-arg traits (DevSliceArg, ScalarArg) collapse the per-dtype KernelArg::DevSlice* / KernelArg::Scalar* variants into a single boxed-dyn pair plus a literal Usize(usize) variant.

Re-exports§

pub use crate::kernel::solver::SolverDispatch;

Structs§

BlasDispatchCtx
Bundle of resources every cuBLAS dispatcher needs to run an op.
BlasLtDispatchCtx
Per-call context handed to a BlasLtDispatch::dispatch impl.
CollectiveDispatchCtx
Per-call context handed to a CollectiveDispatch::dispatch impl. Carries the NCCL communicator (cudarc wraps it) plus the device state and completion strategy.
CudnnDispatchCtx
CudnnDispatch is owned by kernel::cudnn (Phase 2 cuDNN). Re-exported here for symmetry with other actors’ dispatch traits. Context handed to a CudnnDispatch::dispatch call.
FftDispatchCtx
Per-execution context bundle handed to every FftDispatch::dispatch. The actor packs its current stream + completion strategy + plan handle (already resolved against the LRU cache) so dispatch impls stay lean.
NvrtcDispatchCtx
Per-launch context bundle for NvrtcLaunchDispatch::dispatch.
SendSparseHandle
Phase 4 cuSPARSE handle wrapper. Raw pointer is !Send by default; cuSPARSE is thread-safe per-handle as long as a given handle is only touched by one stream at a time (the actor-per-handle invariant).
SparseDispatchCtx
Per-call context handed to a SparseDispatch::dispatch impl.
TensorDispatchCtx
TensorDispatch is owned by kernel::tensor (Phase 2 cuTENSOR).
WorkspacePool
TensorDispatch is owned by kernel::tensor (Phase 2 cuTENSOR).

Enums§

DispatchDType
Alias used by the NCCL CollectiveDispatch (Phase 2). Maps onto the canonical atomr_accel::DType. Compact discriminant for AccelDtype::KIND.
SparseOp
Op-kind tag a SparseDispatch exposes.

Traits§

BlasL1Dispatch
Erased L1 ops: axpy, dot, nrm2, scal, asum, iamax, iamin, copy, swap, rot.
BlasL2Dispatch
Erased L2 ops: gemv, ger.
BlasL3Dispatch
Erased L3 ops other than gemm: geam, syrk, trsm.
BlasLtDispatch
Boxed-dispatch trait the cuBLASLt actor uses to call into a typed MatmulRequest<T> after type-erasing it through the mailbox.
CollectiveDispatch
Boxed-dispatch trait for NCCL collectives. The CollectiveActor handles the message envelope; each typed request struct (e.g. AllReduceRequest<T: NcclReduceSupported>) implements this so the actor stays single-mailbox while the dtype dimension travels in the box.
CudnnDispatch
CudnnDispatch is owned by kernel::cudnn (Phase 2 cuDNN). Re-exported here for symmetry with other actors’ dispatch traits. Dispatch trait for typed cuDNN ops.
DevSliceArg
Type-erased typed-device-slice argument for an NVRTC kernel launch.
FftDispatch
Dispatch trait for typed cuFFT requests (FftRequest<T> for T: FftSupported).
GemmDispatch
Erased GemmRequest<T>. Implementors live in kernel::blas::gemm.
GemmStridedBatchedDispatch
Erased GemmStridedBatchedRequest<T>.
NvrtcLaunchDispatch
Boxed-dispatch trait for an NVRTC kernel launch request.
RngDispatch
Erased payload accepted by RngActor via RngMsg::Fill.
ScalarArg
Type-erased typed-host-scalar argument for an NVRTC kernel launch.
SparseDispatch
Box-erased cuSPARSE op (Phase 4).
TensorDispatch
TensorDispatch is owned by kernel::tensor (Phase 2 cuTENSOR).

Functions§

reply_unsupported

Type Aliases§

GemmDispatchCtx
GemmDispatchCtx is now an alias for BlasDispatchCtx (the cuBLAS agent unified the per-op contexts since every cuBLAS dispatcher needs the same set: cuBLAS handle, stream, completion, state).