Skip to content

Support for SIMD types  #80

@ralfbiedert

Description

@ralfbiedert

I am creating a library where I would like to abstract math over scalar (f32) or packed SIMD types (f32x8) as defined in RFC 2366.

For example, I would like to express:

fn kernel<F>(a: F, b: F) -> F
where
    F: Float,
{
    (a - b) * (a - b)
}

And then call either kernel(1.0, 2.0) or kernel(f32x8::splat(1.0), f32x8::splat(2.0)), depending on what data structure I am operating with.

As part of that I was looking into num-traits, in particular I was about to create a num-packed crate, that implements Num & friends for RFC 2366 packed types.

The problem, however, is that many traits such as Integer, Float, Signed, ... not only provide f(Self) -> Self mathematical functions, but also f(Self) -> bool utilities, such as is_even or integer_decode, which do not directly make sense anymore.

Two questions:

  • Do you think it would be feasible to either split out these utility functions into separate traits, or generalize them to be compatible with packed types?
  • More generally, does num-packed make sense as an addition to num, or am I on the wrong path?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions