SIMD under LDC

Igor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 11 14:22:44 PDT 2017


On Monday, 11 September 2017 at 11:55:45 UTC, Igor wrote:
>
> In the meantime can anyone tell me how to add an attribute to a 
> function only if something is defined, since this doesn't work:
>
> version(USE_SIMD_WITH_LDC) {
>   import ldc.attributes;
>   @target("ssse3")
> } void funcThatUsesSIMD() {
>   ...
>   version(LDC) {
>     import ldc.gccbuiltins_x86;
>     c = __builtin_ia32_pshufb128(c, *simdMasks);
>   } else {
>     c = __simd(XMM.PSHUFB, c, *simdMasks);
>   }
>   ...
> }

Regarding the crash in debug mode the problem was that my masks 
variable wasn't properly aligned and I guess the best I can do 
with the attribute is this:

version(LDC) import ldc.attributes;
else private struct target { string specifier; }
@target("ssse3")
void funcThatUsesSIMD() {...}


More information about the Digitalmars-d-learn mailing list