Skip to content

Commit 8f6000f

Browse files
committed
Fix OpenACC files
1 parent b60fc25 commit 8f6000f

17 files changed

+360
-126
lines changed

openacc/psb_c_oacc_csr_mat_mod.F90

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,15 @@ subroutine c_oacc_csr_free_dev_space(a)
144144
! but with size 0, then CREATE,UPDATE and DELETE
145145
! will fail
146146
!
147-
if (psb_size(a%val)>0) call acc_delete_finalize(a%val)
148-
if (psb_size(a%ja)>0) call acc_delete_finalize(a%ja)
149-
if (psb_size(a%irp)>0) call acc_delete_finalize(a%irp)
147+
if (psb_size(a%val)>0) then
148+
!$acc exit data delete(a%val) finalize
149+
end if
150+
if (psb_size(a%ja)>0) then
151+
!$acc exit data delete(a%ja) finalize
152+
end if
153+
if (psb_size(a%irp)>0) then
154+
!$acc exit data delete(a%irp) finalize
155+
end if
150156

151157
return
152158
end subroutine c_oacc_csr_free_dev_space
@@ -257,9 +263,15 @@ subroutine c_oacc_csr_sync_dev_space(a)
257263
! but with size 0, then CREATE,UPDATE and DELETE
258264
! will fail
259265
!
260-
if (psb_size(a%val)>0) call acc_copyin(a%val)
261-
if (psb_size(a%ja)>0) call acc_copyin(a%ja)
262-
if (psb_size(a%irp)>0) call acc_copyin(a%irp)
266+
if (psb_size(a%val)>0) then
267+
!$acc enter data copyin(a%val)
268+
end if
269+
if (psb_size(a%ja)>0) then
270+
!$acc enter data copyin(a%ja)
271+
end if
272+
if (psb_size(a%irp)>0) then
273+
!$acc enter data copyin(a%irp)
274+
end if
263275
end subroutine c_oacc_csr_sync_dev_space
264276

265277
subroutine c_oacc_csr_sync(a)
@@ -275,13 +287,25 @@ subroutine c_oacc_csr_sync(a)
275287
! will fail
276288
!
277289
if (a%is_dev()) then
278-
if (psb_size(a%val)>0) call acc_update_self(a%val)
279-
if (psb_size(a%ja)>0) call acc_update_self(a%ja)
280-
if (psb_size(a%irp)>0) call acc_update_self(a%irp)
290+
if (psb_size(a%val)>0) then
291+
!$acc update self(a%val)
292+
end if
293+
if (psb_size(a%ja)>0) then
294+
!$acc update self(a%ja)
295+
end if
296+
if (psb_size(a%irp)>0) then
297+
!$acc update self(a%irp)
298+
end if
281299
else if (a%is_host()) then
282-
if (psb_size(a%val)>0) call acc_update_device(a%val)
283-
if (psb_size(a%ja)>0) call acc_update_device(a%ja)
284-
if (psb_size(a%irp)>0) call acc_update_device(a%irp)
300+
if (psb_size(a%val)>0) then
301+
!$acc update device(a%val)
302+
end if
303+
if (psb_size(a%ja)>0) then
304+
!$acc update device(a%ja)
305+
end if
306+
if (psb_size(a%irp)>0) then
307+
!$acc update device(a%irp)
308+
end if
285309
end if
286310
call tmpa%set_sync()
287311
end subroutine c_oacc_csr_sync

openacc/psb_c_oacc_ell_mat_mod.F90

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,18 @@ subroutine c_oacc_ell_free_dev_space(a)
143143
! but with size 0, then CREATE,UPDATE and DELETE
144144
! will fail
145145
!
146-
if (psb_size(a%val)>0) call acc_delete_finalize(a%val)
147-
if (psb_size(a%ja)>0) call acc_delete_finalize(a%ja)
148-
if (psb_size(a%irn)>0) call acc_delete_finalize(a%irn)
149-
if (psb_size(a%idiag)>0) call acc_delete_finalize(a%idiag)
146+
if (psb_size(a%val)>0) then
147+
!$acc exit data delete(a%val) finalize
148+
end if
149+
if (psb_size(a%ja)>0) then
150+
!$acc exit data delete(a%ja) finalize
151+
end if
152+
if (psb_size(a%irn)>0) then
153+
!$acc exit data delete(a%irn) finalize
154+
end if
155+
if (psb_size(a%idiag)>0) then
156+
!$acc exit data delete(a%idiag) finalize
157+
end if
150158
return
151159
end subroutine c_oacc_ell_free_dev_space
152160

@@ -170,7 +178,7 @@ function c_oacc_ell_sizeof(a) result(res)
170178
if (a%is_dev()) call a%sync()
171179

