So I am having trouble passing a variable defined in a device function to another device function. In the provided sudo code I can call foo(0,y),foo(1,y)… or whatever number explicitly and have no problems. However if I use foo(x,y) where x is a variable defined within the bar function I get ‘an illegal memory access was encountered’. Has anyone else encountered this problem?
__device__
void foo(int x, int y)
{
//Do something with x and y
}
__device__
void bar(int y)
{
int x = 1; //some value.
foo(x, y);
}
EDIT:
I found a prior thread that answers my question.
https://devtalk.nvidia.com/default/topic/474601/passing-variables-by-reference-to-device-function/