digitalmars.D.learn - Can we rely on LDC respecting "align" (for avx) ??
- james.p.leblanc (17/17) Sep 07 2021 Dear All,
Dear All, In searching through the forum archives (going back to 2013, 2016 etc), and experiments, it **appears to me** that LDC does indeed respect the standard "align" properties. (Meaning: proper alignment for using AVX with static arrays can be guaranteed). Experiments (and forum discussions) also lead me to believe that DMD does NOT respect this alignment. So, what is the "official status" of AVX alignment possibilities? Succinctly: 1) Can we truly rely on LDC's alignment for AVX ? 2) Is DMD presently **not** respecting alignment? (Or have I misunderstood?) This has important impact on performance of numerical computations. Thanks for all illumination! James
Sep 07 2021
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc wrote:Dear All, In searching through the forum archives (going back to 2013, 2016 etc), and experiments, it **appears to me** that LDC does indeed respect the standard "align" properties. (Meaning: proper alignment for using AVX with static arrays can be guaranteed). Experiments (and forum discussions) also lead me to believe that DMD does NOT respect this alignment. So, what is the "official status" of AVX alignment possibilities? Succinctly: 1) Can we truly rely on LDC's alignment for AVX ? 2) Is DMD presently **not** respecting alignment? (Or have I misunderstood?) This has important impact on performance of numerical computations. Thanks for all illumination! JamesYes you are correct (to my understanding) DMD only respects `align` keyword upto the value 16,ie, until `align(16)`, the code behaves the way you expect it to. It is 100% a bug(don't have the link on me right now) Try the following code on DMD, then LDC. See for yourself ```d import std.stdio:writeln; void main() { align(16) int[100] a; align(1024) int[100] b; writeln(cast(ulong)&a[0] % 16); writeln(cast(ulong)&b[0] % 1024); } ```
Sep 07 2021
On Wednesday, 8 September 2021 at 04:43:31 UTC, Tejas wrote:On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc wrote:Here's the link: https://issues.dlang.org/show_bug.cgi?id=16098[...]Yes you are correct (to my understanding) DMD only respects `align` keyword upto the value 16,ie, until `align(16)`, the code behaves the way you expect it to. It is 100% a bug(don't have the link on me right now) Try the following code on DMD, then LDC. See for yourself ```d import std.stdio:writeln; void main() { align(16) int[100] a; align(1024) int[100] b; writeln(cast(ulong)&a[0] % 16); writeln(cast(ulong)&b[0] % 1024); } ```
Sep 07 2021
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc wrote:1) Can we truly rely on LDC's alignment for AVX ?Yes. If you find wrong alignment, it's a bug. -Johan
Sep 08 2021