Introduce submodules, adjust Makefile

oacc_loloum
sfilippone 6 months ago
parent 0707cc0a72
commit 7006665d82

@ -2,6 +2,7 @@ include ../../Make.inc
LIBDIR=../../lib LIBDIR=../../lib
INCDIR=../../include INCDIR=../../include
MODDIR=../../modules MODDIR=../../modules
UP=..
# #
# Compilers and such # Compilers and such
# #
@ -22,6 +23,17 @@ objs: $(OBJS)
lib: objs lib: objs
ar cur ../$(LIBNAME) $(OBJS) ar cur ../$(LIBNAME) $(OBJS)
psb_d_oacc_csr_vect_mv.o psb_d_oacc_csr_inner_vect_sv.o \
psb_d_oacc_csr_csmm.o psb_d_oacc_csr_csmv.o psb_d_oacc_csr_scals.o \
psb_d_oacc_csr_scal.o psb_d_oacc_csr_allocate_mnnz.o \
psb_d_oacc_csr_reallocate_nz.o psb_d_oacc_csr_cp_from_coo.o \
psb_d_oacc_csr_cp_from_fmt.o psb_d_oacc_csr_mv_from_coo.o \
psb_d_oacc_csr_mv_from_fmt.o psb_d_oacc_csr_mold.o: $(UP)/psb_d_oacc_csr_mat_mod.o
psb_d_oacc_mlt_v_2.o psb_d_oacc_mlt_v.o: $(UP)/psb_d_oacc_vect_mod.o
clean: clean:
/bin/rm -f $(OBJS) /bin/rm -f $(OBJS)

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_allocate_mnnz(m, n, a, nz) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_allocate_mnnz_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_allocate_mnnz contains
module subroutine psb_d_oacc_csr_allocate_mnnz(m, n, a, nz)
implicit none implicit none
integer(psb_ipk_), intent(in) :: m, n integer(psb_ipk_), intent(in) :: m, n
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -27,8 +28,8 @@ subroutine psb_d_oacc_csr_allocate_mnnz(m, n, a, nz)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_allocate_mnnz end subroutine psb_d_oacc_csr_allocate_mnnz
end submodule psb_d_oacc_csr_allocate_mnnz_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_cp_from_coo(a, b, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_cp_from_coo_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_cp_from_coo contains
module subroutine psb_d_oacc_csr_cp_from_coo(a, b, info)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -17,9 +18,9 @@ subroutine psb_d_oacc_csr_cp_from_coo(a, b, info)
return return
9999 continue 9999 continue
info = psb_err_alloc_dealloc_ info = psb_err_alloc_dealloc_
return return
end subroutine psb_d_oacc_csr_cp_from_coo end subroutine psb_d_oacc_csr_cp_from_coo
end submodule psb_d_oacc_csr_cp_from_coo_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_cp_from_fmt(a, b, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_cp_from_fmt_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_cp_from_fmt contains
module subroutine psb_d_oacc_csr_cp_from_fmt(a, b, info)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -19,5 +20,5 @@ subroutine psb_d_oacc_csr_cp_from_fmt(a, b, info)
!$acc update device(a%val, a%ja, a%irp) !$acc update device(a%val, a%ja, a%irp)
end select end select
end subroutine psb_d_oacc_csr_cp_from_fmt end subroutine psb_d_oacc_csr_cp_from_fmt
end submodule psb_d_oacc_csr_cp_from_fmt_impl

@ -1,8 +1,7 @@
subroutine psb_d_oacc_csr_csmm(alpha, a, x, beta, y, info, trans) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_csmm_impl
use psb_base_mod use psb_base_mod
!use elldev_mod contains
!use psb_vectordev_mod module subroutine psb_d_oacc_csr_csmm(alpha, a, x, beta, y, info, trans)
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_csmm
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
@ -79,8 +78,9 @@ subroutine psb_d_oacc_csr_csmm(alpha, a, x, beta, y, info, trans)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_csmm end subroutine psb_d_oacc_csr_csmm
end submodule psb_d_oacc_csr_csmm_impl

@ -1,8 +1,7 @@
subroutine psb_d_oacc_csr_csmv(alpha, a, x, beta, y, info, trans) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_csmv_impl
use psb_base_mod use psb_base_mod
!use elldev_mod contains
!use psb_vectordev_mod module subroutine psb_d_oacc_csr_csmv(alpha, a, x, beta, y, info, trans)
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_csmv
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
@ -74,8 +73,9 @@ subroutine psb_d_oacc_csr_csmv(alpha, a, x, beta, y, info, trans)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_csmv end subroutine psb_d_oacc_csr_csmv
end submodule psb_d_oacc_csr_csmv_impl

@ -1,9 +1,7 @@
subroutine psb_d_oacc_csr_inner_vect_sv(alpha, a, x, beta, y, info, trans) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_inner_vect_sv_impl
use psb_base_mod use psb_base_mod
! use elldev_mod contains
! use psb_vectordev_mod module subroutine psb_d_oacc_csr_inner_vect_sv(alpha, a, x, beta, y, info, trans)
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_inner_vect_sv
use psb_d_oacc_vect_mod
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
@ -78,7 +76,8 @@ subroutine psb_d_oacc_csr_inner_vect_sv(alpha, a, x, beta, y, info, trans)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_inner_vect_sv end subroutine psb_d_oacc_csr_inner_vect_sv
end submodule psb_d_oacc_csr_inner_vect_sv_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_mold(a, b, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_mold_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_mold contains
module subroutine psb_d_oacc_csr_mold(a, b, info)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
class(psb_d_base_sparse_mat), intent(inout), allocatable :: b class(psb_d_base_sparse_mat), intent(inout), allocatable :: b
@ -25,9 +26,10 @@ subroutine psb_d_oacc_csr_mold(a, b, info)
end if end if
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_mold end subroutine psb_d_oacc_csr_mold
end submodule psb_d_oacc_csr_mold_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_mv_from_coo(a, b, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_mv_from_coo_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_mv_from_coo contains
module subroutine psb_d_oacc_csr_mv_from_coo(a, b, info)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -16,9 +17,9 @@ subroutine psb_d_oacc_csr_mv_from_coo(a, b, info)
return return
9999 continue 9999 continue
info = psb_err_alloc_dealloc_ info = psb_err_alloc_dealloc_
return return
end subroutine psb_d_oacc_csr_mv_from_coo end subroutine psb_d_oacc_csr_mv_from_coo
end submodule psb_d_oacc_csr_mv_from_coo_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_mv_from_fmt(a, b, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_mv_from_fmt_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_mv_from_fmt contains
module subroutine psb_d_oacc_csr_mv_from_fmt(a, b, info)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -19,5 +20,5 @@ subroutine psb_d_oacc_csr_mv_from_fmt(a, b, info)
!$acc update device(a%val, a%ja, a%irp) !$acc update device(a%val, a%ja, a%irp)
end select end select
end subroutine psb_d_oacc_csr_mv_from_fmt end subroutine psb_d_oacc_csr_mv_from_fmt
end submodule psb_d_oacc_csr_mv_from_fmt_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_reallocate_nz(nz, a) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_reallocate_nz_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_reallocate_nz contains
module subroutine psb_d_oacc_csr_reallocate_nz(nz, a)
implicit none implicit none
integer(psb_ipk_), intent(in) :: nz integer(psb_ipk_), intent(in) :: nz
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
@ -20,8 +21,8 @@ subroutine psb_d_oacc_csr_reallocate_nz(nz, a)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_reallocate_nz end subroutine psb_d_oacc_csr_reallocate_nz
end submodule psb_d_oacc_csr_reallocate_nz_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_scal(d, a, info, side) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_scal_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_scal contains
module subroutine psb_d_oacc_csr_scal(d, a, info, side)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
real(psb_dpk_), intent(in) :: d(:) real(psb_dpk_), intent(in) :: d(:)
@ -45,8 +46,8 @@ subroutine psb_d_oacc_csr_scal(d, a, info, side)
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_scal end subroutine psb_d_oacc_csr_scal
end submodule psb_d_oacc_csr_scal_impl

@ -1,32 +1,34 @@
subroutine psb_d_oacc_csr_scals(d, a, info) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_scals_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_scals contains
implicit none module subroutine psb_d_oacc_csr_scals(d, a, info)
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a implicit none
real(psb_dpk_), intent(in) :: d class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
integer(psb_ipk_), intent(out) :: info real(psb_dpk_), intent(in) :: d
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_) :: err_act integer(psb_ipk_) :: err_act
character(len=20) :: name='scal' character(len=20) :: name='scal'
logical, parameter :: debug=.false. logical, parameter :: debug=.false.
integer(psb_ipk_) :: i integer(psb_ipk_) :: i
info = psb_success_ info = psb_success_
call psb_erractionsave(err_act) call psb_erractionsave(err_act)
if (a%is_host()) call a%sync() if (a%is_host()) call a%sync()
!$acc parallel loop present(a) !$acc parallel loop present(a)
do i = 1, size(a%val) do i = 1, size(a%val)
a%val(i) = a%val(i) * d a%val(i) = a%val(i) * d
end do end do
call a%set_dev() call a%set_dev()
call psb_erractionrestore(err_act) call psb_erractionrestore(err_act)
return return
9999 call psb_error_handler(err_act) 9999 call psb_error_handler(err_act)
return return
end subroutine psb_d_oacc_csr_scals end subroutine psb_d_oacc_csr_scals
end submodule psb_d_oacc_csr_scals_impl

@ -1,6 +1,7 @@
subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans) submodule (psb_d_oacc_csr_mat_mod) psb_d_oacc_csr_vect_mv_impl
use psb_base_mod use psb_base_mod
use psb_d_oacc_csr_mat_mod, psb_protect_name => psb_d_oacc_csr_vect_mv contains
module subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans)
implicit none implicit none
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
@ -16,9 +17,9 @@ subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans)
n = a%get_ncols() n = a%get_ncols()
if ((n /= size(x%v)) .or. (n /= size(y%v))) then if ((n /= size(x%v)) .or. (n /= size(y%v))) then
write(0,*) 'Size error ', m, n, size(x%v), size(y%v) write(0,*) 'Size error ', m, n, size(x%v), size(y%v)
info = psb_err_invalid_mat_state_ info = psb_err_invalid_mat_state_
return return
end if end if
if (a%is_host()) call a%sync() if (a%is_host()) call a%sync()
@ -28,34 +29,35 @@ subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans)
call inner_spmv(m, n, alpha, a%val, a%ja, a%irp, x%v, beta, y%v, info) call inner_spmv(m, n, alpha, a%val, a%ja, a%irp, x%v, beta, y%v, info)
call y%set_dev() call y%set_dev()
contains contains
subroutine inner_spmv(m, n, alpha, val, ja, irp, x, beta, y, info) subroutine inner_spmv(m, n, alpha, val, ja, irp, x, beta, y, info)
implicit none implicit none
integer(psb_ipk_) :: m, n integer(psb_ipk_) :: m, n
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
real(psb_dpk_) :: val(:), x(:), y(:) real(psb_dpk_) :: val(:), x(:), y(:)
integer(psb_ipk_) :: ja(:), irp(:) integer(psb_ipk_) :: ja(:), irp(:)
integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_) :: i, j, ii, isz integer(psb_ipk_) :: i, j, ii, isz
real(psb_dpk_) :: tmp real(psb_dpk_) :: tmp
integer(psb_ipk_), parameter :: vsz = 256 integer(psb_ipk_), parameter :: vsz = 256
info = 0 info = 0
!$acc parallel loop vector_length(vsz) private(isz) !$acc parallel loop vector_length(vsz) private(isz)
do ii = 1, m, vsz do ii = 1, m, vsz
isz = min(vsz, m - ii + 1) isz = min(vsz, m - ii + 1)
!$acc loop independent private(tmp) !$acc loop independent private(tmp)
do i = ii, ii + isz - 1 do i = ii, ii + isz - 1
tmp = 0.0_psb_dpk_ tmp = 0.0_psb_dpk_
!$acc loop seq !$acc loop seq
do j = irp(i), irp(i + 1) - 1 do j = irp(i), irp(i + 1) - 1
tmp = tmp + val(j) * x(ja(j)) tmp = tmp + val(j) * x(ja(j))
end do end do
y(i) = alpha * tmp + beta * y(i) y(i) = alpha * tmp + beta * y(i)
end do
end do end do
end do
end subroutine inner_spmv end subroutine inner_spmv
end subroutine psb_d_oacc_csr_vect_mv end subroutine psb_d_oacc_csr_vect_mv
end submodule psb_d_oacc_csr_vect_mv_impl

