This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Compiling Eigen with icc and MKL

Tags: None
(comma "," separated)
ashteks
Registered Member
Posts
4
Karma
0

Compiling Eigen with icc and MKL

Thu Jan 03, 2013 9:27 pm
Hi,

I'd like to exploit the MKL libaray to speech up my matrix computations. However, I'm unable to compile the following code

//testMatrixMKL.cpp
#define EIGEN_USE_MKL_ALL
#include "Eigen/Dense"
#include <iostream>
using namespace Eigen;
int main()
{
std::cout<<"enter matrix size"<<std::endl;
int size = 1;
std::cin>>size;
Matrix<double,Dynamic,Dynamic> m1,m2,m3;
m1.setOnes(size,size);
m2.setOnes(size,size);
m3 = m1*m2 + m2;
std::cout<<"done m3"<<std::endl;

}



I get a whole bunch of messages and it stops compiling with the following remarks

/tmp/iccXlzRRA.o: In function `.text._ZN5Eigen8internal29general_matrix_matrix_productIldLi0ELb0EdLi0ELb0ELi0EE3runElllPKdlS4_lPdldRNS0_15level3_blockingIddEEPNS0_16GemmParallelInfoIlEE':
testMKL.cpp:(.text._ZN5Eigen8internal29general_matrix_matrix_productIldLi0ELb0EdLi0ELb0ELi0EE3runElllPKdlS4_lPdldRNS0_15level3_blockingIddEEPNS0_16GemmParallelInfoIlEE[.text._ZN5Eigen8internal29general_matrix_matrix_productIldLi0ELb0EdLi0ELb0ELi0EE3runElllPKdlS4_lPdldRNS0_15level3_blockingIddEEPNS0_16GemmParallelInfoIlEE]+0xe9): undefined reference to `dgemm'

I'm compiling with icc -I. testMatrixMKL.cpp . I'm using the LP64 interface and not the ILP64 one.

Using intel VML seems to compile fine. For example, the following code compiles
#define EIGEN_USE_MKL_VML
#include "Eigen/Dense"
#include <iostream>
using namespace Eigen;
int main()
{
Matrix2d a;
a << 1, 2,
3, 4;
MatrixXd b(2,2);
b << 2, 3,
1, 4;
std::cout << "a + b =\n" << a + b << std::endl;
std::cout << "a - b =\n" << a - b << std::endl;
std::cout << "Doing a += b;" << std::endl;
a += b;
std::cout << "Now a =\n" << a << std::endl;
Vector3d v(1,2,3);
Vector3d w(1,0,0);
std::cout << "-v + w - v =\n" << -v + w - v << std::endl;

What might be the problem ? Also, the tutorial says "These substitutions apply only for Dynamic or large enough objects ". How large must my matrix be in order to for Eigen to use MKL ?


Thanks in advance!

ash
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Compiling Eigen with icc and MKL

Fri Jan 04, 2013 11:11 pm
Clearly your linker flags must be wrong. Please check the MKL linking advisor as suggested there: http://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html.

I'd say that your matrices should be larger than about 50x50 to hope for some gains.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]