Doubts with using printf statement

Hi All,
I’m trying to debug a code and using printf in the kernel code for the same. In my kernel code I have a statement like this

printf(“Entering thread Id is %d\n”, threadIdx.x);

When I execute the kernel it doesn’t print the 0 thread id. Again when I change the printf to this statement

if(threadIdx.x == 0)
printf(“Entering thread Id is %d\n”, threadIdx.x);

now it prints that 0 thread is entering.

Does this mean printf doesn’t print all the statements…?


When I’m including the if statement my code execution flow is changing and it is printing…?

I doubt the latter case but are there chances of it…?

M. Kiran Kumar.