digitalmars.D.ldc - portably determine HW SIMD width
- Bruce Carneal (6/6) Aug 27 2020 With dmd you can import core.simd and use a static if/else ladder
- kinke (4/4) Aug 27 2020 If x86 only, the predefined versions might do it -
- kinke (4/4) Aug 27 2020 Argh scratch the AVX2 part, that's still 256 bit. There's no
- Bruce Carneal (3/7) Aug 27 2020 Thanks. I was hoping to avoid the x86 tie-in but it's certainly
With dmd you can import core.simd and use a static if/else ladder of (is(Vector!(T[SomeSize]))) or is(ubytexx) expressions to determine HW SIMD widths. This doesn't work with ldc because ldc is very permissive when it comes to 'SIMD' vector sizes. I like that about LDC in most contexts but here I'm looking for a discriminant rather than an accommodation. Suggestions?
Aug 27 2020
If x86 only, the predefined versions might do it - `version(D_AVX2)` for 512 bit vectors (`-mattr=+avx2`), and D_AVX for 256 bit. There aren't other alternatives at the moment AFAIK; a trait might be a nice addition.
Aug 27 2020
Argh scratch the AVX2 part, that's still 256 bit. There's no `D_AVX512` yet, but you can use something like `__traits(targetHasFeature, "avx512f")` (AVX512 seems to be a mess, not sure what the exact attr is - see `-mattr=help` output).
Aug 27 2020
On Friday, 28 August 2020 at 00:19:12 UTC, kinke wrote:If x86 only, the predefined versions might do it - `version(D_AVX2)` for 512 bit vectors (`-mattr=+avx2`), and D_AVX for 256 bit. There aren't other alternatives at the moment AFAIK; a trait might be a nice addition.Thanks. I was hoping to avoid the x86 tie-in but it's certainly better than nothing.
Aug 27 2020