@ -1,31 +1,34 @@
submodule (psb_d_oacc_vect_mod) psb_d_oacc_mlt_v_impl
use psb_string_mod
contains
subroutine d_oacc_mlt_v(x, y, info) module subroutine psb_d_oacc_mlt_v(x, y, info)
use psb_d_oacc_vect_mod, psb_protect_name => d_oacc_mlt_v
implicit none implicit none
class(psb_d_base_vect_type), intent(inout) :: x class(psb_d_base_vect_type), intent(inout) :: x
class(psb_d_vect_oacc), intent(inout) :: y class(psb_d_vect_oacc), intent(inout) :: y
integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_) :: i, n integer(psb_ipk_) :: i, n
info = 0 info = 0
n = min(x%get_nrows(), y%get_nrows()) n = min(x%get_nrows(), y%get_nrows())
select type(xx => x) select type(xx => x)
class is (psb_d_vect_oacc) class is (psb_d_vect_oacc)
if (y%is_host()) call y%sync() if (y%is_host()) call y%sync()
if (xx%is_host()) call xx%sync() if (xx%is_host()) call xx%sync()
!$acc parallel loop !$acc parallel loop
do i = 1, n do i = 1, n
y%v(i) = y%v(i) * xx%v(i) y%v(i) = y%v(i) * xx%v(i)
end do end do
call y%set_dev() call y%set_dev()
class default class default
if (xx%is_dev()) call xx%sync() if (xx%is_dev()) call xx%sync()
if (y%is_dev()) call y%sync() if (y%is_dev()) call y%sync()
do i = 1, n do i = 1, n
y%v(i) = y%v(i) * xx%v(i) y%v(i) = y%v(i) * xx%v(i)
end do end do
call y%set_host() call y%set_host()
end select end select
end subroutine d_oacc_mlt_v end subroutine psb_d_oacc_mlt_v
end submodule psb_d_oacc_mlt_v_impl

