Unable to call operator== and operator!= for matrices inside a CUDA kernel

Submitted by Patrick Stotko

Assigned to Nobody

Link to original bugzilla bug (#1396)
Version: 3.4 (development)
Operating system: Linux

Description

Created attachment 778
Minimal failing example

Hi,

I have observed this error when trying to check if two matrices are equal inside a CUDA kernel (see attached reproducer):

<path>/main.cu(12): error: calling a host function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)5, (int)3, (int)0, (int)5, (int)3> > ::operator ==< ::Eigen::Matrix<float, (int)5, (int)3, (int)0, (int)5, (int)3> > ") from a global function("testEqual<(int)5, (int)3> ") is not allowed

<path>/main.cu(28): error: calling a host function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)5, (int)3, (int)0, (int)5, (int)3> > ::operator !=< ::Eigen::Matrix<float, (int)5, (int)3, (int)0, (int)5, (int)3> > ") from a global function("testNotEqual<(int)5, (int)3> ") is not allowed

This fails on both version 3.3.3 and the development version from the default branch.

In Eigen/src/Core/MatrixBase.h lines 296-306 where both functions are defined, there is indeed no EIGEN_DEVICE_FUNC. Furthermore, it is also missing in Eigen/src/Core/DenseBase.h lines 487-488 where all() and any() are defined.

Is there a reason why calling them is not allowed inside kernels? If not, I would suggest to add the EIGEN_DEVICE_FUNC qualifier and inline the definitions of all() and any().

Tested on (K)Ubuntu 14.04 and CUDA 8.0 using the attached example program.

Kind regards,
Patrick

Attachment 778, "Minimal failing example":
EigenCUDA.zip

Edited by Eigen Bugzilla