172180
res = 8
173-
res = res + psb_sizeof_dp * size(a%val)
181+
res = res + (2*psb_sizeof_sp) * size(a%val)
174182
res = res + psb_sizeof_ip * size(a%ja)
175183
res = res + psb_sizeof_ip * size(a%irn)
176184
res = res + psb_sizeof_ip * size(a%idiag)
@@ -186,10 +194,18 @@ subroutine c_oacc_ell_sync_dev_space(a)
186194
! but with size 0, then CREATE,UPDATE and DELETE
187195
! will fail
188196
!
189-
if (psb_size(a%val)>0) call acc_copyin(a%val)
190-
if (psb_size(a%ja)>0) call acc_copyin(a%ja)
191-
if (psb_size(a%irn)>0) call acc_copyin(a%irn)
192-
if (psb_size(a%idiag)>0) call acc_copyin(a%idiag)
197+
if (psb_size(a%val)>0) then
198+
!$acc enter data copyin(a%val)
199+
end if
200+
if (psb_size(a%ja)>0) then
201+
!$acc enter data copyin(a%ja)
202+
end if
203+
if (psb_size(a%irn)>0) then
204+
!$acc enter data copyin(a%irn)
205+
end if
206+
if (psb_size(a%idiag)>0) then
207+
!$acc enter data copyin(a%idiag)
208+
end if
193209
end subroutine c_oacc_ell_sync_dev_space
194210

195211
function c_oacc_ell_is_host(a) result(res)
@@ -256,15 +272,31 @@ subroutine c_oacc_ell_sync(a)
256272
! will fail
257273
!
258274
if (a%is_dev()) then
259-
if (psb_size(a%val)>0) call acc_update_self(a%val)
260-
if (psb_size(a%ja)>0) call acc_update_self(a%ja)
261-
if (psb_size(a%irn)>0) call acc_update_self(a%irn)
262-
if (psb_size(a%idiag)>0) call acc_update_self(a%idiag)
275+
if (psb_size(a%val)>0) then
276+
!$acc update self(a%val)
277+
end if
278+
if (psb_size(a%ja)>0) then
279+
!$acc update self(a%ja)
280+
end if
281+
if (psb_size(a%irn)>0) then
282+
!$acc update self(a%irn)
283+
end if
284+
if (psb_size(a%idiag)>0) then
285+
!$acc update self(a%idiag)
286+
end if
263287
else if (a%is_host()) then
264-
if (psb_size(a%val)>0) call acc_update_device(a%val)
265-
if (psb_size(a%ja)>0) call acc_update_device(a%ja)
266-
if (psb_size(a%irn)>0) call acc_update_device(a%irn)
267-
if (psb_size(a%idiag)>0) call acc_update_device(a%idiag)
288+
if (psb_size(a%val)>0) then
289+
!$acc update device(a%val)
290+
end if
291+
if (psb_size(a%ja)>0) then
292+
!$acc update device(a%ja)
293+
end if
294+
if (psb_size(a%irn)>0) then
295+
!$acc update device(a%irn)
296+
end if
297+
if (psb_size(a%idiag)>0) then
298+
!$acc update device(a%idiag)
299+
end if
268300
end if
269301
call tmpa%set_sync()
270302
end subroutine c_oacc_ell_sync

openacc/psb_c_oacc_hll_mat_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function c_oacc_hll_sizeof(a) result(res)
171171
if (a%is_dev()) call a%sync()
172172

173173
res = 8
174-
res = res + psb_sizeof_dp * size(a%val)
174+
res = res + (2*psb_sizeof_sp) * size(a%val)
175175
res = res + psb_sizeof_ip * size(a%ja)
176176
res = res + psb_sizeof_ip * size(a%irn)
177177
res = res + psb_sizeof_ip * size(a%idiag)

openacc/psb_c_oacc_vect_mod.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,10 @@ function c_inner_oacc_dot(n, x, y) result(res)
829829
complex(psb_spk_) :: res
830830
integer(psb_ipk_) :: i
831831

832+
res = czero
832833
!$acc parallel loop reduction(+:res) present(x, y)
833834
do i = 1, n
834-
res = res + x(i) * y(i)
835+
res = res + conjg(x(i)) * y(i)
835836
end do
836837
!$acc end parallel loop
837838
end function c_inner_oacc_dot
@@ -843,10 +844,10 @@ function c_oacc_dot_a(n, x, y) result(res)
843844
complex(psb_spk_), intent(in) :: y(:)
844845
integer(psb_ipk_), intent(in) :: n
845846
complex(psb_spk_) :: res
846-
complex(psb_spk_), external :: cdot
847+
complex(psb_spk_), external :: cdotc
847848

848849
if (x%is_dev()) call x%sync()
849-
res = cdot(n, y, 1, x%v, 1)
850+
res = cdotc(n, y, 1, x%v, 1)
850851

