-
Notifications
You must be signed in to change notification settings - Fork 21
Description
There's a proof-of-concept safe_wrappers feature that's supposed to let you use your own custom architecture-specific SIMD code if you want to, by obtaining an architecture-specific SIMD token from Level using as_neon, as_avx2, etc.
This isn't the ideal abstraction for a couple reasons:
- You need to pass the
Levelall the way down into every SIMD function you use. - The
as_[platform]methods onLevelincur a runtime cost. When a SIMD-using function calls some method on theSimdtoken it's passed, that token's type is statically known, because it's a type parameter.Level, however, is always an enum.
I think #108 starts to move in a different direction, but it creates a lot of autogenerated code, is not fully implemented (WASM is missing), and doesn't actually tie into fearless_simd as implemented. It also seems to have stalled out.
In the meantime, I propose adding as_[platform] methods on the Simd trait itself. The default method implementations would all return None, and individual implementations (Sse4_2, Neon, etc.) could override specific methods to all return Some(self). This means we don't need to pass down the Level, and the new as_[platform] methods would be statically dispatched.