Discussion:
[eigen] GSoC 2018 Project "Faster Matrix Algebra for ATLAS" - Multiplication of Hermitian Matrices in Eigen
David Tellenbach
2018-08-06 01:05:19 UTC
Permalink
Hello together,

I am writing you to share some new results of our Google Summer of Code 2018
project that aims to implement support for hermitian matrices in Eigen.

We are currently in the third and last phase of the Summer of Code and managed
to implement the most important and most complicated part: Matrix multiplication.

Generally we distinguish four different cases for building a product of the form
Lhs * Rhs that involves hermitian matrices:

1. Lhs is dense, Rhs is hermitian -> Assignment to dense matrix
2. Lhs is dense, Rhs is hermitian -> Assignment to dense matrix
3. Lhs is hermitian, Rhs is hermitian -> Assignment to dense matrix
4. Lhs is hermitian, Rhs is hermitian -> Assignment to hermitian matrix

Case 4. is useful when you know in advance that the resulting product will be again
hermitian. This is the case if and only if the matrix product commutates, i.e., if

Lhs * Rhs = Rhs * Lhs.

3. covers the more general case of the product of two hermitian matrices.

Implementation:

The cases 1.-3. basically work by assigning the hermitian matrix to a dense matrix
and performing dense multiplication.

Case 4. works differently. As suggested by members of this mailing list, we store
hermitian matrices in so called Rectangular Full Packed Format (RFPF). See

https://software.intel.com/en-us/mkl-developer-reference-c-matrix-storage-schemes-for-lapack-routines <https://software.intel.com/en-us/mkl-developer-reference-c-matrix-storage-schemes-for-lapack-routines>

for further information about this storage scheme.

Benchmarks:

Now the interesting part: How do the four cases above perform compared to their
dense counterparts?

Attached to this email you find two graphics that show four different benchmarks
using Google's benchmark suite (https://github.com/google/benchmark <https://github.com/google/benchmark>)

The first one shows the following operations for fixed sized matrices:

1. hermitian * dense = dense
2. dense * hermitian = dense
3. dense * dense = dense

The second one shows the above operations for dynamically sized matrices.

The next benchmark shows a comparison of the following operations

1. hermitian * hermitian = dense
2. hermitian * hermitian = hermitian

The last benchmark shows the above operations for dynamically sized matrices.

The implementation detail can be found here:

https://bitbucket.org/tellenbach/eigen/src/HermitianMatrix/ <https://bitbucket.org/tellenbach/eigen/src/HermitianMatrix/>

As always we would be very happy about some feedback.

All the best,
David

Loading...