different behavior for eigen::matrix inversion when compiled with gcc and nvcc











up vote
1
down vote

favorite












I do matrix inversion(code provided below) using Eigen(Lets call it inversion.cpp). Inversion.cpp compiles with g++ and gives correct inverse.



Now I change the code name to Inversion.cu and try to compile with nvcc. The compile fails with a long list of errors.



#include <Eigen/Geometry>
using namespace Eigen;
using namespace std;

typedef Matrix<float, 6, 6> Matrix6f;

int main()
{

Matrix6f M;

M<< 0.932322, 0.125848, -0.85106, -0.313612, -1.50979, -0.691102,
0.125848, 0.663803, -0.555993, 0.117918, -0.645694, -0.625737,
-0.85106, -0.555993, 1.26442, 0.39079, 1.89422, 0.959306,
-0.313612, 0.117918, 0.39079, 2.70718, 1.84228, 2.12945,
-1.50979, -0.645694, 1.89422, 1.84228, 3.89408, 2.5017,
-0.691102, -0.625737, 0.959306, 2.12945, 2.5017, 3.39874;

cout << "Inverse= " << M.inverse() << endl;

return 0;
}


The errors I get when I try to compile code with nvcc is:



Scanning dependencies of target matrix_inverse
[100%] Linking CXX executable matrix_inverse
CMakeFiles/matrix_inverse.dir/matrix_inverse_generated_matrix_inverse.cu.o: In function `Eigen::internal::compute_inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 6>::run(Eigen::Matrix<float, 6, 6, 0, 6, 6> const&, Eigen::Matrix<float, 6, 6, 0, 6, 6>&)':
/usr/include/eigen3/Eigen/src/LU/InverseImpl.h:28: undefined reference to `Eigen::MatrixBase<Eigen::Matrix<float, 6, 6, 0, 6, 6> >::partialPivLu() const'
collect2: error: ld returned 1 exit status
CMakeFiles/matrix_inverse.dir/build.make:79: recipe for target 'matrix_inverse' failed
make[2]: *** [matrix_inverse] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/matrix_inverse.dir/all' failed
make[1]: *** [CMakeFiles/matrix_inverse.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


My cmakelists:



cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(inversion)
INCLUDE_DIRECTORIES (/usr/include/eigen3)

FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_52,code=sm_52;
)

cuda_add_executable (matrix_inverse matrix_inverse.cu)


The compile log is huge and I add only some relevant parts below:



/usr/include/eigen3/Eigen/src/LU/InverseImpl.h(335): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during instantiation of "const Eigen::Inverse<Derived> Eigen::MatrixBase<Derived>::inverse() const [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(58): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::cols() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(57): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::rows() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Solve.h(72): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Solve<Decomposition, RhsType>::rows() const [with Decomposition=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, RhsType=Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 10 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here









share|improve this question
























  • What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
    – Avi Ginsburg
    Nov 22 at 6:20












  • added cmakelists.txt
    – user27665
    Nov 22 at 6:27






  • 2




    You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
    – talonmies
    Nov 22 at 6:50












  • @talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
    – Avi Ginsburg
    Nov 22 at 7:14










  • All of that addition output you have added only contains compiler warnings, not errors
    – talonmies
    Nov 22 at 15:21















up vote
1
down vote

favorite












I do matrix inversion(code provided below) using Eigen(Lets call it inversion.cpp). Inversion.cpp compiles with g++ and gives correct inverse.



Now I change the code name to Inversion.cu and try to compile with nvcc. The compile fails with a long list of errors.



#include <Eigen/Geometry>
using namespace Eigen;
using namespace std;

typedef Matrix<float, 6, 6> Matrix6f;