851852
end function c_oacc_dot_a
852853

@@ -943,6 +944,7 @@ subroutine c_oacc_vect_all(n, x, info)
943944
class(psb_c_vect_oacc), intent(out) :: x
944945
integer(psb_ipk_), intent(out) :: info
945946

947+
call x%free(info)
946948
call psb_realloc(n, x%v, info)
947949
if (info /= 0) then
948950
info = psb_err_alloc_request_

openacc/psb_d_oacc_csr_mat_mod.F90

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,15 @@ subroutine d_oacc_csr_free_dev_space(a)
144144
! but with size 0, then CREATE,UPDATE and DELETE
145145
! will fail
146146
!
147-
if (psb_size(a%val)>0) call acc_delete_finalize(a%val)
148-
if (psb_size(a%ja)>0) call acc_delete_finalize(a%ja)
149-
if (psb_size(a%irp)>0) call acc_delete_finalize(a%irp)
147+
if (psb_size(a%val)>0) then
148+
!$acc exit data delete(a%val) finalize
149+
end if
150+
if (psb_size(a%ja)>0) then
151+
!$acc exit data delete(a%ja) finalize
152+
end if
153+
if (psb_size(a%irp)>0) then
154+
!$acc exit data delete(a%irp) finalize
155+
end if
150156

151157
return
152158
end subroutine d_oacc_csr_free_dev_space
@@ -257,9 +263,15 @@ subroutine d_oacc_csr_sync_dev_space(a)
257263
! but with size 0, then CREATE,UPDATE and DELETE
258264
! will fail
259265
!
260-
if (psb_size(a%val)>0) call acc_copyin(a%val)
261-
if (psb_size(a%ja)>0) call acc_copyin(a%ja)
262-
if (psb_size(a%irp)>0) call acc_copyin(a%irp)
266+
if (psb_size(a%val)>0) then
267+
!$acc enter data copyin(a%val)
268+
end if
269+
if (psb_size(a%ja)>0) then
270+
!$acc enter data copyin(a%ja)
271+
end if
272+
if (psb_size(a%irp)>0) then
273+
!$acc enter data copyin(a%irp)
274+
end if
263275
end subroutine d_oacc_csr_sync_dev_space
264276

265277
subroutine d_oacc_csr_sync(a)
@@ -275,13 +287,25 @@ subroutine d_oacc_csr_sync(a)
275287
! will fail
276288
!
277289
if (a%is_dev()) then
278-
if (psb_size(a%val)>0) call acc_update_self(a%val)
279-
if (psb_size(a%ja)>0) call acc_update_self(a%ja)
280-
if (psb_size(a%irp)>0) call acc_update_self(a%irp)
290+
if (psb_size(a%val)>0) then
291+
!$acc update self(a%val)
292+
end if
293+
if (psb_size(a%ja)>0) then
294+
!$acc update self(a%ja)
295+
end if
296+
if (psb_size(a%irp)>0) then
297+
!$acc update self(a%irp)
298+
end if
281299
else if (a%is_host()) then
282-
if (psb_size(a%val)>0) call acc_update_device(a%val)
283-
if (psb_size(a%ja)>0) call acc_update_device(a%ja)
284-
if (psb_size(a%irp)>0) call acc_update_device(a%irp)
300+
if (psb_size(a%val)>0) then
301+
!$acc update device(a%val)
302+
end if
303+
if (psb_size(a%ja)>0) then
304+
!$acc update device(a%ja)
305+
end if
306+
if (psb_size(a%irp)>0) then
307+
!$acc update device(a%irp)
308+
end if
285309
end if
286310
call tmpa%set_sync()
287311
end subroutine d_oacc_csr_sync

openacc/psb_d_oacc_ell_mat_mod.F90

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,18 @@ subroutine d_oacc_ell_free_dev_space(a)
143143
! but with size 0, then CREATE,UPDATE and DELETE
144144
! will fail
145145
!
146-
if (psb_size(a%val)>0) call acc_delete_finalize(a%val)
147-
if (psb_size(a%ja)>0) call acc_delete_finalize(a%ja)
148-
if (psb_size(a%irn)>0) call acc_delete_finalize(a%irn)
149-
if (psb_size(a%idiag)>0) call acc_delete_finalize(a%idiag)
146+
if (psb_size(a%val)>0) then
147+
!$acc exit data delete(a%val) finalize
148+
end if
149+
if (psb_size(a%ja)>0) then
150+
!$acc exit data delete(a%ja) finalize
151+
end if
152+
if (psb_size(a%irn)>0) then
153+
!$acc exit data delete(a%irn) finalize
154+
end if
155+
if (psb_size(a%idiag)>0) then
156+
!$acc exit data delete(a%idiag) finalize
157+
end if
150158
return
151159
end subroutine d_oacc_ell_free_dev_space
152160

