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

Summary statistics and padding

Peter_B_9
Beginner
331 Views

When using matrices in MKL, I'm careful to align my columns as recommended by Intel for maximum throughput (this seems to be particularly important on the Intel Xeon Phi). MKL's BLAS interface makes it easy to deal with matrices with padded columns,  since the number of rows and the size of the leading dimension are always specified separately. For example, I can specify that my matrix has 1021 rows, but that the leading dimension is 1024.

However I can't figure out how to do this with the summary statistics functions. I want to calculate a correlation matrix from the columns of a (column-major) matrix with padding in each column.

Do I have to use an indices array with all but the last few elements set to 1? This seems inconvenient and inefficient. What if I want padding in the correlation matrix?

 

0 Kudos
3 Replies
Zhang_Z_Intel
Employee
332 Views

The matrix passed to a summary statistics routine is packed as a one-dimensional array. You don't need to pad each column or row to make its starting address aligned against certain boundary. For performance considerations, you only need to make sure the starting address of the entire matrix lies on the boundary of, say 64-byte, boundaries. Matrix arguments in BLAS are also passed in the form of one-dimensional arrays. The concept of leading dimensions is more about facilitating the handling of sub-matrices than about performance.

0 Kudos
Peter_B_9
Beginner
332 Views

Hi Zhang, thanks for the information. This seems like a significant limitation. The BLAS approach has several advantages: for example, it's very easy to select a subset of a BLAS matrix by adjusting the size of the leading dimension. I hope that Intel considers enhancing VSL to support padding in a future version. (I note that NAG's statistics functions do support an explicit leading dimension.)

0 Kudos
Zhang_Z_Intel
Employee
332 Views

Peter, Thanks for your suggestion. I see some NAG statistic functions do take a 'stride' argument for the matrix it operates on. One example is function 'nag_corr_cov' (http://www.nag.com/numeric/CL/nagdoc_cl23/html/G02/g02bxc.html). Is this what you have in mind? If so, I can put in a feature request to MKL VSL.

Thanks!

 

0 Kudos
Reply