error in using threadIdx.x as integer

Hi

When I am assigning value as below:

s_data is shared memory.

float val=5;
s_data[threadIdx.x]=val;( some garbage value got assigned)

If I do the below steps;
int x=threadIdx.x;
s_data[x]=val; ( correct value got assigned)

Someone please let me know if am doing anything wrong.

Thanks in advance.

Can you post more of your “surrounding” code plz? Both methods seem to be correct…

Can you post more of your “surrounding” code plz? Both methods seem to be correct…

If I had to guess, it’s probably a compiler bug…maybe threadIdx.x isn’t being converted to an int when it’s used as an index value, but the generated binary is still reading an int from wherever the value is stored (and thus, the top 2 bytes of the value used as the index aren’t zero, but something else).

If I had to guess, it’s probably a compiler bug…maybe threadIdx.x isn’t being converted to an int when it’s used as an index value, but the generated binary is still reading an int from wherever the value is stored (and thus, the top 2 bytes of the value used as the index aren’t zero, but something else).

Thanks for the reply.
I forgot where that code was,please give me sometime .

As soon as I find the code I will post it.

Thanks for the reply.
I forgot where that code was,please give me sometime .

As soon as I find the code I will post it.