@@ -186,10 +194,18 @@ subroutine d_oacc_ell_sync_dev_space(a)
186194
! but with size 0, then CREATE,UPDATE and DELETE
187195
! will fail
188196
!
189-
if (psb_size(a%val)>0) call acc_copyin(a%val)
190-
if (psb_size(a%ja)>0) call acc_copyin(a%ja)
191-
if (psb_size(a%irn)>0) call acc_copyin(a%irn)
192-
if (psb_size(a%idiag)>0) call acc_copyin(a%idiag)
197+
if (psb_size(a%val)>0) then
198+
!$acc enter data copyin(a%val)
199+
end if
200+
if (psb_size(a%ja)>0) then
201+
!$acc enter data copyin(a%ja)
202+
end if
203+
if (psb_size(a%irn)>0) then
204+
!$acc enter data copyin(a%irn)
205+
end if
206+
if (psb_size(a%idiag)>0) then
207+
!$acc enter data copyin(a%idiag)
208+
end if
193209
end subroutine d_oacc_ell_sync_dev_space
194210

195211
function d_oacc_ell_is_host(a) result(res)
@@ -256,15 +272,31 @@ subroutine d_oacc_ell_sync(a)
256272
! will fail
257273
!
258274
if (a%is_dev()) then
259-
if (psb_size(a%val)>0) call acc_update_self(a%val)
260-
if (psb_size(a%ja)>0) call acc_update_self(a%ja)
261-
if (psb_size(a%irn)>0) call acc_update_self(a%irn)
262-
if (psb_size(a%idiag)>0) call acc_update_self(a%idiag)
275+
if (psb_size(a%val)>0) then
276+
!$acc update self(a%val)
277+
end if
278+
if (psb_size(a%ja)>0) then
279+
!$acc update self(a%ja)
280+
end if
281+
if (psb_size(a%irn)>0) then
282+
!$acc update self(a%irn)
283+
end if
284+
if (psb_size(a%idiag)>0) then
285+
!$acc update self(a%idiag)
286+
end if
263287
else if (a%is_host()) then
264-
if (psb_size(a%val)>0) call acc_update_device(a%val)
265-
if (psb_size(a%ja)>0) call acc_update_device(a%ja)
266-
if (psb_size(a%irn)>0) call acc_update_device(a%irn)
267-
if (psb_size(a%idiag)>0) call acc_update_device(a%idiag)
288+
if (psb_size(a%val)>0) then
289+
!$acc update device(a%val)
290+
end if
291+
if (psb_size(a%ja)>0) then
292+
!$acc update device(a%ja)
293+
end if
294+
if (psb_size(a%irn)>0) then
295+
!$acc update device(a%irn)
296+
end if
297+
if (psb_size(a%idiag)>0) then
298+
!$acc update device(a%idiag)
299+
end if
268300
end if
269301
call tmpa%set_sync()
270302
end subroutine d_oacc_ell_sync

openacc/psb_d_oacc_vect_mod.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,10 @@ function d_inner_oacc_dot(n, x, y) result(res)
829829
real(psb_dpk_) :: res
830830
integer(psb_ipk_) :: i
831831

832+
res = dzero
832833
!$acc parallel loop reduction(+:res) present(x, y)
833834
do i = 1, n
834-
res = res + x(i) * y(i)
835+
res = res + (x(i)) * y(i)
835836
end do
836837
!$acc end parallel loop
837838
end function d_inner_oacc_dot
@@ -943,6 +944,7 @@ subroutine d_oacc_vect_all(n, x, info)
943944
class(psb_d_vect_oacc), intent(out) :: x
944945
integer(psb_ipk_), intent(out) :: info
945946

947+
call x%free(info)
946948
call psb_realloc(n, x%v, info)
947949
if (info /= 0) then
948950
info = psb_err_alloc_request_

openacc/psb_i_oacc_vect_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ subroutine i_oacc_vect_all(n, x, info)
547547
class(psb_i_vect_oacc), intent(out) :: x
548548
integer(psb_ipk_), intent(out) :: info
549549

550+
call x%free(info)
550551
call psb_realloc(n, x%v, info)
551552
if (info /= 0) then
552553
info = psb_err_alloc_request_

openacc/psb_l_oacc_vect_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ subroutine l_oacc_vect_all(n, x, info)
549549
class(psb_l_vect_oacc), intent(out) :: x
550550
integer(psb_ipk_), intent(out) :: info
551551

552+
call x%free(info)
552553
call psb_realloc(n, x%v, info)
553554
if (info /= 0) then
554555
info = psb_err_alloc_request_

0 commit comments

Comments
 (0)