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

Is it possible to access sub-matrices?

Deleted_U_Intel
Employee
701 Views
I'm evaluating the MKL for a fastconvolution implementation. Basically I haveone big (800x600) matrix from which I have to cut out small (5x5) sub-matrices which are then further used for multiplication whith a second (fix) matrix.
In the manual I didn't find any function which would allowslicing from an existing matrix. Any hint how MKL can be used for this kind of problem?
0 Kudos
2 Replies
Intel_C_Intel
Employee
702 Views
Are you seeking to use something like dgemm on the 5x5 submatrices to multiply onto the second matrix? While this could certainly be done, you would likely be unhappy with the results because this is a pretty small operation count to use with dgemm.
With more information we might be able to address this question better.
--Bruce
0 Kudos
Intel_C_Intel
Employee
702 Views

All of the BLAS functions were designed with to be used in linear algebra applications. One of the most widely used applications for dgemm is in the update of a matrix which is being factored. A single matrix has a set of rows and columns which have been factored and those factored sections are then used to "update" the rest of the matrix in an operation: C = C - A*B, where A and B are the factored portions of the matrix, C is the balance of the matrix.

There are three 6 numerical parameters that are crucial to the function of dgemm (ignoring, for the moment, the scaling values alpha and beta. If we assume we are performing an operation like C = A*B (I will use Fortran matrix storage nomenclature), the dimensions of portion of A that will be multiplied are m rows and k columns. The dimensions of the portion of B that will be multiplied are k rows and n columns and that leaves that portion of C which will receive the results as having m rows and n columns.

Where the operations will begin for each of the 3 matrices depends on the address of each matrix passed to dgemm, such as C(13, 4), for instance. But dgemm must also know the size of the overall matrices in which A, B, and C are located so there are the parameters lda, ldb, and ldc which, for Fortran, are the number of rows in the underlying matrices.

Returning to the factorization example, let's assume that we are factoring 32 columns at a time and that we have factored the first 32 columns/rows. Furthermore, let's assume that there are 1000 equations and the matrix has 1000 rows. Then, the first call to dgemm would look like this (we are going to perform C = C - A*B). Let us call the matrix A.

call dgemm( 'n', 'n', 968, 968, 32, -1.0, A(33, 1), 1000, A(1, 33), 1000, 1.0, A(33, 33), 1000 )

So this will multiply a submatrix 968 rows long by 32 columns wide times a submatrix 32 rows long by 968 columns wide and subtract it from a matrix 968 rows long by 968 columns wide, all within a matrix with 1000 rows.
Bruce
0 Kudos
Reply