Calling a __host__ function from a __global__ function is not allowed

I have this code attempting to generate a random float value to move the sphere by, however I get the error:

calling a host function from a global function is not allowed

How can I go about generating these random numbers to use here if I cant call the function? thank you

You could generate random numbers on the host, and transfer them to the gpu.

You could use cuRAND in the kernel.


That isn’t right. I’m not saying its the source of your problem (which isn’t evident here; however you haven’t shown any code that actually copies non-zero values to random_array).

You may want to remind yourself of basic CUDA programming concepts by studying a code like vectorAdd.