C++ 在内核代码中调用特征函数时出现NVCC编译错误
我在Ubuntu 18.04.4上运行的项目中使用了Egen3.3.9。在我试图修改我的CUDA支持项目之前,一切都很顺利。我试过cuda/10.0和cuda/10.2 当我试图调用特征矩阵的行列式()时,问题就出现了。我的编译器产生以下错误C++ 在内核代码中调用特征函数时出现NVCC编译错误,c++,eigen,nvcc,C++,Eigen,Nvcc,我在Ubuntu 18.04.4上运行的项目中使用了Egen3.3.9。在我试图修改我的CUDA支持项目之前,一切都很顺利。我试过cuda/10.0和cuda/10.2 当我试图调用特征矩阵的行列式()时,问题就出现了。我的编译器产生以下错误 voxelize.cu(301): error: calling a __host__ function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)
voxelize.cu(301): error: calling a __host__ function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> > ::determinant const") from a __global__ function("MeshIterKernel") is not allowed
voxelize.cu(301): error: identifier "Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> > ::determinant const" is undefined in device code
voxelize.cu(301): error: calling a __host__ function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> > ::determinant const") from a __global__ function("MeshIterKernel") is not allowed
voxelize.cu(301): error: identifier "Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> > ::determinant const" is undefined in device code
voxelize.cu(301): error: calling a __host__ function("Eigen::MatrixBase< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> > ::determinant const") from a __global__ function("MeshIterKernel") is not allowed
下面是产生错误的部分代码
__device__
bool Philipp(Vector3f A, Vector3f B, Vector3f C, Vector3f D, Vector3f P)
{
Vector3f a = A - P, b = B - P, c = C - P, d = D - P;
Matrix3f Da, Db, Dc, Dd;
Da << b, c, d;
Db << a, c, d;
Dc << a, b, d;
Dd << a, b, c;
if((Da.determinant() * Dc.determinant() >= 0) && (Db.determinant() * Dd.determinant() >= 0) && (Da.determinant() * Db.determinant() <= 0))
return true;
return false;
}
你能提取a并在这里提供吗?另外,为了确保这一点,您确实在线搜索了错误消息以形成理解,对吗?在线查询错误消息只会给我提供有关如何使用CUDA支持编译Eigen的结果,但我的大部分Eigen函数都工作得很好。此外,向谷歌发送警告消息会让我看到一系列关于如何抑制警告的结果(-Wall)。
__device__
bool Philipp(Vector3f A, Vector3f B, Vector3f C, Vector3f D, Vector3f P)
{
Vector3f a = A - P, b = B - P, c = C - P, d = D - P;
Matrix3f Da, Db, Dc, Dd;
Da << b, c, d;
Db << a, c, d;
Dc << a, b, d;
Dd << a, b, c;
if((Da.determinant() * Dc.determinant() >= 0) && (Db.determinant() * Dd.determinant() >= 0) && (Da.determinant() * Db.determinant() <= 0))
return true;
return false;
}
#include <Eigen/Dense>
using namespace Eigen;
__device__
bool Foo()
{
Vector3f a, b, c;
Matrix3f Da;
a << 1,2,3;
b << 2,5,7;
c << 6,1,8;
Da << a, b, c;
return Da.determinant() >= 0;
}
__global__
void Kernel()
{
Foo();
}
int main(int argc, char** argv)
{
Kernel<<<1,1>>>();
return 0;
}
nvcc add.cu -I .