Compiler Version:
nvfortran 23.7-0 64-bit target on x86-64 Linux -tp icelake-server
Problem Description:
When compiling Fortran code using OpenACC, nvfortran 23.7
fails to recognize the !$acc routine
directive for a subroutine defined within a separate module file. This results in an error when the subroutine is called from an !$acc parallel
region in another file. The issue persists even when compiling both files simultaneously or using separate compilation steps.
Test:
test.F90:
program test
use thompson
implicit none
integer, parameter :: n = 100, m = 100
real :: A(n, m), B(n, m), C(n, m)
integer :: i
B = 1.0
C = 2.0
!$acc data copy(A) copyin(B, C)
!$acc parallel loop gang private(i)
do i = 1, n
call sum(i, A, B, C, m) ! Line 15
end do
!$acc end parallel loop
!$acc end data
print *, "A(1,1) = ", A(1,1)
end program test
thompson.F90:
module thompson
implicit none
contains
!$acc routine
subroutine sum(i, A, B, C, m)
integer, intent(in) :: i, m
real, intent(inout) :: A(:, :)
real, intent(in) :: B(:, :), C(:, :)
integer :: j
do j = 1, m
A(i, j) = B(i, j) + C(i, j)
end do
end subroutine sum
end module thompson
compilation command and error:
nvfortran -acc -Minfo=accel -o test thompson.F90 test.F90
thompson.F90:
test.F90:
NVFORTRAN-S-1061-Procedures called in a compute region must have acc routine information - sum (test.F90: 15)
test:
12, Generating copy(a(:,:)) [if not already present]
Generating copyin(c(:,:),b(:,:)) [if not already present]
15, Accelerator restriction: call to ‘sum’ with no acc routine information
0 inform, 0 warnings, 1 severes, 0 fatal for test
When the subroutine is located in the same file as main function, acc routine works well, but when it is in a seperate file or module, it doesnt work.