Nvfortran: do while within OpenACC kernels construct

Hi, the following program fails to compile with nvfortran -acc -o dont dont.f90:

program dont

integer :: sad = 7

!$acc kernels
do while (sad < 3 .OR. sad > 5)
  sad = sad + 1
end do
!$acc end kernels

end program dont

The compiler crashes with NVFORTRAN-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Missing branch target block.

Cheers,
-Nuno

Don’t code like this or you will be sad.
The while loop is not countable, which means it cannot be parallelized by our compiler. So our options for a kernels region is to run it sequentially, either on the host or device. The Minfo message looks like it is trying to generate a serial kernel, but then aborts. I opened up a bug for this, FS#34100.

Don’t code like this or you will be sad.

😇

The while loop is not countable, which means it cannot be parallelized by our compiler. So our options for a kernels region is to run it sequentially, either on the host or device. The Minfo message looks like it is trying to generate a serial kernel, but then aborts.

Indeed, I should’ve probably mentioned that the compiler is happy with a simpler condition such as

!$acc kernels
do while (sad < 3)
  sad = sad + 1
end do
!$acc end kernels

I opened up a bug for this, FS#34100.

Thanks!