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

Looking for example of blocked multiply using GEMM

AndrewC
New Contributor III
1,067 Views
I need to multiply two large non-square matrices that will not fit in memory. The result is a square matrix that will fit in memory. I am looking for sample code that shows how to do a blocked matrix multiply. I note this from Wikipedia.

"By decomposing one or both of the input matrices into block matrices, GEMM can be used repeatedly on the smaller blocks to build up a result for the full matrix. This is one of the motivations for including the parameter, so the results of previous blocks can be accumulated"
Googling has not turned up anything so far....


0 Kudos
5 Replies
Basden__Alastair
Beginner
1,067 Views
There is an example in Numerical recipes which does this - the computational load is better too - N^2.7 rather than N^3.

0 Kudos
AndrewC
New Contributor III
1,067 Views
That would be the third edition , I assume, as I see no reference to blocked matrix multiply in the earlier editions. Do you know if the blocked multiply they implement can handle non-square blocks in the source matrices?
0 Kudos
AndrewC
New Contributor III
1,067 Views
Unfortunately that NR section was not useful at all as they are only talking in the most general terms and do not provide a concrete example.
0 Kudos
AndrewC
New Contributor III
1,067 Views
I found what I needed. Google search for "The Science of Programming Matrix Computations"
0 Kudos
Basden__Alastair
Beginner
1,067 Views
Just incase it helps anyone... Numerical recipes in C second edition, page 102, section heading is "is matrix inversion an N^3 process", and in this section it gives Strassen formula for matrix multiply which is blocked, and also slightly faster than the normal approach.
0 Kudos
Reply