Community
cancel
Showing results for
Did you mean: Beginner
89 Views

## Alternative to dgemm(A', A, B) which only calculates upper/lower triangular matrix? (CBLAS)

I need to calculate a matrix crossproduct of the form B = A' * A; This results in a symmetric matrix B, so it should be possible to have the multiplication only calculate the upper or lower triangular matrix B and flip it to fill the second half, thereby saving 50% of the calculation time. However I cannot find a method/option which does this.

I have tried manually implementing this calculation, by multiplying row vectors/blocks of A' by A and storing these in the corresponding blocks of B, however depending on the block size the overhead due to multiple calls can even lead to a decrease in performance (very small blocks) or a gain in performance < 50%.

Alternatively, what would the optimal block size be to reduce the overhead in multiple calls, and spinning up threads? Is any information available on how the algorithm partitions the data into multiple threads internally?
1 Solution Employee
89 Views
Hello Henrik,

Could you please check whether the DSYRK function in MKL BLASwill work for you? Here is an excerpt from the MKL Reference Manual:

The ?syrk routines perform a matrix-matrix operation using symmetric matrices. The operation is defined as

C := alpha*A*A' + beta*C,

or

C := alpha*A'*A + beta*C

Thank you,
Efe

3 Replies Employee
90 Views
Hello Henrik,

Could you please check whether the DSYRK function in MKL BLASwill work for you? Here is an excerpt from the MKL Reference Manual:

The ?syrk routines perform a matrix-matrix operation using symmetric matrices. The operation is defined as

C := alpha*A*A' + beta*C,

or

C := alpha*A'*A + beta*C

Thank you,
Efe Beginner
89 Views
Thank you, that is exactly what I was looking for. When I had looked at the overview of all functions I had stopped reading the function description when it mentioned "symmetric matrices", and did not notice that the first argument did not have to be symmetric. Employee
89 Views
You're right,the documentationcould be more descriptive. Thank you for the input. 