News for hackers. Stuff that matters.
Re:How much memory bandwidth do large Amazon instances offer? by gavinray on Friday January 19, 2024 @02:07PM (#39059631)
Note that you can get a significant speedup by using "restrict" on the pointer in the "sum()" function to tell the compiler that there is no mutation or aliasing happening during the call's lifetime.

On Godbolt, with a size of 100MB (due to limits), this improves the speed using LLVM 17 (https://godbolt.org/z/6dW1h8aev) from:

  1 15.1 
  2 15.9 
To (https://godbolt.org/z/sh3489Mxv)

  1 12.8 
  2 13.7
Re:How much memory bandwidth do large Amazon instances offer? by scode2 on Friday January 19, 2024 @03:26PM (#39060622)
Isn't higher better?
Re:How much memory bandwidth do large Amazon instances offer? by d0mine on Friday January 19, 2024 @04:59PM (#39061831)
Re:How much memory bandwidth do large Amazon instances offer? by LegionMammal978 on Friday January 19, 2024 @08:35PM (#39063752)
That __restrict isn't useful to the compiler in this function, since it can already infer that there is no mutation from the access patterns: it's a leaf function with only non-atomic reads and no writes. (It's mostly only useful when you interleave reading from one pointer with writing to another with the same type, or when you call an opaque function before reading from a pointer.) Indeed, if you look at the generated assembly, the two are identical. The timing differences are likely random variation.