You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tested this code. When I remove the blockIdx, such as the code as follows:
__global__ void myfirstkernel(void) {
//blockIdx.x gives the block number of current kernel
//printf("Hello!!!I'm thread in block: %d\n", blockIdx.x);
printf("Hello!!!I'm thread in block: %d\n");
}
int main(void) {
//A kernel call with 16 blocks and 1 thread per block
myfirstkernel << <16, 1 >> > ();
//Function used for waiting for all kernels to finish
cudaDeviceSynchronize();
printf("All threads are finished!\n");
return 0;
}
I can not get the kernel running results as the book shows. Just as:
If add blockIdx back, as printf("Hello!!!I'm thread in block: %d\n", blockIdx.x) then I get the right results.
Why?
The text was updated successfully, but these errors were encountered:
I have tested this code. When I remove the blockIdx, such as the code as follows:
I can not get the kernel running results as the book shows. Just as:
If add blockIdx back, as
printf("Hello!!!I'm thread in block: %d\n", blockIdx.x)
then I get the right results.Why?
The text was updated successfully, but these errors were encountered: