Skip to main content

ReductionScalar

Trait ReductionScalar 

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§

fn identity(op: ReductionOp) -> Self

Get the identity value for the given reduction operation.

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

Combine two values according to the reduction operation.

fn cuda_type() -> &'static str

CUDA type name for code generation.

fn wgsl_type() -> &'static str

WGSL type name for code generation.

Provided Methods§

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§

§

impl ReductionScalar for f32

§

fn identity(op: ReductionOp) -> f32

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

§

impl ReductionScalar for f64

§

fn identity(op: ReductionOp) -> f64

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

§

impl ReductionScalar for i32

§

fn identity(op: ReductionOp) -> i32

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

§

impl ReductionScalar for i64

§

fn identity(op: ReductionOp) -> i64

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

§

impl ReductionScalar for u32

§

fn identity(op: ReductionOp) -> u32

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

§

impl ReductionScalar for u64

§

fn identity(op: ReductionOp) -> u64

§

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

§

fn cuda_type() -> &'static str

§

fn wgsl_type() -> &'static str

Implementors§