I’m writing a kernel and have come across a rather unique situation. I have a logical variable in the global device memory called d_flag, which is initially set to ‘true’. I call this subroutine while inside the kernel:
attributes(device) subroutine devicesub (tid) integer, intent(in), value :: tid if (tid.eq.1) then d_flag = .false. call syncthreads() else do while (d_flag) call syncthreads() end do endif end subroutine devicesub
If I launch a kernel with 4 threads for example, when I call this subroutine the first thread is supposed to go through the first conditional branch while the other 3 threads go through the ‘else’ branch. These 3 threads are supposed to keep calling syncthreads() until d_flag is set to false. But this doesn’t happen, when I run the program it just gets stuck in this ‘do while’ loop forever.
Please let me know where I’m going wrong, thanks.