2 ms·
Nate, first of all, thank you for your detailed responses. I really appreciate it! Second, your suggestion to use fma instruction for dot product is great - th
by p1esk 10y ago
Nate, first of all, thank you for your detailed responses. I really appreciate it!
Second, your suggestion to use fma instruction for dot product is great - the code is both simpler and much faster. I wasted some time trying to run the code on my work computer, where it compiled fine, however exited without any output. Turned out that CPU is Ivy Bridge and doesn't support AVX2. So it seems that compiling with -mfma will convince the compiler to use non-existing instructions, regardless of the architecture.
I'm now wondering if I should upgrade GCC on my Ubuntu box - the default was 4.8, which I upgraded to 4.9, however, the latest is 6.2. Is there a reason they keep it so old?
Anyway, Agner guide to optimization is pretty interesting, lots of stuff to learn. My naive original code when compiled with Ofast and march=native is still faster than my AVX code compiled without any optimizations, but hopefully one day that will be able to beat it!