Thread overview
portably determine HW SIMD width
Aug 28, 2020
Bruce Carneal
Aug 28, 2020
kinke
Aug 28, 2020
kinke
Aug 28, 2020
Bruce Carneal
August 28, 2020
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?




August 28, 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.
August 28, 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).
August 28, 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.