【发布时间】:2020-08-15 00:35:14
【问题描述】:
我正在尝试使用 MKL 从 Eigen 库运行 SVD,但出现以下错误
In file included from blas_mkl.cpp:6:
In file included from /usr/local/include/eigen3/Eigen/SVD:11:
In file included from /usr/local/include/eigen3/Eigen/QR:45:
/usr/local/include/eigen3/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h:85:1: error: cannot initialize a variable of type 'long long *' with an rvalue of type
'Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::Scalar *' (aka 'int *')
EIGEN_LAPACKE_QR_COLPIV(double, double, d, ColMajor, LAPACK_COL_MAJOR)
...
/usr/local/include/eigen3/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h:74:15: note: expanded from macro 'EIGEN_LAPACKE_QR_COLPIV'
lapack_int *perm = m_colsPermutation.indices().data(); \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated.
我有最新版的MKL,我的cpp文件是
//blas_mkl.cpp
#define EIGEN_USE_MKL_VML
#define EIGEN_USE_LAPACKE
#include <iostream>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/SVD>
using namespace Eigen;
using namespace std;
int main() {
MatrixXf data(4, 2);
data << 76, 8,
0, 0,
82, 3,
80, 0;
JacobiSVD<MatrixXf> svd(data, ComputeThinU | ComputeThinV);
cout << svd.matrixU() * svd.singularValues().asDiagonal() * svd.matrixV().transpose() << endl;
cout << data << endl;
return 0;
}
我使用以下命令运行代码
g++ -DMKL_ILP64 -m64 -I${MKLROOT}/include ${MKLROOT}/lib/libmkl_intel_ilp64.a ${MKLROOT}/lib/libmkl_intel_thread.a ${MKLROOT}/lib/libmkl_core.a -liomp5 -lpthread -lm -ldl -o blas_mkl blas_mkl.cpp
echo ${MKLROOT} 给出的地方
/opt/intel/compilers_and_libraries_2020.2.258/mac/mkl
但是当我只保留#define EIGEN_USE_MKL_VML 时,代码实际上可以正常工作,但是当我保留 LAPACKE 时,我得到了分段错误 11。谁能告诉我这里发生了什么?
【问题讨论】:
-
它工作正常,你得到一个段错误或你得到一个编译错误?
-
我在使用 LAPACKE 时遇到了段错误。