Pgc++ can't running c++ code with eigen library

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?

Which compiler version and which Eigen package are you using?

While I’ve not seen this particular error, we have had issues with compiling Eigen mostly due to the AVX512 intrinsics. These should be addressed in an upcoming release. You may try adding the flag “-cuda” so it doesn’t use the AVX512 intrinsics.

Example using nvc++ 21.9 with Eigen 3.4.0:

% nvc++ -w --std=c++17 -Ieigen-3.4.0/ test.cpp -V21.9
"eigen-3.4.0/Eigen/src/Core/arch/AVX512/PacketMath.h", line 810: error: argument of type "const void *" is incompatible with parameter of type "const float *"
    return _mm512_i32gather_ps(indices, from, 4);
           ^

1 error detected in the compilation of "test.cpp".
% nvc++ -w --std=c++17 -Ieigen-3.4.0/ test.cpp -V21.9 -cuda
% a.out
0.999998
1
1
1
1
1
1
1
0.999999
1

-Mat

1 Like

Thanks a lot!! I downloaded the latest version of hpc-sdk package and worked! I was using the 20.11, now I’m using 21.9 version. The flag “-cuda” helps too.