How to achieve 4 flops per cycle?
stackoverflow.com
stackoverflow.com
It is important to note that the SO discussion is focused on achieving peak flops when the data is already in the XMM registers. The real bottleneck is pushing the data quickly through the levels of the memory hierarchy.
I was surprised by how little low-level knowledge it took to get within a stone's throw of the theoretical peak.
The general rule seems to be:
- keep data in packed registers (use YMM instead of XMM if you have them)
- interleave addition and multiplication
- unroll the loop sufficiently to avoid stalls
I wonder if how close to ATLAS you could get if you wrote a matrix multiply following these principles and additionally structured the row/column iterations into cache-sized tiles.
Figure 2 and 3 in this paper (http://cran.r-project.org/web/packages/gcbd/vignettes/gcbd.p...) show atlas is only better than an unoptimized ("reference") BLAS implementation and that it is many times slower than the winner GotoBLAS (now OpenBLAS http://xianyi.github.com/OpenBLAS/), which is written assembly by Kazushige Goto while he worked at the Texas Advanced Computing Center.
Edit: Article in the NY Times about Mr. Goto http://www.nytimes.com/2005/11/28/technology/28super.html?sc...
CPUs are very capable today, unfortunately, to get 'every last drop of performance' is very difficult.
I'd say that CPUs are more complex than compilers can optimize the code for them.
Of course, manually optimizing for something like this is "easy" (if you have a somewhat deep knowledge of Intel's manuals)
Now for "everyday computing" this gets tougher, even though compilers do a good job (good, not great) and it's usually good enough.
So you end up going to the deeper details in time-sensitive things: games, video processing, etc
There are some tools (from Intel and AMD, even though I tested only the AMD one some time ago) that tells you 'everything' that you need to know about how good your code is. For example, IIRC, if you load a register then immediately store to it (or store then load, I don't remember), there's a stall, so you can do something else in between
By this part:
"If you decide to compile and run this, pay attention to your CPU temperatures!!! Make sure you don't overheat it. And make sure CPU-throttling doesn't affect your results!"
Fair enough for the CPU throttling.
But did the nineties just call? Computers dying due to CPU overheating was all scary and spooky back when we were running old AMDs and old Pentium CPUs but I haven't own any CPU that could die due to overheating since a very, very long time. They do automagically throttle to: a) make sure they stay within their TDP specs b) make sure they don't melt.
I mean: honestly, scientists should start to worry about overheating their CPU that are going to melt?
I don't think with modern CPUs that this is a problem, but you would have to test to find out!
You probably have, CPUs are just smarter about it now, and throttle themselves back:
http://www.intel.com/content/www/us/en/architecture-and-tech...
If you have a densely packed blade farm, you could easily exceed the cooling capacity within the rack. Another scenario is laptops.
My officemate is working with some neural networks researchers, trying to get near-peak throughput running convolutional neural networks on NVIDIA's new K20 GPUs. Several GPUs have already died and they're looking for better cooling for the rest. So, I don't know if peak utilization of multi-core CPUs can still be hazardous, but it's definitely true for graphics cards.