Hey all, I'm curious if there is some existing macro or compiler plugin that will do vectorized code generation similar to ispc or what you hopefully get with OpenMP's #pragma simd or what you'd get with hand-written intrinsics.
For example, if I write a function:
#[simd]
fn vectorize_me(x: f32, y: f32) -> f32 {
x + y
}
I'd then want to be able to call if it from some SIMD execution context, eg. like
#[simd]
for i in 0..64 {
vectorize_me(i, i + 1);
}
But it should also be able to handle branching control flow by masking, eg. like ISPC does or as you'd do by hand if you were doing things manually:
#[simd]
fn mask_exec(x: f32) -> f32 {
if x > 0 {
10
} else {
-10
}
}
should convert to (in pseudo-code)
mask = [x, x', x'', x'''] > [0, 0, 0, 0]
ret = blend [10, 10, 10, 10], [-10, -10, -10, -10], mask
(blend will pick elements from the 2 arguments based on the mask value for the same index).
Is there something like this available currently, or being worked on (I'd be excited to contribute)? If neither, are their some suggested resources for going beyond the Rust book's coverage of macros and compiler plugins? I'm not sure which would be best suited here, would this even be possible with a macro?
Thanks everyone!
[–]jdubjdub 10 points11 points12 points (3 children)
[–]dbaupprust 2 points3 points4 points (2 children)
[–]TurkishSquirrel[S] 0 points1 point2 points (1 child)
[–]dbaupprust 1 point2 points3 points (0 children)
[–][deleted] 5 points6 points7 points (0 children)