Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 28, 2020 portably determine HW SIMD width | ||||
---|---|---|---|---|
| ||||
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 Re: portably determine HW SIMD width | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruce Carneal | 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 Re: portably determine HW SIMD width | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | 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 Re: portably determine HW SIMD width | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | 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.
|
Copyright © 1999-2021 by the D Language Foundation