ThreadIdx.y is not working

In my code :

main(){

    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);

not

dim3 blocks;

blocks=(3,3);

Thank you so much… ^___^