![]() Registered Member ![]()
|
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 |
![]() Moderator ![]()
|
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. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]