@ -1,53 +1,55 @@
subroutine d_oacc_mlt_v_2(alpha, x, y, beta, z, info, conjgx, conjgy) submodule (psb_d_oacc_vect_mod) d_oacc_mlt_v_2_impl
use psb_d_oacc_vect_mod, psb_protect_name => d_oacc_mlt_v_2
use psb_string_mod use psb_string_mod
implicit none contains
real(psb_dpk_), intent(in) :: alpha, beta module subroutine d_oacc_mlt_v_2(alpha, x, y, beta, z, info, conjgx, conjgy)
class(psb_d_base_vect_type), intent(inout) :: x implicit none
class(psb_d_base_vect_type), intent(inout) :: y real(psb_dpk_), intent(in) :: alpha, beta
class(psb_d_vect_oacc), intent(inout) :: z class(psb_d_base_vect_type), intent(inout) :: x
integer(psb_ipk_), intent(out) :: info class(psb_d_base_vect_type), intent(inout) :: y
character(len=1), intent(in), optional :: conjgx, conjgy class(psb_d_vect_oacc), intent(inout) :: z
integer(psb_ipk_) :: i, n integer(psb_ipk_), intent(out) :: info
logical :: conjgx_, conjgy_ character(len=1), intent(in), optional :: conjgx, conjgy
integer(psb_ipk_) :: i, n
logical :: conjgx_, conjgy_
conjgx_ = .false. conjgx_ = .false.
conjgy_ = .false. conjgy_ = .false.
if (present(conjgx)) conjgx_ = (psb_toupper(conjgx) == 'C') if (present(conjgx)) conjgx_ = (psb_toupper(conjgx) == 'C')
if (present(conjgy)) conjgy_ = (psb_toupper(conjgy) == 'C') if (present(conjgy)) conjgy_ = (psb_toupper(conjgy) == 'C')
n = min(x%get_nrows(), y%get_nrows(), z%get_nrows()) n = min(x%get_nrows(), y%get_nrows(), z%get_nrows())
info = 0 info = 0
select type(xx => x) select type(xx => x)
class is (psb_d_vect_oacc)
select type (yy => y)
class is (psb_d_vect_oacc) class is (psb_d_vect_oacc)
if (xx%is_host()) call xx%sync() select type (yy => y)
if (yy%is_host()) call yy%sync() class is (psb_d_vect_oacc)
if ((beta /= dzero) .and. (z%is_host())) call z%sync() if (xx%is_host()) call xx%sync()
!$acc parallel loop if (yy%is_host()) call yy%sync()
do i = 1, n if ((beta /= dzero) .and. (z%is_host())) call z%sync()
z%v(i) = alpha * xx%v(i) * yy%v(i) + beta * z%v(i) !$acc parallel loop
end do do i = 1, n
call z%set_dev() z%v(i) = alpha * xx%v(i) * yy%v(i) + beta * z%v(i)
end do
call z%set_dev()
class default
if (xx%is_dev()) call xx%sync()
if (yy%is_dev()) call yy%sync()
if ((beta /= dzero) .and. (z%is_dev())) call z%sync()
do i = 1, n
z%v(i) = alpha * xx%v(i) * yy%v(i) + beta * z%v(i)
end do
call z%set_host()
end select
class default class default
if (xx%is_dev()) call xx%sync() if (x%is_dev()) call x%sync()
if (yy%is_dev()) call yy%sync() if (y%is_dev()) call y%sync()
if ((beta /= dzero) .and. (z%is_dev())) call z%sync() if ((beta /= dzero) .and. (z%is_dev())) call z%sync()
do i = 1, n do i = 1, n
z%v(i) = alpha * xx%v(i) * yy%v(i) + beta * z%v(i) z%v(i) = alpha * x%v(i) * y%v(i) + beta * z%v(i)
end do end do
call z%set_host() call z%set_host()
end select end select
class default end subroutine d_oacc_mlt_v_2
if (x%is_dev()) call x%sync() end submodule d_oacc_mlt_v_2_impl
if (y%is_dev()) call y%sync()
if ((beta /= dzero) .and. (z%is_dev())) call z%sync()
do i = 1, n
z%v(i) = alpha * x%v(i) * y%v(i) + beta * z%v(i)
end do
call z%set_host()
end select
end subroutine d_oacc_mlt_v_2