int main()
{

Matrix6f M;

M<< 0.932322, 0.125848, -0.85106, -0.313612, -1.50979, -0.691102,
0.125848, 0.663803, -0.555993, 0.117918, -0.645694, -0.625737,
-0.85106, -0.555993, 1.26442, 0.39079, 1.89422, 0.959306,
-0.313612, 0.117918, 0.39079, 2.70718, 1.84228, 2.12945,
-1.50979, -0.645694, 1.89422, 1.84228, 3.89408, 2.5017,
-0.691102, -0.625737, 0.959306, 2.12945, 2.5017, 3.39874;

cout << "Inverse= " << M.inverse() << endl;

return 0;
}


The errors I get when I try to compile code with nvcc is:



Scanning dependencies of target matrix_inverse
[100%] Linking CXX executable matrix_inverse
CMakeFiles/matrix_inverse.dir/matrix_inverse_generated_matrix_inverse.cu.o: In function `Eigen::internal::compute_inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 6>::run(Eigen::Matrix<float, 6, 6, 0, 6, 6> const&, Eigen::Matrix<float, 6, 6, 0, 6, 6>&)':
/usr/include/eigen3/Eigen/src/LU/InverseImpl.h:28: undefined reference to `Eigen::MatrixBase<Eigen::Matrix<float, 6, 6, 0, 6, 6> >::partialPivLu() const'
collect2: error: ld returned 1 exit status
CMakeFiles/matrix_inverse.dir/build.make:79: recipe for target 'matrix_inverse' failed
make[2]: *** [matrix_inverse] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/matrix_inverse.dir/all' failed
make[1]: *** [CMakeFiles/matrix_inverse.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


My cmakelists:



cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(inversion)
INCLUDE_DIRECTORIES (/usr/include/eigen3)

FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_52,code=sm_52;
)

cuda_add_executable (matrix_inverse matrix_inverse.cu)


The compile log is huge and I add only some relevant parts below:



/usr/include/eigen3/Eigen/src/LU/InverseImpl.h(335): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during instantiation of "const Eigen::Inverse<Derived> Eigen::MatrixBase<Derived>::inverse() const [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(58): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::cols() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(57): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::rows() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Solve.h(72): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Solve<Decomposition, RhsType>::rows() const [with Decomposition=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, RhsType=Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 10 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here









share|improve this question
























  • What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
    – Avi Ginsburg
    Nov 22 at 6:20












  • added cmakelists.txt
    – user27665
    Nov 22 at 6:27






  • 2




    You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
    – talonmies
    Nov 22 at 6:50












  • @talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
    – Avi Ginsburg
    Nov 22 at 7:14










  • All of that addition output you have added only contains compiler warnings, not errors
    – talonmies
    Nov 22 at 15:21













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I do matrix inversion(code provided below) using Eigen(Lets call it inversion.cpp). Inversion.cpp compiles with g++ and gives correct inverse.



Now I change the code name to Inversion.cu and try to compile with nvcc. The compile fails with a long list of errors.



#include <Eigen/Geometry>
using namespace Eigen;
using namespace std;

typedef Matrix<float, 6, 6> Matrix6f;

int main()
{

Matrix6f M;

M<< 0.932322, 0.125848, -0.85106, -0.313612, -1.50979, -0.691102,
0.125848, 0.663803, -0.555993, 0.117918, -0.645694, -0.625737,
-0.85106, -0.555993, 1.26442, 0.39079, 1.89422, 0.959306,
-0.313612, 0.117918, 0.39079, 2.70718, 1.84228, 2.12945,
-1.50979, -0.645694, 1.89422, 1.84228, 3.89408, 2.5017,
-0.691102, -0.625737, 0.959306, 2.12945, 2.5017, 3.39874;

cout << "Inverse= " << M.inverse() << endl;

return 0;
}


The errors I get when I try to compile code with nvcc is:



