简体   繁体   English

CUDA fmod - 不允许从__global__函数调用__host__函数

[英]CUDA fmod - calling a __host__ function from a __global__ function is not allowed

I'm compiling a CUDA 5 project with VS2012 and I'm receiving this error: 我正在用VS2012编译一个CUDA 5项目,我收到了这个错误:

error : calling a __host__ function("fmod<float, int> ") from a __global__ function is not allowed

The compiler is practically mismatching the CUDA __device__ fmod with the fmod defined in math.h 编译器实际上将CUDA __device__ fmod与math.h中定义的fmod不匹配

How can I "disambiguate" between them? 我怎样才能在它们之间“消除歧义”?

This is happening because of a template argument mismatch. 这是由于模板参数不匹配而发生的。 You are calling fmod with a floating point argument and an integer argument. 您正在使用浮点参数和整数参数调用fmod There is only a device template argument for a pair of single precision or double precision floating point arguments (see here ). 对于一对单精度或双精度浮点参数,只有一个设备模板参数(参见此处 )。

What you are probably looking for is fmod(float, (float)int) .... 您可能正在寻找的是fmod(float, (float)int) ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM