Hi,
I’m using pgc++ to accelerate my seismic tomography code and I need to solve a sparse linear system using Eigen library.
The matrix declaration and matrix operation using Eigen is fine when I compile the code with pgc++, but
the linear system solvers didn’t compile and the error is
$ pgc++ sparse_matrix.cpp -o sparse.exe
NVC++-F-0000-Internal compiler error. Not a vect type 465045 (sparse_matrix.cpp: 1208)
NVC++/x86-64 Linux 20.11-0: compilation aborted
The simple code (sparse_matrix.cpp) to solve a sparse linear system is
# include <vector>
# include <iostream>
# include <Eigen/Sparse>
int main(int argc, char **argv)
{
int n = 10;
int m = 10;
int nnz = 29;
std::vector < int > i {0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,5,6,6,7,7,8,8,9,9,9};
std::vector < int > j {0,2,6,9,1,3,6,2,5,9,1,3,7,2,4,6,1,3,5,9,3,6,1,7,4,8,1,5,9};
std::vector < float > v {1.0f,3.0f,-5.0f,2.0f,4.0f,-2.0f,1.0f,-2.0f,2.0f,1.0f,1.0f,
1.0f,-3.0f,2.0f,5.0f,-2.0f,2.0f,-4.0f,2.0f,4.0f,4.0f,-1.0f,
1.0f,-3.0f,-3.0f,1.0f,-5.0f,6.0f,2.0f};
std::vector < float > d {1.0f,3.0f,1.0f,-1.0f,5.0f,4.0f,3.0f,-2.0f,-2.0f,3.0f};
Eigen::SparseVector<float,Eigen::ColMajor> b(n), x(m);
Eigen::SparseMatrix<float,Eigen::ColMajor> A(m,n);
typedef Eigen::Triplet<float> T;
std::vector<T> tripletList;
tripletList.reserve(nnz);
for (int index = 0; index < nnz; index++)
tripletList.push_back(T(i[index],j[index],v[index]));
A.setFromTriplets(tripletList.begin(), tripletList.end());
for (int index = 0; index < n; index++)
b.insert(index) = d[index];
// Solving the linear system
Eigen::SparseLU<Eigen::SparseMatrix<float>, Eigen::COLAMDOrdering<int>> SLU;
SLU.analyzePattern(A);
SLU.factorize(A);
x = SLU.solve(b);
std::cout<<x.col(0)<<std::endl;
return 0;
}
Can you please help me to solve this compilation error?