Why some parallel functions scale well with the number of cores, but the others are not.

Why some parallel functions scale well with the number of cores, but the others are not.

woshiwuxin's picture

Hi, everyone! I noticed that some parallel functions in MKL scale well with the number of cores. For example, ?gemm can be 2x if I setup two threads on two cores, and 6x if six threads on six cores. But some others, e.g. ?gemv, ?syev etc, scale less good with the number of cores. Why it is that? Thanks in advance!

CPU: Intel Core 2 Duo 2.4 GHz OS: Mac OS X 10.5.8 Linux: Debian 5.0 x86_64 Compiler: Intel Fortran Compiler 11.1 & Intel C++ Compiler 11.1 (with Intel MKL included)
3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Konstantin Arturov (Intel)'s picture

Hi, thank you for good question!

You're right, the scalability may vary depending on the algorithm the function implements.

For example, let's compare ?gemm vs. ?gemv for square NxN matrices and N vector:

gemmshould load3*N*N elements (matrices A, B and C) and perform ~2*N*N*N add/mul operations.
On the other hand, gemv should load N*N+2*N (matrix A and vectors X, Y), but perform ~2*N*N operations.

So, ?gemv is memory-limited operation (having not alldata in cache) and its perfromance depends more on the throughput of memory subsystem than on the number of cores.

Regards,
Konstantin

woshiwuxin's picture

Thank you very much! To summarize, the compute-to-memory ratio in ?gemm is 2*N/3. If N is infinite, the ratio is 2 in ?gemv. Thus, ?gemm is compute bound, and ?gemv is bandwidth bound.

CPU: Intel Core 2 Duo 2.4 GHz OS: Mac OS X 10.5.8 Linux: Debian 5.0 x86_64 Compiler: Intel Fortran Compiler 11.1 & Intel C++ Compiler 11.1 (with Intel MKL included)

Login to leave a comment.