Hello
I want to ask about using openACC at fortran.
I used nvhpc/22.11 and nvfortran compiler.
I meet complie error below message
(trdiag3p_gpu = subroutine_in)
nvlink error : Undefined reference to ‘trdiag3p_gpu_’ in ‘lica.o’
pgacclnk: child process exit status 2: /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/compilers/bin/tools/nvdd
make: *** [Makefile:27: lica] Error 2
I don’t know correct openACC useage.
As you know “subroutine_out” is parallelized by !$acc parallel, !$acc loop and call the “subroutine_in”.
AK, BK, CK, GK array are already exist gpu buffer.
I use !$acc enter data copyin AK, BK, CK, GK in subroutine_out.
As i known fortran always call by reference so when in the subroutine_in the “A” means “AK” array.
In “subroutine_in” i want to use array such as A, B, C, F (my opinion it is AK, BK, CK, GK) but when i use these array i meet nvlink error.
Could i ask this problem?
And also i already search about !$acc routine and find this Q&A.
[Since PGI doesn’t support nested parallelism,]
If i understand this Q&A correct, I already parallel compute at the outer function(subroutine_out). So i have to call subroutine_in sequential? is it right?
Through this forums , I have already helped you a lot.
Thanks. Mat Colgrove
(I have security issue, so i block most of codes.
If you need more information, please tell me.)
PROGRAM MAIN
......
......
call subroutine_out()
......
......
STOP
END
SUBROUTINE subroutine_out
USE MOD_COMMON
IMPLICIT NONE
INTEGER*8 :: I,J,K
REAL*8 :: CRE
REAL*8, DIMENSION (:,:), ALLOCATABLE :: AK,BK,CK,GK
!$acc routine(subroutine_in)
allocate(AK(M1,M3),BK(M1,M3),CK(M1,M3),GK(M1,M3))
!$acc enter data copyin ( AK(1:M1, 1:M3), BK(1:M1, 1:M3), CK(1:M1, 1:M3), GK(1:M1, 1:M3) )
!$acc enter data copyin ( RHS1(0:M1, 0:M2, 0:M3, 3) )
! RHS1 define at MOD_COMMON
!$acc parallel
!$acc loop
do J=1,200
!$acc loop collapse(2) !independent
do K=1,500
do I=1,N1M
AK(I,K)= ......
BK(I,K)= ......
CK(I,K)= ......
GK(I,K)= ......
enddo
enddo
!$acc end loop
CALL subroutine_in(AK,BK,CK,GK,1,500,1,500)
!$acc loop collapse(2) independent
do K=1,500
do I=1,500
RHS1(I,J,K,1)= ......
enddo
enddo
!$acc end loop
enddo
!$acc end loop
!$acc end parallel
!$acc exit data delete ( AK(1:M1, 1:M3), BK(1:M1, 1:M3), CK(1:M1, 1:M3), GK(1:M1, 1:M3) )
END
SUBROUTINE subroutine_in(A, B, C, F, J1,J2,L1,L2)
!$acc routine seq
!seq or vector
USE MOD_COMMON
IMPLICIT NONE
REAL*8 :: A(M1,M3),B(M1,M3),C(M1,M3),F(M1,M3)
INTEGER*8 :: J1,J2,L1,L2
INTEGER*8 :: I,J,K
REAL*8 :: Q(M1,M3),S(M1,M3),FN(M1)
REAL*8 :: BINV
!$acc data present ( A(1:M1, 1:M3), B(1:M1, 1:M3), C(1:M1, 1:M3), F(1:M1, 1:M3) )
!$acc data copyin ( Q(M1,M3), S(M1,M3), QE(M1,M3), FN(M1), PN(M1) )
do K=L1,L2
BINV= ......
Q(K,J1)= ......
S(K,J1)= ......
FN(K)= ......
F(K,J1)= ......
enddo
!$acc end data
!$acc end data
END