Skip to main content

Module pipeline

Module pipeline 

Source
Expand description

Multi-stream pipeline pattern.

Lets users wire Source -> KernelStage -> ... -> Sink such that stage K+1 begins as soon as stage K’s GPU work is complete, with cross-stage handoff via [cudarc::driver::CudaEvent] — no host roundtrip between stages.

§Stage shape

Implement PipelineStage for any kernel-actor adapter:

struct BlasSgemmStage { /* ... */ }
impl PipelineStage for BlasSgemmStage {
    type In = (GpuRef<f32>, GpuRef<f32>);
    type Out = GpuRef<f32>;
    fn enqueue(
        &mut self, stream, wait_for, (a, b)
    ) -> Result<(CudaEvent, GpuRef<f32>), GpuError> {
        if let Some(ev) = wait_for { stream.wait(ev)?; }
        /* enqueue cuBLAS gemm via record-mode contract */
        let ev = stream.record_event(None)?;
        Ok((ev, c))
    }
}

F2 ships the trait + a thin executor; the full PipelineBuilder<I, O> type-state DSL with Source / Sink wrappers lands in F3 once we have more concrete patterns demanding it.

Structs§

PipelineExecutor
Two-stage type-state executor — the simplest non-trivial chain.
PipelineExecutorN
N-stage heterogeneous executor.
PipelineSink
Producer end. submit blocks (awaits) when the channel is full — that’s the backpressure signal.
PipelineSource
Consumer end. Returns a ReceiverStream<Result<O, GpuError>> that yields one item per processed input.
StageBox
Adapter wrapping any typed PipelineStage into a BoxedStage.

Traits§

BoxedStage
Heterogeneous N-stage executor.
PipelineStage
One stage in a multi-stream GPU pipeline.

Functions§

run_pipeline
Run a homogeneous sequence of stages on streams[i] for stage i.
spawn_pipeline
Spawn a backpressured async pipeline driver around an executor. Returns (PipelineSink<I>, PipelineSource<O>). The driver runs on the ambient tokio runtime.