Eigen(3) の Intel MKL を使用してみました。以下に示す基本的な行列乗算プログラムを作成しました。
#include <iostream>
#define EIGEN_USE_MKL_ALL
#include "../Eigen/src/Core/util/MKL_support.h"
#include "Dense"
#include "EigenTools.h"
#include <sys/time.h>
int main()
{
int rows= 10000, cols =100;
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> M(rows, cols);
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> N(cols, rows);
M.setRandom();
N.setRandom();
struct timeval tv_start;
struct timezone tz;
gettimeofday(&tv_start, &tz);
Eigen::MatrixXf P = M*N;
struct timeval tv_end;
gettimeofday(&tv_end, &tz);
float elapsedTime = (tv_end.tv_sec-tv_start.tv_sec)*1000000+tv_end.tv_usec-tv_start.tv_usec;
elapsedTime /= 1000000;
std::cout<<"rows, cols:"<<M.rows()<<","<<M.cols()<<std::endl;
std::cout<<"elpsed Time in sec is :"<<elapsedTime<<"\n";
return 0;
}
「g++ EigenTest_IntelMKL.cpp -I../Eigen -DMKL_ILP64 -m64 -I /opt/intel/mkl/include」を使用すると、次のコンパイル エラーが発生しました。
EigenTest_IntelMKL.cpp:3:0 からインクルードされたファイル: ../Eigen/src/Core/util/MKL_support.h:64:9: エラー: 'complex' in namespace 'std' does not name a type typedef std::複雑なdcomplex; ^ ../Eigen/src/Core/util/MKL_support.h:65:9: エラー: 名前空間 'std' の 'complex' は型 typedef std::complex scomplex を指定しません。