Disclaimer: this is not a fully fleshed out idea, mostly filing this to see if this is potentially interesting and worth me thinking about in more detail, or if it's out of scope.
fearless_simd itself has a proc macro to run a test function over all SIMD levels. I'm feeling the same need in my hacking as a user of fearless_simd, and ended up implementing a few similar macros.
Maybe fearless_simd should provide some "public" test helper macros for this kind of thing? Doesn't really block 1.0 since it's just convenience, but could be nice for developer UX. The helpers I would find helpful personally:
- Something like the current
#[simd_test], instantiate a function for each SIMD level with appropriate skipping when unsupported on the test runner.
- Run a fn once for each SIMD vector type, with optional filtering by scalar type and overall vector width, e.g.
#[simd_vector_test(type(u8, u16, u32, u64), width(256, 512))].
The second one is useful in tests for implementing additional operations that are generic over some subset of vectors (e.g. bitpacking/unpacking in my code, generic over 512-bit integer vector types). Both are useful for writing benchmarks, since the performance can change pretty drastically depending on types and simd level.
In both cases ideally the macro wouldn't force the annotated function to be a test, so that benchmarks etc. can also be done. Some of this can also be done with declarative macros, but IDEs struggle with code inside such macro bodies. Attr proc macros give better ergonomics on that front.
This definitely needs more fleshing out for the exact syntax of the macros, what they support/don't support, what shape gives users enough flexibility, ... I'm willing to prototype and iterate on that if it sounds interesting.
Disclaimer: this is not a fully fleshed out idea, mostly filing this to see if this is potentially interesting and worth me thinking about in more detail, or if it's out of scope.
fearless_simd itself has a proc macro to run a test function over all SIMD levels. I'm feeling the same need in my hacking as a user of fearless_simd, and ended up implementing a few similar macros.
Maybe fearless_simd should provide some "public" test helper macros for this kind of thing? Doesn't really block 1.0 since it's just convenience, but could be nice for developer UX. The helpers I would find helpful personally:
#[simd_test], instantiate a function for each SIMD level with appropriate skipping when unsupported on the test runner.#[simd_vector_test(type(u8, u16, u32, u64), width(256, 512))].The second one is useful in tests for implementing additional operations that are generic over some subset of vectors (e.g. bitpacking/unpacking in my code, generic over 512-bit integer vector types). Both are useful for writing benchmarks, since the performance can change pretty drastically depending on types and simd level.
In both cases ideally the macro wouldn't force the annotated function to be a test, so that benchmarks etc. can also be done. Some of this can also be done with declarative macros, but IDEs struggle with code inside such macro bodies. Attr proc macros give better ergonomics on that front.
This definitely needs more fleshing out for the exact syntax of the macros, what they support/don't support, what shape gives users enough flexibility, ... I'm willing to prototype and iterate on that if it sounds interesting.