ThreadIdx.y is not working

In my code :


    block = (3,3);
grid = (1,1);

     test<<<grid, block>>>();


global void test(){

    int k = threadIdx.x;
int y = threadIdx.y;

printf("T.x = %d\t",k);
printf("T.y = %d\n",y);


I show the Thread index, k is printed 0 to 2 but y display 0. What’s wrong ?

You’re initializing the block and grid variables in a way that isn’t at all what you think you’re doing. You can’t initialize them with " = (3,3)". In C, this invokes the COMMA operator, but on a constant, so it’s ignored, so you just have a (3) in parentheses, so that’s a simple scalar initializer.

Initialize them like:

dim3 blocks(3,3);


dim3 blocks;


Thank you so much… ^___^