AVX for math code ... avx instructions later disappearing ?

james.p.leblanc james.p.leblanc at gmail.com
Sun Sep 26 19:20:16 UTC 2021


On Sunday, 26 September 2021 at 19:00:54 UTC, kinke wrote:
> On Sunday, 26 September 2021 at 18:08:46 UTC, james.p.leblanc 
> wrote:
>> or even moving the array declarations to before
>> the dot product function, and the avx instructions will 
>> disappear!
>
> That's because the `@fastmath` UDA applies to the next 
> declaration only, which is the `x` array in your 2nd example 
> (where it obviously has no effect). Either use `@fastmath:` 
> with the colon to apply it to the entire scope, or use 
> `-ffast-math` in the LDC cmdline.
>
> Similarly, when moving the function to another module and you 
> don't include that module in the cmdline, it's only imported 
> and not compiled and won't show up in the resulting assembly.
>
> Wrt. stack alignment, there aren't any issues with LDC AFAIK 
> (not limited to 16 or whatever like DMD).

Kinke,

Thanks very much for your response.  There were many issues that I
had been misunderstanding in my attempts.  The provided 
explanation
helped me understand the broader scope of what is happening.

(I never even thought about the @fastmath UDA aspect! ... a bit
embarrassing for me!)  Using the -ffast-math in the LDC
cmdline seems to be a most elegant solution.

Much appreciated!
Regards,
James





More information about the Digitalmars-d-learn mailing list