Scanning dependencies of target matrix_inverse
[100%] Linking CXX executable matrix_inverse
CMakeFiles/matrix_inverse.dir/matrix_inverse_generated_matrix_inverse.cu.o: In function `Eigen::internal::compute_inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 6>::run(Eigen::Matrix<float, 6, 6, 0, 6, 6> const&, Eigen::Matrix<float, 6, 6, 0, 6, 6>&)':
/usr/include/eigen3/Eigen/src/LU/InverseImpl.h:28: undefined reference to `Eigen::MatrixBase<Eigen::Matrix<float, 6, 6, 0, 6, 6> >::partialPivLu() const'
collect2: error: ld returned 1 exit status
CMakeFiles/matrix_inverse.dir/build.make:79: recipe for target 'matrix_inverse' failed
make[2]: *** [matrix_inverse] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/matrix_inverse.dir/all' failed
make[1]: *** [CMakeFiles/matrix_inverse.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


My cmakelists:



cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(inversion)
INCLUDE_DIRECTORIES (/usr/include/eigen3)

FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_52,code=sm_52;
)

cuda_add_executable (matrix_inverse matrix_inverse.cu)


The compile log is huge and I add only some relevant parts below:



/usr/include/eigen3/Eigen/src/LU/InverseImpl.h(335): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during instantiation of "const Eigen::Inverse<Derived> Eigen::MatrixBase<Derived>::inverse() const [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(58): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::cols() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(57): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::rows() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Solve.h(72): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Solve<Decomposition, RhsType>::rows() const [with Decomposition=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, RhsType=Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 10 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here









share|improve this question















I do matrix inversion(code provided below) using Eigen(Lets call it inversion.cpp). Inversion.cpp compiles with g++ and gives correct inverse.



Now I change the code name to Inversion.cu and try to compile with nvcc. The compile fails with a long list of errors.



#include <Eigen/Geometry>
using namespace Eigen;
using namespace std;

typedef Matrix<float, 6, 6> Matrix6f;

int main()
{

Matrix6f M;

M<< 0.932322, 0.125848, -0.85106, -0.313612, -1.50979, -0.691102,
0.125848, 0.663803, -0.555993, 0.117918, -0.645694, -0.625737,
-0.85106, -0.555993, 1.26442, 0.39079, 1.89422, 0.959306,
-0.313612, 0.117918, 0.39079, 2.70718, 1.84228, 2.12945,
-1.50979, -0.645694, 1.89422, 1.84228, 3.89408, 2.5017,
-0.691102, -0.625737, 0.959306, 2.12945, 2.5017, 3.39874;

cout << "Inverse= " << M.inverse() << endl;

return 0;
}


The errors I get when I try to compile code with nvcc is:



Scanning dependencies of target matrix_inverse
[100%] Linking CXX executable matrix_inverse
CMakeFiles/matrix_inverse.dir/matrix_inverse_generated_matrix_inverse.cu.o: In function `Eigen::internal::compute_inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 6>::run(Eigen::Matrix<float, 6, 6, 0, 6, 6> const&, Eigen::Matrix<float, 6, 6, 0, 6, 6>&)':
/usr/include/eigen3/Eigen/src/LU/InverseImpl.h:28: undefined reference to `Eigen::MatrixBase<Eigen::Matrix<float, 6, 6, 0, 6, 6> >::partialPivLu() const'
collect2: error: ld returned 1 exit status
CMakeFiles/matrix_inverse.dir/build.make:79: recipe for target 'matrix_inverse' failed
make[2]: *** [matrix_inverse] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/matrix_inverse.dir/all' failed
make[1]: *** [CMakeFiles/matrix_inverse.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


My cmakelists:



cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(inversion)
INCLUDE_DIRECTORIES (/usr/include/eigen3)

FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_52,code=sm_52;
)

cuda_add_executable (matrix_inverse matrix_inverse.cu)


The compile log is huge and I add only some relevant parts below:



/usr/include/eigen3/Eigen/src/LU/InverseImpl.h(335): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during instantiation of "const Eigen::Inverse<Derived> Eigen::MatrixBase<Derived>::inverse() const [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(58): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::cols() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Inverse.h(57): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Inverse<XprType>::rows() const [with XprType=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 4 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here

/usr/include/eigen3/Eigen/src/Core/Solve.h(72): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Index Eigen::Solve<Decomposition, RhsType>::rows() const [with Decomposition=Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, RhsType=Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(733): here
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(712): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<<expression>, void *>::type) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>, Func=Eigen::internal::assign_op<float>]"
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(693): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 6, 6, 0, 6, 6>, Src=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(682): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Solve<Eigen::PartialPivLU<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<float>, Eigen::Matrix<float, 6, 6, 0, 6, 6>>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
[ 10 instantiation contexts not shown ]
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(783): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 6, 6, 0, 6, 6>, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>, OtherDerived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(296): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=6, _Cols=6, _Options=0, _MaxRows=6, _MaxCols=6, T=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/DenseBase.h(410): here
instantiation of "Eigen::DenseBase<Derived>::EvalReturnType Eigen::DenseBase<Derived>::eval() const [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/usr/include/eigen3/Eigen/src/Core/IO.h(248): here
instantiation of "std::ostream &Eigen::operator<<(std::ostream &, const Eigen::DenseBase<Derived> &) [with Derived=Eigen::Inverse<Eigen::Matrix<float, 6, 6, 0, 6, 6>>]"
/home/krr/temp_codes/eigen/matrix_inverse/src/matrix_inverse.cu(21): here






matrix cuda eigen inversion






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 7:22

























asked Nov 22 at 5:45









user27665

309414




309414












  • What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
    – Avi Ginsburg
    Nov 22 at 6:20












  • added cmakelists.txt
    – user27665
    Nov 22 at 6:27






  • 2




    You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
    – talonmies
    Nov 22 at 6:50












  • @talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
    – Avi Ginsburg
    Nov 22 at 7:14










  • All of that addition output you have added only contains compiler warnings, not errors
    – talonmies
    Nov 22 at 15:21


















  • What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
    – Avi Ginsburg
    Nov 22 at 6:20












  • added cmakelists.txt
    – user27665
    Nov 22 at 6:27






  • 2




    You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
    – talonmies
    Nov 22 at 6:50












  • @talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
    – Avi Ginsburg
    Nov 22 at 7:14










  • All of that addition output you have added only contains compiler warnings, not errors
    – talonmies
    Nov 22 at 15:21
















What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
– Avi Ginsburg
Nov 22 at 6:20






What versions/platform of nvcc/g++/Eigen? The combination has been known in the past not to play nicely with each other... As an added bonus, can you throw in your exact command line flags?
– Avi Ginsburg
Nov 22 at 6:20














added cmakelists.txt
– user27665
Nov 22 at 6:27




added cmakelists.txt
– user27665
Nov 22 at 6:27




2




2




You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
– talonmies
Nov 22 at 6:50






You say in the question that you get a "long list of errors, but I see only one error, and that is a linking error, not a compilation error. It that really what is happening? A linking error for that class member function? Because it appears to be a fully documented limitation of Eigen -- eigen.tuxfamily.org/bz/show_bug.cgi?id=1089
– talonmies
Nov 22 at 6:50














@talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
– Avi Ginsburg
Nov 22 at 7:14




@talonmies Except that OP has #include <Eigen/Geometry> which starts by including Eigen/Core and LU, at least in the version I checked (3.3.4). So that documented limitation shouldn't be relevant.
– Avi Ginsburg
Nov 22 at 7:14












All of that addition output you have added only contains compiler warnings, not errors
– talonmies
Nov 22 at 15:21




All of that addition output you have added only contains compiler warnings, not errors
– talonmies
Nov 22 at 15:21












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










This is simply because inversion of matrices larger than 4 are not supported yet on CUDA.



