Re: [eigen] Issue with CUDA

[ Thread Index | Date Index | More Archives ]

For CUDA 9 better use the head of the default branch, or maybe the head of the 3.3 branch which also contains a few CUDA9 related fixes. Then, we don't alllow dynamic allocation on device code, so either pass fixed size matrices of Map<> referencing existing buffers:

typedef Eigen::Map<Eigen::MatrixXd> MapMatXd;
typedef Eigen::Map<Eigen::VectorXd> MapVecXd;
typedef Eigne::Ref<Eigen::MatrixXd> RefMatXd;
typedef Eigen::Ref<Eigen::VectorXd> RefVecXd;

__device__ void EigenMVCuda(RefMatXd mat, RefVecXd& vec, RefVecXd& res)
   res.noalias() = mat * vec;

and in your kernel use MapMatXd/MapVecXd to wrap existing buffers.

On Thu, Sep 13, 2018 at 2:39 AM Vladimir Florinski <vaf0001@xxxxxxx> wrote:
I hope one of the developers could help me with using Eigen in CUDA code. I am using version 9.1 of the CUDA toolkit and Eigen 3.3.5. This simple code

#include <cuda_runtime.h>
#include <Eigen/Dense>

__device__ void EigenMVCuda(Eigen::MatrixXd& mat, Eigen::VectorXd& vec, Eigen::VectorXd& res)
   res = mat * vec;

int main() {};

Generates the following type of errors:

../include/Eigen/src/Core/MathFunctions.h(1067): warning: calling a __host__ function from a __host__ __device__ function is not allowed

../include/Eigen/src/Core/arch/CUDA/Half.h(96): error: identifier "x" is undefined

../include/Eigen/src/Core/arch/CUDA/PacketMathHalf.h(102): error: more than one conversion function from "const __half" to a built-in type applies:
            function "__half::operator short() const"
            function "__half::operator unsigned short() const"
            function "__half::operator int() const"
            function "__half::operator unsigned int() const"
            function "__half::operator long long() const"
            function "__half::operator unsigned long long() const"
            function "__half::operator __nv_bool() const"

Looks like there are three different issues here, but I am not sufficiently familiar with the inner workings of either library to make much sense out of them. Please advise how to resolve.


Vladimir Florinski

Mail converted by MHonArc 2.6.19+