Skip to main content

ReductionHandle

Trait ReductionHandle 

pub trait ReductionHandle<T>: Send + Sync
where T: ReductionScalar,
{ // Required methods fn device_ptr(&self) -> u64; fn reset(&self) -> Result<(), RingKernelError>; fn read(&self) -> Result<T, RingKernelError>; fn read_combined(&self) -> Result<T, RingKernelError>; fn sync_and_read(&self) -> Result<T, RingKernelError>; fn op(&self) -> ReductionOp; fn num_slots(&self) -> usize; }
Expand description

Handle to a reduction buffer for streaming operations.

This trait abstracts over backend-specific reduction buffer implementations, allowing the same code to work with CUDA, WebGPU, or CPU backends.

Required Methods§

fn device_ptr(&self) -> u64

Get device pointer for kernel parameter passing.

fn reset(&self) -> Result<(), RingKernelError>

Reset buffer to identity value.

fn read(&self) -> Result<T, RingKernelError>

Read the current reduction result from slot 0.

fn read_combined(&self) -> Result<T, RingKernelError>

Read and combine all slots into a single result.

fn sync_and_read(&self) -> Result<T, RingKernelError>

Synchronize device and read result.

Ensures all GPU operations complete before reading.

fn op(&self) -> ReductionOp

Get the reduction operation type.

fn num_slots(&self) -> usize

Get number of slots.

Implementors§