I recently started working with a 7250 Xeon Phi Knights Landing (KNL) 7250 computer ( http://ark.intel.com/products/94035/Intel-Xeon-Phi-Processor-7250-16GB-1_40-GHz-68-core ) .
It has 68 cores and an AVX 512. The base frequency is 1.4 GHz and the Turbo Frequency is 1.6 GHz. I do not know what the turbocharging frequency is for all cores, because, as a rule, the turbocharging frequency is quoted for only one core.
Each core for Knights Knights can perform two 8-cycle FMA operations per cycle. Since each FMA operation consists of two floating point operations, double floating point operations per cycle per core are 32.
Therefore, the maximum GFLOPS is 32*68*1.4 = 3046.4 DP GFLOPS
.
For one core, the peak FLOPS is 32*1.6 = 51.2 DP GLOPS
.
Dense matrix multiplication is one of the few operations that are actually capable of approaching peak outliers. Intel MKL library provides optimized dense matrix multiplication functions. On Sandy Bridge systems, I got over 97% of peak FLOPS with DGEMM. At Haswell, I got about 90% of the peak when I checked a few years ago, so it was clearly harder to get the peak with FMA at that time. However, with Knights Landing and MKL I get much less than 50% of the peak.
I modified the dgemm_example.c
file in the MKL sample directory to calculate GFLOPS using 2.0*1E-9*n*n*n/time
(see below).
I also tried export KMP_AFFINITY=scatter
and export OMP_NUM_THREADS=68
, but that doesn't seem to matter much. However, KMP_AFFINITY=compact
much slower and therefore OMP_NUM_THREADS=1
, so the default thread topology seems to be scattered all the same and the threads work.
The best GFLOPS I've seen are around 1301 GFLOPS, which is about 43% of the peak. For one thread, I saw 38 GFLOPS, which is about 74% of the peak. This suggests that MKL DGEMM is optimized for the AVX512, otherwise it will see less than 50%. On the other hand, for one thread, I think I should get 90% of the peak.
KNL memory can work in three modes (cached, flat and hybrid), which can be installed from the BIOS ( http://www.anandtech.com/show/9794/a-few-notes-on-intels-knights-landing- and-mcdram-modes-from-sc15 ). I do not know in what mode my (or rather, my work) KNL system works. Could this affect DGEMM?
My question is: why is the FLOPS from DGEMM so low, and what can I do to improve it? Perhaps I did not configure MKL optimally (I am using ICC 17.0).
source /opt/intel/mkl/bin/mklvars.sh intel64 icc -O3 -mkl dgemm_example.c
Here is the code
#define min(x,y) (((x) < (y)) ? (x) : (y))