A perspective on abstracting SIMD that emphasizes how to expose intrinsics seems like its lost in the weeds. Is there anything like ISPC for Rust? One of the critical features of ISPC is language support for transforming arrays-of-structs (AoS) to structs-of-arrays (SoA). You can define, declare, and reference your data structures as you normally would, e.g.
struct { float x, y, x } arr[100]
which is easier to grok and maintain, but the internal memory layout transparently becomes more like
When such semantics are provided by the language itself, the need to resort to explicit SIMD intrinsics (directly or indirectly via API abstractions) is tremendously reduced as most of the biggest impediments to auto-vectorization are lifted. ISPC also provides complementing language features for managing parallel control flow, e.g. conditional masking, that significantly obviates much of the remaining use cases for explicit SIMD procedures.
camel-cdr · 25m ago
Since you can trivially build a SoA container type with C++ templates, I assume the same is possible in Rust.
raphlinus · 3h ago
There's a new game in town for portable, multiversioned Rust SIMD: fearless_simd. It's still early days (we're gearing up for an 0.2 release soon), but we are using it very successfully to accelerate rendering algorithms in vello_cpu and vello_hybrid. I believe it represents the best compromise on stable Rust today. We're not saying it's ready for production use yet, but I encourage people exploring this space to try it and give us feedback on how well it works.
There's also a big discussion to be had about how the Rust language might more natively support SIMD. There are some hacks in fearless_simd to work around limitations in the language (especially relying on inlining as load-bearing), and it would be excellent to make that more robust. But the best path forward is not obvious.
When such semantics are provided by the language itself, the need to resort to explicit SIMD intrinsics (directly or indirectly via API abstractions) is tremendously reduced as most of the biggest impediments to auto-vectorization are lifted. ISPC also provides complementing language features for managing parallel control flow, e.g. conditional masking, that significantly obviates much of the remaining use cases for explicit SIMD procedures.
There's also a big discussion to be had about how the Rust language might more natively support SIMD. There are some hacks in fearless_simd to work around limitations in the language (especially relying on inlining as load-bearing), and it would be excellent to make that more robust. But the best path forward is not obvious.
[1] https://github.com/linebender/fearless_simd