To answer talonmies's comment, since the OP's file is compiled with nvcc, Eigen automatically enables CUDA support. In particular the method MatrixBase::inverse() is declared as host device because if the underlying expression is 4x4 or smaller then it will branch, at compile-time, to CUDA compatible code. For larger ones, it branches to non-cuda compatible code... So the consequence is that CUDA and non-CUDA non-trivial code better has to be well separated in .cu and .cpp files.






share|improve this answer



















  • 1




    But there is no CUDA code here
    – talonmies
    Nov 22 at 22:34










  • I completed the analysis.
    – ggael
    Nov 23 at 15:24











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424578%2fdifferent-behavior-for-eigenmatrix-inversion-when-compiled-with-gcc-and-nvcc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










This is simply because inversion of matrices larger than 4 are not supported yet on CUDA.



To answer talonmies's comment, since the OP's file is compiled with nvcc, Eigen automatically enables CUDA support. In particular the method MatrixBase::inverse() is declared as host device because if the underlying expression is 4x4 or smaller then it will branch, at compile-time, to CUDA compatible code. For larger ones, it branches to non-cuda compatible code... So the consequence is that CUDA and non-CUDA non-trivial code better has to be well separated in .cu and .cpp files.






share|improve this answer



















  • 1




    But there is no CUDA code here
    – talonmies
    Nov 22 at 22:34










  • I completed the analysis.
    – ggael
    Nov 23 at 15:24















up vote
1
down vote



accepted










This is simply because inversion of matrices larger than 4 are not supported yet on CUDA.



To answer talonmies's comment, since the OP's file is compiled with nvcc, Eigen automatically enables CUDA support. In particular the method MatrixBase::inverse() is declared as host device because if the underlying expression is 4x4 or smaller then it will branch, at compile-time, to CUDA compatible code. For larger ones, it branches to non-cuda compatible code... So the consequence is that CUDA and non-CUDA non-trivial code better has to be well separated in .cu and .cpp files.






share|improve this answer



















  • 1




    But there is no CUDA code here
    – talonmies
    Nov 22 at 22:34










  • I completed the analysis.
    – ggael
    Nov 23 at 15:24













up vote
1
down vote



accepted







up vote
1
down vote



accepted






This is simply because inversion of matrices larger than 4 are not supported yet on CUDA.



To answer talonmies's comment, since the OP's file is compiled with nvcc, Eigen automatically enables CUDA support. In particular the method MatrixBase::inverse() is declared as host device because if the underlying expression is 4x4 or smaller then it will branch, at compile-time, to CUDA compatible code. For larger ones, it branches to non-cuda compatible code... So the consequence is that CUDA and non-CUDA non-trivial code better has to be well separated in .cu and .cpp files.






share|improve this answer














This is simply because inversion of matrices larger than 4 are not supported yet on CUDA.



To answer talonmies's comment, since the OP's file is compiled with nvcc, Eigen automatically enables CUDA support. In particular the method MatrixBase::inverse() is declared as host device because if the underlying expression is 4x4 or smaller then it will branch, at compile-time, to CUDA compatible code. For larger ones, it branches to non-cuda compatible code... So the consequence is that CUDA and non-CUDA non-trivial code better has to be well separated in .cu and .cpp files.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 at 15:24

























answered Nov 22 at 20:31









ggael

19.9k22944




19.9k22944








  • 1




    But there is no CUDA code here
    – talonmies
    Nov 22 at 22:34










  • I completed the analysis.
    – ggael
    Nov 23 at 15:24














  • 1




    But there is no CUDA code here
    – talonmies
    Nov 22 at 22:34










  • I completed the analysis.
    – ggael
    Nov 23 at 15:24








1




1




But there is no CUDA code here
– talonmies
Nov 22 at 22:34




But there is no CUDA code here
– talonmies
Nov 22 at 22:34












I completed the analysis.
– ggael
Nov 23 at 15:24




I completed the analysis.
– ggael
Nov 23 at 15:24


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424578%2fdifferent-behavior-for-eigenmatrix-inversion-when-compiled-with-gcc-and-nvcc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks