NVIDIA OpenACC extension

I was experimenting with some Fortran codebase that was meant to be compiled with nvfortran.
And I got an error with both gfortran and flang for the following MRE.
a.f90 file:

subroutine foo()
end subroutine foo

b.f90 file:

subroutine bar()
    !$acc routine (foo) seq
end subroutine bar

The error for flang is error: No function or subroutine declared for 'foo'. This can be fixed with adding external foo to the bar.
I wonder if this extension could be implemented in flang and accepted? For sure, it have to be disabled by default and enabled by a flag.

I guess you have a call to foo inside bar otherwise the code does not really makes sense to me?

Yes, sure! I just created the example to be as minimal as possible.

I guess we will probably have extension in flang similar to what is done for OpenMP in clang. I’m not sure it makes sense to add it now since the support for OpenACC is still under development and even the basic case is not working.

Interesting. Per my understanding of Fortran, a call foo constitutes an implicit external foo – but that’s not yet visible at the time the !$acc routine (foo) is handled.

subroutine bar()
  !external foo
  !$acc routine (foo) gang

  !$acc parallel
  call foo
  !$acc end parallel
end subroutine bar

That’s similar to GCC https://gcc.gnu.org/PR98915 “OpenACC ‘routine with a name’ directive does not compile”.

And, there’s discussion in the OpenACC issue tracker https://github.com/OpenACC/openacc-spec/issues/345 (need to be a member of the GitHub OpenACC organization to see this), about whether OpenACC needs to clarify/specify how such and a few other scenarios ought to be handled.

I agree that extensions should be added after the standard functionality is supported.

Yep, you seem to be right.

This is great, I hope it resolves in the best possible way. But it’s kind of sad that OpenACC specification discussions are closed from the public :frowning: