6 integer, allocatable
:: block(:,:)
8 procedure
:: initialize
11 type, extends(compute
) :: cpu_compute
14 procedure
:: setblocksize
17 type, extends(compute
) :: gpu_compute
21 integer, allocatable
:: gpu_block(:,:)
28 subroutine initialize(c
, length
, width
)
36 allocate (c
%block(length
, width
))
43 end subroutine initialize
45 subroutine setdims(c
, g
, w
, v
)
47 class(gpu_compute
) :: c
54 end subroutine setdims
56 subroutine setblocksize(c
, bs
)
58 class(cpu_compute
) :: c
61 end subroutine setblocksize
63 end module wrapper_mod
68 class(compute
), allocatable
, target
:: mycomp
71 allocate(gpu_compute
::mycomp
)
73 call mycomp
%initialize(1024,1024)
75 !$acc enter data copyin(mycomp)
79 call mycomp
%setblocksize(32)
81 call mycomp
%setdims(32,32,32)
82 allocate(mycomp
%gpu_block(1024,1024))
83 !$acc update device(mycomp)
84 !$acc parallel copyin(mycomp%block) copyout(mycomp%gpu_block)
85 !$acc loop gang worker vector collapse(2)
88 mycomp
%gpu_block(i
,j
) = mycomp
%block(i
,j
) + 1
94 !$acc exit data copyout(mycomp)
96 select
type (g
=> mycomp
)
100 if (g
%gpu_block(i
,j
) .ne
. i
+ j
+ 1) stop 1