Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add {u32,f32,...}xN shorthand types for Simd<{u32,f32,...}, N> #447

Open
ds84182 opened this issue Dec 23, 2024 · 0 comments
Open

Add {u32,f32,...}xN shorthand types for Simd<{u32,f32,...}, N> #447

ds84182 opened this issue Dec 23, 2024 · 0 comments
Labels
C-feature-request Category: a feature request, i.e. not implemented / a PR

Comments

@ds84182
Copy link

ds84182 commented Dec 23, 2024

Shorthand types that are generic over lane count:

type u32xN<const N: usize> = Simd<u32, N>;
type f32xN<const N: usize> = Simd<f32, N>;
type u64xN<const N: usize> = Simd<u64, N>;
type f64xN<const N: usize> = Simd<f64, N>;
// etc.

I've found it easier to write these compared to Simd<u32, N> (which I find quite noisy).

And possibly the inverse, although not as useful(?):

type Tx1<T> = Simd<T, 1>;
type Tx2<T> = Simd<T, 2>;
type Tx4<T> = Simd<T, 4>;
type Tx8<T> = Simd<T, 8>;
// etc.

This would be used in code that is generic over lane count, for example:

fn multiply_add<const N: usize>(x: f32xN<N>, y: f32xN<N>, z: f32xN<N>) -> f32xN<N>
  where LaneCount<N>: SupportedLaneCount
{
  x * y + z
}
@ds84182 ds84182 added the C-feature-request Category: a feature request, i.e. not implemented / a PR label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: a feature request, i.e. not implemented / a PR
Projects
None yet
Development

No branches or pull requests

1 participant