Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6621 Discussions

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

woshiwuxin
Novice
108 Views
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!
0 Kudos
2 Replies
Konstantin_A_Intel
108 Views
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
Novice
108 Views
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.
Reply