Skip to main content

ReductionScalar

Trait ReductionScalar 

Source
pub trait ReductionScalar:
    Copy
    + Send
    + Sync
    + Debug
    + Default
    + 'static {
    // Required methods
    fn identity(op: ReductionOp) -> Self;
    fn combine(a: Self, b: Self, op: ReductionOp) -> Self;
    fn cuda_type() -> &'static str;
    fn wgsl_type() -> &'static str;

    // Provided method
    fn size_bytes() -> usize { ... }
}
Expand description

Trait for scalar types that support reduction operations.

Implementors must provide identity values for each reduction operation. The identity value is the neutral element such that op(x, identity) = x.

Required Methods§

Source

fn identity(op: ReductionOp) -> Self

Get the identity value for the given reduction operation.

Source

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Combine two values according to the reduction operation.

Source

fn cuda_type() -> &'static str

CUDA type name for code generation.

Source

fn wgsl_type() -> &'static str

WGSL type name for code generation.

Provided Methods§

Source

fn size_bytes() -> usize

Size in bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ReductionScalar for f32

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Source§

impl ReductionScalar for f64

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Source§

impl ReductionScalar for i32

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Source§

impl ReductionScalar for i64

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Source§

impl ReductionScalar for u32

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Source§

impl ReductionScalar for u64

Source§

fn identity(op: ReductionOp) -> Self

Source§

fn combine(a: Self, b: Self, op: ReductionOp) -> Self

Source§

fn cuda_type() -> &'static str

Source§

fn wgsl_type() -> &'static str

Implementors§