@ -1,358 +1,345 @@
module psb_d_oacc_csr_mat_mod module psb_d_oacc_csr_mat_mod
use iso_c_binding use iso_c_binding
use psb_d_mat_mod use psb_d_mat_mod
use psb_d_oacc_vect_mod use psb_d_oacc_vect_mod
!use oaccsparse_mod !use oaccsparse_mod
integer(psb_ipk_), parameter, private :: is_host = -1 integer(psb_ipk_), parameter, private :: is_host = -1
integer(psb_ipk_), parameter, private :: is_sync = 0 integer(psb_ipk_), parameter, private :: is_sync = 0
integer(psb_ipk_), parameter, private :: is_dev = 1 integer(psb_ipk_), parameter, private :: is_dev = 1
type, extends(psb_d_csr_sparse_mat) :: psb_d_oacc_csr_sparse_mat type, extends(psb_d_csr_sparse_mat) :: psb_d_oacc_csr_sparse_mat
integer(psb_ipk_) :: devstate = is_host integer(psb_ipk_) :: devstate = is_host
contains contains
procedure, nopass :: get_fmt => d_oacc_csr_get_fmt procedure, nopass :: get_fmt => d_oacc_csr_get_fmt
procedure, pass(a) :: sizeof => d_oacc_csr_sizeof procedure, pass(a) :: sizeof => d_oacc_csr_sizeof
procedure, pass(a) :: vect_mv => psb_d_oacc_csr_vect_mv procedure, pass(a) :: vect_mv => psb_d_oacc_csr_vect_mv
procedure, pass(a) :: in_vect_sv => psb_d_oacc_csr_inner_vect_sv procedure, pass(a) :: in_vect_sv => psb_d_oacc_csr_inner_vect_sv
procedure, pass(a) :: csmm => psb_d_oacc_csr_csmm procedure, pass(a) :: csmm => psb_d_oacc_csr_csmm
procedure, pass(a) :: csmv => psb_d_oacc_csr_csmv procedure, pass(a) :: csmv => psb_d_oacc_csr_csmv
procedure, pass(a) :: scals => psb_d_oacc_csr_scals procedure, pass(a) :: scals => psb_d_oacc_csr_scals
procedure, pass(a) :: scalv => psb_d_oacc_csr_scal procedure, pass(a) :: scalv => psb_d_oacc_csr_scal
procedure, pass(a) :: reallocate_nz => psb_d_oacc_csr_reallocate_nz procedure, pass(a) :: reallocate_nz => psb_d_oacc_csr_reallocate_nz
procedure, pass(a) :: allocate_mnnz => psb_d_oacc_csr_allocate_mnnz procedure, pass(a) :: allocate_mnnz => psb_d_oacc_csr_allocate_mnnz
procedure, pass(a) :: cp_from_coo => psb_d_oacc_csr_cp_from_coo procedure, pass(a) :: cp_from_coo => psb_d_oacc_csr_cp_from_coo
procedure, pass(a) :: cp_from_fmt => psb_d_oacc_csr_cp_from_fmt procedure, pass(a) :: cp_from_fmt => psb_d_oacc_csr_cp_from_fmt
procedure, pass(a) :: mv_from_coo => psb_d_oacc_csr_mv_from_coo procedure, pass(a) :: mv_from_coo => psb_d_oacc_csr_mv_from_coo
procedure, pass(a) :: mv_from_fmt => psb_d_oacc_csr_mv_from_fmt procedure, pass(a) :: mv_from_fmt => psb_d_oacc_csr_mv_from_fmt
procedure, pass(a) :: free => d_oacc_csr_free procedure, pass(a) :: free => d_oacc_csr_free
procedure, pass(a) :: mold => psb_d_oacc_csr_mold procedure, pass(a) :: mold => psb_d_oacc_csr_mold
procedure, pass(a) :: all => d_oacc_csr_all procedure, pass(a) :: all => d_oacc_csr_all
procedure, pass(a) :: is_host => d_oacc_csr_is_host procedure, pass(a) :: is_host => d_oacc_csr_is_host
procedure, pass(a) :: is_sync => d_oacc_csr_is_sync procedure, pass(a) :: is_sync => d_oacc_csr_is_sync
procedure, pass(a) :: is_dev => d_oacc_csr_is_dev procedure, pass(a) :: is_dev => d_oacc_csr_is_dev
procedure, pass(a) :: set_host => d_oacc_csr_set_host procedure, pass(a) :: set_host => d_oacc_csr_set_host
procedure, pass(a) :: set_sync => d_oacc_csr_set_sync procedure, pass(a) :: set_sync => d_oacc_csr_set_sync
procedure, pass(a) :: set_dev => d_oacc_csr_set_dev procedure, pass(a) :: set_dev => d_oacc_csr_set_dev
procedure, pass(a) :: sync_space => d_oacc_csr_sync_space procedure, pass(a) :: sync_space => d_oacc_csr_sync_space
procedure, pass(a) :: sync => d_oacc_csr_sync procedure, pass(a) :: sync => d_oacc_csr_sync
end type psb_d_oacc_csr_sparse_mat end type psb_d_oacc_csr_sparse_mat
interface interface
subroutine psb_d_oacc_csr_mold(a,b,info) module subroutine psb_d_oacc_csr_mold(a,b,info)
import :: psb_d_oacc_csr_sparse_mat, psb_d_base_sparse_mat, psb_ipk_ class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_base_sparse_mat), intent(inout), allocatable :: b
class(psb_d_base_sparse_mat), intent(inout), allocatable :: b integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(out) :: info end subroutine psb_d_oacc_csr_mold
end subroutine psb_d_oacc_csr_mold end interface
end interface
interface
interface module subroutine psb_d_oacc_csr_cp_from_fmt(a,b,info)
subroutine psb_d_oacc_csr_cp_from_fmt(a,b,info) class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
import :: psb_d_oacc_csr_sparse_mat, psb_d_base_sparse_mat, psb_ipk_ class(psb_d_base_sparse_mat), intent(in) :: b
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a integer(psb_ipk_), intent(out) :: info
class(psb_d_base_sparse_mat), intent(in) :: b end subroutine psb_d_oacc_csr_cp_from_fmt
integer(psb_ipk_), intent(out) :: info end interface
end subroutine psb_d_oacc_csr_cp_from_fmt
end interface interface
module subroutine psb_d_oacc_csr_mv_from_coo(a,b,info)
interface class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
subroutine psb_d_oacc_csr_mv_from_coo(a,b,info) class(psb_d_coo_sparse_mat), intent(inout) :: b
import :: psb_d_oacc_csr_sparse_mat, psb_d_coo_sparse_mat, psb_ipk_ integer(psb_ipk_), intent(out) :: info
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a end subroutine psb_d_oacc_csr_mv_from_coo
class(psb_d_coo_sparse_mat), intent(inout) :: b end interface
integer(psb_ipk_), intent(out) :: info
end subroutine psb_d_oacc_csr_mv_from_coo interface
end interface module subroutine psb_d_oacc_csr_mv_from_fmt(a,b,info)
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
interface class(psb_d_base_sparse_mat), intent(inout) :: b
subroutine psb_d_oacc_csr_mv_from_fmt(a,b,info) integer(psb_ipk_), intent(out) :: info
import :: psb_d_oacc_csr_sparse_mat, psb_d_base_sparse_mat, psb_ipk_ end subroutine psb_d_oacc_csr_mv_from_fmt
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a end interface
class(psb_d_base_sparse_mat), intent(inout) :: b
integer(psb_ipk_), intent(out) :: info interface
end subroutine psb_d_oacc_csr_mv_from_fmt module subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans)
end interface class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
real(psb_dpk_), intent(in) :: alpha, beta
interface class(psb_d_base_vect_type), intent(inout) :: x, y
subroutine psb_d_oacc_csr_vect_mv(alpha, a, x, beta, y, info, trans) integer(psb_ipk_), intent(out) :: info
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_d_base_vect_type, psb_ipk_ character, optional, intent(in) :: trans
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a end subroutine psb_d_oacc_csr_vect_mv
real(psb_dpk_), intent(in) :: alpha, beta end interface
class(psb_d_base_vect_type), intent(inout) :: x, y
integer(psb_ipk_), intent(out) :: info interface
character, optional, intent(in) :: trans module subroutine psb_d_oacc_csr_inner_vect_sv(alpha, a, x, beta, y, info, trans)
end subroutine psb_d_oacc_csr_vect_mv class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
end interface real(psb_dpk_), intent(in) :: alpha, beta
class(psb_d_base_vect_type), intent(inout) :: x,y
interface integer(psb_ipk_), intent(out) :: info
subroutine psb_d_oacc_csr_inner_vect_sv(alpha, a, x, beta, y, info, trans) character, optional, intent(in) :: trans
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_d_base_vect_type, psb_ipk_ end subroutine psb_d_oacc_csr_inner_vect_sv
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a end interface
real(psb_dpk_), intent(in) :: alpha, beta
class(psb_d_base_vect_type), intent(inout) :: x,y interface
integer(psb_ipk_), intent(out) :: info module subroutine psb_d_oacc_csr_csmm(alpha, a, x, beta, y, info, trans)
character, optional, intent(in) :: trans class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
end subroutine psb_d_oacc_csr_inner_vect_sv real(psb_dpk_), intent(in) :: alpha, beta, x(:,:)
end interface real(psb_dpk_), intent(inout) :: y(:,:)
integer(psb_ipk_), intent(out) :: info
interface character, optional, intent(in) :: trans
subroutine psb_d_oacc_csr_csmm(alpha, a, x, beta, y, info, trans) end subroutine psb_d_oacc_csr_csmm
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_d_base_vect_type, psb_ipk_ end interface
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
real(psb_dpk_), intent(in) :: alpha, beta, x(:,:) interface
real(psb_dpk_), intent(inout) :: y(:,:) module subroutine psb_d_oacc_csr_csmv(alpha, a, x, beta, y, info, trans)
integer(psb_ipk_), intent(out) :: info class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
character, optional, intent(in) :: trans real(psb_dpk_), intent(in) :: alpha, beta, x(:)
end subroutine psb_d_oacc_csr_csmm real(psb_dpk_), intent(inout) :: y(:)
end interface integer(psb_ipk_), intent(out) :: info
character, optional, intent(in) :: trans
interface end subroutine psb_d_oacc_csr_csmv
subroutine psb_d_oacc_csr_csmv(alpha, a, x, beta, y, info, trans) end interface
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_d_base_vect_type, psb_ipk_
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a interface
real(psb_dpk_), intent(in) :: alpha, beta, x(:) module subroutine psb_d_oacc_csr_scals(d, a, info)
real(psb_dpk_), intent(inout) :: y(:) class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
integer(psb_ipk_), intent(out) :: info real(psb_dpk_), intent(in) :: d
character, optional, intent(in) :: trans integer(psb_ipk_), intent(out) :: info
end subroutine psb_d_oacc_csr_csmv end subroutine psb_d_oacc_csr_scals
end interface end interface
interface interface
subroutine psb_d_oacc_csr_scals(d, a, info) module subroutine psb_d_oacc_csr_scal(d,a,info,side)
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_ipk_ class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a real(psb_dpk_), intent(in) :: d(:)
real(psb_dpk_), intent(in) :: d integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(out) :: info character, optional, intent(in) :: side
end subroutine psb_d_oacc_csr_scals end subroutine psb_d_oacc_csr_scal
end interface end interface
interface interface
subroutine psb_d_oacc_csr_scal(d,a,info,side) module subroutine psb_d_oacc_csr_reallocate_nz(nz,a)
import :: psb_d_oacc_csr_sparse_mat, psb_dpk_, psb_ipk_ class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a integer(psb_ipk_), intent(in) :: nz
real(psb_dpk_), intent(in) :: d(:) end subroutine psb_d_oacc_csr_reallocate_nz
integer(psb_ipk_), intent(out) :: info end interface
character, optional, intent(in) :: side
end subroutine psb_d_oacc_csr_scal interface
end interface module subroutine psb_d_oacc_csr_allocate_mnnz(m,n,a,nz)
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
interface integer(psb_ipk_), intent(in) :: m,n
subroutine psb_d_oacc_csr_reallocate_nz(nz,a) integer(psb_ipk_), intent(in), optional :: nz
import :: psb_d_oacc_csr_sparse_mat, psb_ipk_ end subroutine psb_d_oacc_csr_allocate_mnnz
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a end interface
integer(psb_ipk_), intent(in) :: nz
end subroutine psb_d_oacc_csr_reallocate_nz interface
end interface module subroutine psb_d_oacc_csr_cp_from_coo(a,b,info)
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
interface class(psb_d_coo_sparse_mat), intent(in) :: b
subroutine psb_d_oacc_csr_allocate_mnnz(m,n,a,nz) integer(psb_ipk_), intent(out) :: info
import :: psb_d_oacc_csr_sparse_mat, psb_ipk_ end subroutine psb_d_oacc_csr_cp_from_coo
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a end interface
integer(psb_ipk_), intent(in) :: m,n
integer(psb_ipk_), intent(in), optional :: nz
end subroutine psb_d_oacc_csr_allocate_mnnz
end interface
interface
subroutine psb_d_oacc_csr_cp_from_coo(a,b,info)
import :: psb_d_oacc_csr_sparse_mat, psb_d_coo_sparse_mat, psb_ipk_
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
class(psb_d_coo_sparse_mat), intent(in) :: b
integer(psb_ipk_), intent(out) :: info
end subroutine psb_d_oacc_csr_cp_from_coo
end interface
contains contains
subroutine d_oacc_csr_free(a) subroutine d_oacc_csr_free(a)
use psb_base_mod use psb_base_mod
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
integer(psb_ipk_) :: info integer(psb_ipk_) :: info
if (allocated(a%val)) then if (allocated(a%val)) then
!$acc exit data delete(a%val) !$acc exit data delete(a%val)
end if end if
if (allocated(a%ja)) then if (allocated(a%ja)) then
!$acc exit data delete(a%ja) !$acc exit data delete(a%ja)
end if end if
if (allocated(a%irp)) then if (allocated(a%irp)) then
!$acc exit data delete(a%irp) !$acc exit data delete(a%irp)
end if end if
call a%psb_d_csr_sparse_mat%free() call a%psb_d_csr_sparse_mat%free()
return return
end subroutine d_oacc_csr_free end subroutine d_oacc_csr_free
function d_oacc_csr_sizeof(a) result(res) function d_oacc_csr_sizeof(a) result(res)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
integer(psb_epk_) :: res integer(psb_epk_) :: res
if (a%is_dev()) call a%sync() if (a%is_dev()) call a%sync()
res = 8 res = 8
res = res + psb_sizeof_dp * size(a%val) res = res + psb_sizeof_dp * size(a%val)
res = res + psb_sizeof_ip * size(a%irp) res = res + psb_sizeof_ip * size(a%irp)
res = res + psb_sizeof_ip * size(a%ja) res = res + psb_sizeof_ip * size(a%ja)
end function d_oacc_csr_sizeof end function d_oacc_csr_sizeof
function d_oacc_csr_get_fmt() result(res) function d_oacc_csr_get_fmt() result(res)
implicit none implicit none
character(len=5) :: res character(len=5) :: res
res = 'CSR_oacc' res = 'CSR_oacc'
end function d_oacc_csr_get_fmt end function d_oacc_csr_get_fmt
subroutine d_oacc_csr_all(m, n, nz, a, info) subroutine d_oacc_csr_all(m, n, nz, a, info)
implicit none implicit none
integer(psb_ipk_), intent(in) :: m, n, nz integer(psb_ipk_), intent(in) :: m, n, nz
class(psb_d_oacc_csr_sparse_mat), intent(out) :: a class(psb_d_oacc_csr_sparse_mat), intent(out) :: a
integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(out) :: info
info = 0 info = 0
if (allocated(a%val)) then if (allocated(a%val)) then
!$acc exit data delete(a%val) finalize !$acc exit data delete(a%val) finalize
deallocate(a%val, stat=info) deallocate(a%val, stat=info)
end if end if
if (allocated(a%ja)) then if (allocated(a%ja)) then
!$acc exit data delete(a%ja) finalize !$acc exit data delete(a%ja) finalize
deallocate(a%ja, stat=info) deallocate(a%ja, stat=info)
end if end if
if (allocated(a%irp)) then if (allocated(a%irp)) then
!$acc exit data delete(a%irp) finalize !$acc exit data delete(a%irp) finalize
deallocate(a%irp, stat=info) deallocate(a%irp, stat=info)
end if end if
call a%set_nrows(m) call a%set_nrows(m)
call a%set_ncols(n) call a%set_ncols(n)
allocate(a%val(nz),stat=info) allocate(a%val(nz),stat=info)
allocate(a%ja(nz),stat=info) allocate(a%ja(nz),stat=info)
allocate(a%irp(m+1),stat=info) allocate(a%irp(m+1),stat=info)
if (info == 0) call a%set_host() if (info == 0) call a%set_host()
if (info == 0) call a%sync_space() if (info == 0) call a%sync_space()
end subroutine d_oacc_csr_all end subroutine d_oacc_csr_all
function d_oacc_csr_is_host(a) result(res) function d_oacc_csr_is_host(a) result(res)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
logical :: res logical :: res
res = (a%devstate == is_host) res = (a%devstate == is_host)
end function d_oacc_csr_is_host end function d_oacc_csr_is_host
function d_oacc_csr_is_sync(a) result(res) function d_oacc_csr_is_sync(a) result(res)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
logical :: res logical :: res
res = (a%devstate == is_sync) res = (a%devstate == is_sync)
end function d_oacc_csr_is_sync end function d_oacc_csr_is_sync
function d_oacc_csr_is_dev(a) result(res) function d_oacc_csr_is_dev(a) result(res)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(in) :: a class(psb_d_oacc_csr_sparse_mat), intent(in) :: a
logical :: res logical :: res
res = (a%devstate == is_dev) res = (a%devstate == is_dev)
end function d_oacc_csr_is_dev end function d_oacc_csr_is_dev
subroutine d_oacc_csr_set_host(a) subroutine d_oacc_csr_set_host(a)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
a%devstate = is_host a%devstate = is_host
end subroutine d_oacc_csr_set_host end subroutine d_oacc_csr_set_host
subroutine d_oacc_csr_set_sync(a) subroutine d_oacc_csr_set_sync(a)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
a%devstate = is_sync a%devstate = is_sync
end subroutine d_oacc_csr_set_sync end subroutine d_oacc_csr_set_sync
subroutine d_oacc_csr_set_dev(a) subroutine d_oacc_csr_set_dev(a)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
a%devstate = is_dev a%devstate = is_dev
end subroutine d_oacc_csr_set_dev end subroutine d_oacc_csr_set_dev
subroutine d_oacc_csr_sync_space(a) subroutine d_oacc_csr_sync_space(a)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a class(psb_d_oacc_csr_sparse_mat), intent(inout) :: a
if (allocated(a%val)) then if (allocated(a%val)) then
call d_oacc_create_dev(a%val) call d_oacc_create_dev(a%val)
end if end if
if (allocated(a%ja)) then if (allocated(a%ja)) then
call i_oacc_create_dev(a%ja) call i_oacc_create_dev(a%ja)
end if end if
if (allocated(a%irp)) then if (allocated(a%irp)) then
call i_oacc_create_dev(a%irp) call i_oacc_create_dev(a%irp)
end if end if
contains contains
subroutine d_oacc_create_dev(v) subroutine d_oacc_create_dev(v)
implicit none implicit none
real(psb_dpk_), intent(in) :: v(:) real(psb_dpk_), intent(in) :: v(:)
!$acc enter data copyin(v) !$acc enter data copyin(v)
end subroutine d_oacc_create_dev end subroutine d_oacc_create_dev
subroutine i_oacc_create_dev(v) subroutine i_oacc_create_dev(v)
implicit none implicit none
integer(psb_ipk_), intent(in) :: v(:) integer(psb_ipk_), intent(in) :: v(:)
!$acc enter data copyin(v) !$acc enter data copyin(v)
end subroutine i_oacc_create_dev end subroutine i_oacc_create_dev
end subroutine d_oacc_csr_sync_space end subroutine d_oacc_csr_sync_space
subroutine d_oacc_csr_sync(a) subroutine d_oacc_csr_sync(a)
implicit none implicit none
class(psb_d_oacc_csr_sparse_mat), target, intent(in) :: a class(psb_d_oacc_csr_sparse_mat), target, intent(in) :: a
class(psb_d_oacc_csr_sparse_mat), pointer :: tmpa class(psb_d_oacc_csr_sparse_mat), pointer :: tmpa
integer(psb_ipk_) :: info integer(psb_ipk_) :: info
tmpa => a tmpa => a
if (a%is_dev()) then if (a%is_dev()) then
call d_oacc_csr_to_host(a%val) call d_oacc_csr_to_host(a%val)
call i_oacc_csr_to_host(a%ja) call i_oacc_csr_to_host(a%ja)
call i_oacc_csr_to_host(a%irp) call i_oacc_csr_to_host(a%irp)
else if (a%is_host()) then else if (a%is_host()) then
call d_oacc_csr_to_dev(a%val) call d_oacc_csr_to_dev(a%val)
call i_oacc_csr_to_dev(a%ja) call i_oacc_csr_to_dev(a%ja)
call i_oacc_csr_to_dev(a%irp) call i_oacc_csr_to_dev(a%irp)
end if end if
call tmpa%set_sync() call tmpa%set_sync()
end subroutine d_oacc_csr_sync end subroutine d_oacc_csr_sync
subroutine d_oacc_csr_to_dev(v) subroutine d_oacc_csr_to_dev(v)
implicit none implicit none
real(psb_dpk_), intent(in) :: v(:) real(psb_dpk_), intent(in) :: v(:)
!$acc update device(v) !$acc update device(v)
end subroutine d_oacc_csr_to_dev end subroutine d_oacc_csr_to_dev
subroutine d_oacc_csr_to_host(v) subroutine d_oacc_csr_to_host(v)
implicit none implicit none
real(psb_dpk_), intent(in) :: v(:) real(psb_dpk_), intent(in) :: v(:)
!$acc update self(v) !$acc update self(v)
end subroutine d_oacc_csr_to_host end subroutine d_oacc_csr_to_host
subroutine i_oacc_csr_to_dev(v) subroutine i_oacc_csr_to_dev(v)
implicit none implicit none
integer(psb_ipk_), intent(in) :: v(:) integer(psb_ipk_), intent(in) :: v(:)
!$acc update device(v) !$acc update device(v)
end subroutine i_oacc_csr_to_dev end subroutine i_oacc_csr_to_dev
subroutine i_oacc_csr_to_host(v) subroutine i_oacc_csr_to_host(v)
implicit none implicit none
integer(psb_ipk_), intent(in) :: v(:) integer(psb_ipk_), intent(in) :: v(:)
!$acc update self(v) !$acc update self(v)
end subroutine i_oacc_csr_to_host end subroutine i_oacc_csr_to_host
end module psb_d_oacc_csr_mat_mod end module psb_d_oacc_csr_mat_mod

@ -49,8 +49,8 @@ module psb_d_oacc_vect_mod
procedure, pass(z) :: abgdxyz => d_oacc_abgdxyz procedure, pass(z) :: abgdxyz => d_oacc_abgdxyz
procedure, pass(y) :: mlt_a => d_oacc_mlt_a procedure, pass(y) :: mlt_a => d_oacc_mlt_a
procedure, pass(z) :: mlt_a_2 => d_oacc_mlt_a_2 procedure, pass(z) :: mlt_a_2 => d_oacc_mlt_a_2
procedure, pass(y) :: mlt_v => d_oacc_mlt_v procedure, pass(y) :: mlt_v => psb_d_oacc_mlt_v
procedure, pass(z) :: mlt_v_2 => d_oacc_mlt_v_2 procedure, pass(z) :: mlt_v_2 => psb_d_oacc_mlt_v_2
procedure, pass(x) :: scal => d_oacc_scal procedure, pass(x) :: scal => d_oacc_scal
procedure, pass(x) :: nrm2 => d_oacc_nrm2 procedure, pass(x) :: nrm2 => d_oacc_nrm2
procedure, pass(x) :: amax => d_oacc_amax procedure, pass(x) :: amax => d_oacc_amax
@ -63,19 +63,17 @@ module psb_d_oacc_vect_mod
real(psb_dpk_), allocatable :: v1(:),v2(:),p(:) real(psb_dpk_), allocatable :: v1(:),v2(:),p(:)
interface interface
subroutine d_oacc_mlt_v(x, y, info) module subroutine psb_d_oacc_mlt_v(x, y, info)
import
implicit none implicit none
class(psb_d_base_vect_type), intent(inout) :: x class(psb_d_base_vect_type), intent(inout) :: x
class(psb_d_vect_oacc), intent(inout) :: y class(psb_d_vect_oacc), intent(inout) :: y
integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(out) :: info
end subroutine d_oacc_mlt_v end subroutine psb_d_oacc_mlt_v
end interface end interface
interface interface
subroutine d_oacc_mlt_v_2(alpha, x, y, beta, z, info, conjgx, conjgy) module subroutine psb_d_oacc_mlt_v_2(alpha, x, y, beta, z, info, conjgx, conjgy)
import
implicit none implicit none
real(psb_dpk_), intent(in) :: alpha, beta real(psb_dpk_), intent(in) :: alpha, beta
class(psb_d_base_vect_type), intent(inout) :: x class(psb_d_base_vect_type), intent(inout) :: x
@ -83,7 +81,7 @@ module psb_d_oacc_vect_mod
class(psb_d_vect_oacc), intent(inout) :: z class(psb_d_vect_oacc), intent(inout) :: z
integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(out) :: info
character(len=1), intent(in), optional :: conjgx, conjgy character(len=1), intent(in), optional :: conjgx, conjgy
end subroutine d_oacc_mlt_v_2 end subroutine psb_d_oacc_mlt_v_2
end interface end interface
contains contains

Loading…
Cancel
Save