Hi, look at the code below, it looks like acc_attach() does not work:
1 MODULE m_fields
2
3 real*8, allocatable, dimension(:,:,:), target :: qv
4 real*8, pointer, dimension(:,:,:) :: p_qv
5 !$acc declare create(p_qv, qv)
6
7 contains
8 subroutine fill_qv(n)
9 !$acc routine seq
10
11 INTEGER :: i,j,k
12 INTEGER, value :: n
13 do i=1, n
14 do j=1, n
15 do k=1,n
16 p_qv(i,j,k)=i+j+k
17 !qv(i,j,k)=i+j+k
18 end do
19 end do
20 end do
21
22 end subroutine fill_qv
23
24 END MODULE m_fields
25
26
27 program test_pointer
28 use m_fields
29 use openacc
30
31 integer :: i, j, k
32 integer :: n=10
33 !!$acc declare copyin(n)
34
35 allocate(qv(n,n,n))
36
37 !point p_qv to qv in the host
38 p_qv => qv
39
40 !point p_qv to qv in the device
41 call acc_attach(p_qv)
42
43 !!$acc serial present(p_qv)
44 !$acc kernels present(p_qv)
45
46 call fill_qv(n)
47
48 !$acc end kernels
49 !!$acc end serial
50
51 !$acc update host(qv)
52
53 print*, qv(n,n,n)
54
55 DEALLOCATE ( qv )
56
57 end program
compile and run:
TP# nvfortran -g -pg -Mlarge_arrays -m64 -Wall -Werror -gpu=ccall,managed,implicitsections -stdpar -traceback -ffpe-trap=invalid,zero,overflow -Minfo=accel -cpp -acc -o test_pointer_7 test_pointer_7.f90
fill_qv:
8, Generating acc routine seq
Generating NVIDIA GPU code
test_pointer:
44, Accelerator serial kernel generated
Generating NVIDIA GPU code
51, Generating update self(qv(:,:,:))
(rapids) TP# ./*7
libcupti.so not found
call to cuEventSynchronize returned error 700: Illegal address during kernel execution
Accelerator Kernel Timing data
(unknown)
(unknown) NVIDIA devicenum=0
time(us): 89
0: upload reached 3 times
0: data copyin transfers: 3
device time(us): total=89 max=42 min=19 avg=29
TP/test_pointer_7.f90
test_pointer NVIDIA devicenum=0
time(us): 0
44: compute region reached 1 time
44: kernel launched 1 time
grid: [1] block: [1]
device time(us): total=0 max=0 min=0 avg=0
However, it works if I directly use the allocable array variable in fill_qv. This is a small example, in my larger code, I cannot avoid using pointers.
Thanks.