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.

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!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today