Re: [eigen] Use Eigen as BLAS

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]




On Mon, Feb 20, 2017 at 8:33 AM, Peter <list@xxxxxxxxxxxxxxxxx> wrote:
Dear Mathieu and Gael,



Am 19.02.2017 um 11:32 schrieb Gael Guennebaud:
Yes and no. There is one BLAS API in eigen/blas, but its goal is to compile a BLAS compatible library. Converting it to a header-only lib would be a bad idea because BLAS functions are not templated, so you would end up compiling
the entire blas every time... Then if you are looking for something like:

MatrixXd A, B, C;
gemm(A,B,alpha,C,1);

I'm afraid it's a little bit more complicated, as one has to deal with the leading dimension parameter.
In addition the interface should be given by e.g.

void dgemm( const char*, const char*, const int&, const int&, const int&, const double&,
            const double*, const int&, const double*, const int&, const double&,  double*, const int&);


Still unclear to me. With such prototypes no arbitrary scalar type, no range checking, and everything will be compiled for every compilation unit (the order of minutes...). And as I said, this one is already available in Eigen's source /blas folder (modulo the int& versus int*).

Perhaps you want:

template<typename Scalar,typename Index>
void gemm( const char*, const char*, const Index&, const Index&, const Index&, const Scalar&,
            const Scalar*, const int&, const Scalar*, const Index&, const Scalar&,  Scalar*, const Index&);

to get custom scalar types and no huge compilation overhead, but still no range checking. This version can be easily accomplished through a slight refactoring of the code in eigen/blas.

For range checking you have to pass Eigen's object and then passing the leading dimensions become useless, which is why I suggested gemm(A,B,alpha,C,1);, but then simply use C++ Eigen's API.

 
I'm not sure to see the point.

In case one is the author/coauthor of a code using BLAS calls I see several good reasons
in wanting a header only BLAS version.

(1) A good starting point for switching to Eigen, e.g. benchmarking the own application, before performing a switch

for this, just builld libeigenblas.so and link to it.
 

gael



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/