[flang-commits] [flang] [flang][openacc] Ignore bare acc routine in module subprogram part instead of erroring out (PR #205450)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Jun 24 11:52:20 PDT 2026


clementval wrote:

> Valentin, what happens if there are more than 1 module procedures? In NV the ROUTINE directive seems to create acc routines for all CONTAINed procedures:
> 
> `$ nvfortran -acc=gpu -Minfo=accel -g -fast test2.f90 acc_routine1: 4, Generating implicit acc routine seq Generating implicit acc routine seq Generating NVIDIA GPU code acc_routine2: 8, Generating implicit acc routine seq Generating implicit acc routine seq Generating NVIDIA GPU code testem: 19, Generating copyout(arg) [if not already present] Generating NVIDIA GPU code 20, !$acc loop gang ! blockidx%x rogreen at sky6:~/quad/llvm205450$ rogreen at sky6:~/quad/llvm205450$ rogreen at sky6:~/quad/llvm205450$ cat test2.f90 module acc_routine_bad contains !$acc routine subroutine acc_routine1(arg) integer, intent(inout) :: arg arg = 1 end subroutine subroutine acc_routine2(arg) integer, intent(inout) :: arg arg = 2 end subroutine end module
> 
> program testem use acc_routine_bad implicit none integer :: i,arg
> 
> !$acc parallel loop copyout(arg) do i=1,2 call acc_routine1(arg) call acc_routine2(arg) end do
> 
> print*, "arg ", arg end program testem rogreen at sky6:~/quad/llvm205450$ nvfortran -acc=gpu -Minfo=accel -g -fast test2.f90 acc_routine1: 4, Generating implicit acc routine seq Generating implicit acc routine seq Generating NVIDIA GPU code acc_routine2: 8, Generating implicit acc routine seq Generating implicit acc routine seq Generating NVIDIA GPU code testem: 19, Generating copyout(arg) [if not already present] Generating NVIDIA GPU code 20, !$acc loop gang ! blockidx%x rogreen at sky6:~/quad/llvm205450$ ./a.out arg 2 `

We would just error out on the first invalid `!$acc routine`. This is the current behavior as in https://github.com/llvm/llvm-project/blob/89ff26442d773dbf8d6dbd5b8908e4d9eef04ef2/flang/test/Semantics/OpenACC/acc-routine-validity.f90#L15.  

https://github.com/llvm/llvm-project/pull/205450


More information about the flang-commits mailing list