I have a nested device function (which does not work).
The function is called from inside another device function from within a for loop
In an effort to debug cuda.cuh r1.16 I have added the following printf to the inner function
if(I==99 && blockIdx.x==0 && threadIdx.x==0)
printf("%d,%u,%u %d, %d\n",
0,lastpos,data,
0,0);
It appears to produce:
0,0,67107912 0, 67107872
I would expect I to be 99 on the first iterration of the for loop.
I cannot see why it prints “67107872” rather than “0”.
Are the variables ‘lastpos’ and ‘data’ of type ‘unsigned int’? If not, a type mismatch between data and format specifier may be the issue. Since we cannot see the rest of the code, it is also possible that the values of those variables are exactly as printed, just different from what you expect, maybe due to integer overflow or an implicit signed-to-unsigned conversion elsewhere in the code.
Dear njuffa,
Thank you for your rapid reply.
Here is the inner function’s header device unsigned char read_char(const int I, unsigned int * lastpos, unsigned int * data )
If it makes any difference, at this point (I would expect) both lastpos and data to be
pointers to variables which had not been assigned a value. read_char() sets them both up.
Is there anything which would cause %d to pick up rubbish in place of the zero passed to printf() ?