Calling a host function from within the device

Exactly one year ago I used the current at the time CUDA version (don’t remember which one) and I wrote some CUDA kernels that made use of my vector class. This class has some functions, mostly overloaded operators. And they all worked fine. But today I downloaded that newest CUDA toolkit, try to compile my old project and…

error: calling a host function("vec3::operator +") from a __device__/__global__ function("rasterizePixel") is not allowed

Is there a way to fix that? And I would prefer a way that avoids any modifications to vec3 class.

I have a same problem when I tried to compile julia_gpu.cu (cuda_by_example/chapter04) with CUDA 7.5

Since Cuda By Example is a very old textbook, I guess CUDA of higher version has changed a lot and is not compatible with the old codes in the textbook.

Does anybody know how to solve this problem?

  1. Try decorating the function in question with host device
  2. Check the cuda by example sample code, I think it may have the issue fixed:

[url]https://developer.nvidia.com/cuda-example[/url]

Well, you mean the codes in CUDA By Example have been updated?

Unfortunately, however, the codes that I am using are the latest ones.