pointer not working

I am using a similar code in my program…

typedef struct _Node Node;

device Node * globalHead1;
device Node * globalHead2;

device xyz(Node **temp1, Node **temp2){
*temp1=globalHead1;
*temp2=globalHead2;
}

global kernel(){
Node * node1;
Node * node2;

     xyz(&node1,&node2);

}

I am checking correctness through cuda-gdb, and in which I found that it is not working as I was expecting. after calling xyz() from global *temp1 should be globalHead1. but debugger shows that temp1 cannot be dereferenced , illegal memory reference. So can anybody point out that where exactly I am missing something.

Thanks

Hum…

The code is incomplete, so maybe I am wrong, but I don’t see the point where you will assign any value (reference) to globalHead1 or globalHead2.
As the partial code is, globalHead1 is an non-initialized pointer to Node structure, containing anything but a correct memory reference (probably pointing to adress 0).

it lacks something like
device Node variableName;

globalHead1 = &variableName;

for globalHead1 pointing on something

Here i am not able to dereference temp1 or temp2. the effect of call xyz() should be like, temp1 = &node1, so *temp1 will automatically points to node1. but when I debug it, temp1 remains some garbage value like 0x02 instead &temp1. so it cannot dereference it. i am not able to see what is the problem. i guess it is somehow related to double pointer, though not sure.

node1 and node2 are local variables and hence will be mapped to registers…

I am not sure, what &node1 would translate in PTX…

Examine the PTX. You will have more clue.

Can I explicitly allocate that variable to a global memory? if I use device then only one shared copy will be created, so is there any support like volatile in ptx.

Are you allocaitng memory for globalHead1 and globalHead2 ??

btw,
Instead of XYZ() function, you could just say “node1 = globalHead1; node2 = globalHead2;”