This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1099 - CUDA/nvcc compilation error (identifier undefined) and warnings (C++11 feature)
Summary: CUDA/nvcc compilation error (identifier undefined) and warnings (C++11 feature)
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - 64-bit Linux
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-29 21:06 UTC by myemailadress99
Modified: 2019-12-04 15:06 UTC (History)
3 users (show)



Attachments

Description myemailadress99 2015-10-29 21:06:20 UTC
When using #include "Eigen/Dense" in a file compiled for CUDA with nvcc i get the following error:

../Eigen/src/Core/util/Meta.h:143: error: identifier "CUDART_MAX_NORMAL_F" is undefined

Information:
CUDA: 7.5.18
Linux: x64, 4.2.4
Gcc: 5.2
Eigen: 3.3, current master branch (at time of writing)

I've also tried adding the workaround mentioned here: http://eigen.tuxfamily.org/dox-devel/TopicCUDA.html (but it did not help)

I've also tried with Eigen 3.3-alpha1 (http://bitbucket.org/eigen/eigen/get/3.3-alpha1.tar.bz2) which gave an additional error:

../Eigen/src/Core/util/Meta.h:148: error: identifier "CUDART_INF" is undefined

Note i didn't add any code using Eigen to the project yet, just the include.

When i add the following code to a __global__ function in the .cu cuda file i get 2 extra warning with the above mentioned error:
../Eigen/src/Core/util/Memory.h:472: warning: list initialization syntax is a C++11 feature
          detected during:
            instantiation of "void Eigen::DenseStorage<T, -1, -1, -1, _Options>::resize(Eigen::Index, Eigen::Index, Eigen::Index) [with T=double, _Options=0]" 
../Eigen/src/Core/PlainObjectBase.h:267: here
            instantiation of "void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived=Eigen::Matrix<double, -1, -1, 0, -1, -1>]" 
../Eigen/src/Core/PlainObjectBase.h:706: here
            instantiation of "void Eigen::PlainObjectBase<Derived>::_init2<T0,T1>(Eigen::Index, Eigen::Index, Eigen::internal::enable_if<<expression>, T0>::type *) [with Derived=Eigen::Matrix<double, -1, -1, 0, -1, -1>, T0=int, T1=int]" 
../Eigen/src/Core/Matrix.h:304: here
            instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T0 &, const T1 &) [with _Scalar=double, _Rows=-1, _Cols=-1, _Options=0, _MaxRows=-1, _MaxCols=-1, T0=int, T1=int]" 
../kernel.cu:37: here

../Eigen/src/Core/util/Memory.h:367: warning: list initialization syntax is a C++11 feature
          detected during:
            instantiation of "T *Eigen::internal::conditional_aligned_new_auto<T,Align>(size_t) [with T=double, Align=true]" 
../Eigen/src/Core/DenseStorage.h:403: here
            instantiation of "void Eigen::DenseStorage<T, -1, -1, -1, _Options>::resize(Eigen::Index, Eigen::Index, Eigen::Index) [with T=double, _Options=0]" 
../Eigen/src/Core/PlainObjectBase.h:267: here
            instantiation of "void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived=Eigen::Matrix<double, -1, -1, 0, -1, -1>]" 
../Eigen/src/Core/PlainObjectBase.h:706: here
            instantiation of "void Eigen::PlainObjectBase<Derived>::_init2<T0,T1>(Eigen::Index, Eigen::Index, Eigen::internal::enable_if<<expression>, T0>::type *) [with Derived=Eigen::Matrix<double, -1, -1, 0, -1, -1>, T0=int, T1=int]" 
../Eigen/src/Core/Matrix.h:304: here
            instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T0 &, const T1 &) [with _Scalar=double, _Rows=-1, _Cols=-1, _Options=0, _MaxRows=-1, _MaxCols=-1, T0=int, T1=int]" 
../kernel.cu:37: here

The code i added to the kernel (__global__ function): 
    Eigen::MatrixXd m(2,2);
    m(0,0) = 3;
    m(1,0) = 2.5;
    m(0,1) = -1;
    m(1,1) = m(1,0) + m(0,1);
Comment 1 Gael Guennebaud 2015-10-30 10:48:45 UTC
What about adding:

#include <math_constants.h>

before including any Eigen's header?
Comment 2 myemailadress99 2015-10-30 22:20:38 UTC
That indeed resolves the errors, thanks. The warnings are still present but it compiles and works.

I will mark it as resolved and invalid (I assume it's my job to include <math_constants.h> and not Eigen's), although how should I have known this? (I know at least 1 other person had the same problem since he had asked about it on stackoverflow)
Comment 3 Gael Guennebaud 2015-10-31 17:07:34 UTC
This should be done within Eigen, so fixed: https://bitbucket.org/eigen/eigen/commits/4111270ba6e1/
Comment 4 Nobody 2019-12-04 15:06:40 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1099.

Note You need to log in before you can comment on or make changes to this bug.