From ff0cfac9cf5d67d2fec1dc8ecb6f83922c149214 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Fri, 28 Jul 2017 16:09:38 +0100 Subject: [PATCH] Merged CSRE experiment. --- base/modules/serial/psb_d_csr_mat_mod.f90 | 40 ++- base/modules/serial/psb_d_mat_mod.f90 | 2 +- base/serial/impl/psb_d_csr_impl.f90 | 362 ++++++++++++++++++++++ test/kernel/pdgenspmv.f90 | 15 +- 4 files changed, 407 insertions(+), 12 deletions(-) diff --git a/base/modules/serial/psb_d_csr_mat_mod.f90 b/base/modules/serial/psb_d_csr_mat_mod.f90 index d1655449..f1c2b335 100644 --- a/base/modules/serial/psb_d_csr_mat_mod.f90 +++ b/base/modules/serial/psb_d_csr_mat_mod.f90 @@ -101,6 +101,15 @@ module psb_d_csr_mat_mod end type psb_d_csr_sparse_mat + type, extends(psb_d_csr_sparse_mat) :: psb_d_csre_sparse_mat + + contains + procedure, pass(a) :: csmv => psb_d_csre_csmv + procedure, nopass :: get_fmt => d_csre_get_fmt + + end type psb_d_csre_sparse_mat + + private :: d_csr_get_nzeros, d_csr_free, d_csr_get_fmt, & & d_csr_get_size, d_csr_sizeof, d_csr_get_nz_row, & & d_csr_is_by_rows @@ -494,6 +503,19 @@ module psb_d_csr_mat_mod end subroutine psb_d_csr_scals end interface + !> \memberof psb_d_csre_sparse_mat + !! \see psb_d_base_mat_mod::psb_d_base_csmv + interface + subroutine psb_d_csre_csmv(alpha,a,x,beta,y,info,trans) + import :: psb_ipk_, psb_d_csre_sparse_mat, psb_dpk_ + class(psb_d_csre_sparse_mat), intent(in) :: a + real(psb_dpk_), intent(in) :: alpha, beta, x(:) + real(psb_dpk_), intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character, optional, intent(in) :: trans + end subroutine psb_d_csre_csmv + end interface + contains @@ -511,16 +533,16 @@ contains ! == =================================== - + function d_csr_is_by_rows(a) result(res) implicit none class(psb_d_csr_sparse_mat), intent(in) :: a logical :: res res = .true. - + end function d_csr_is_by_rows - + function d_csr_sizeof(a) result(res) implicit none class(psb_d_csr_sparse_mat), intent(in) :: a @@ -529,7 +551,7 @@ contains res = res + psb_sizeof_dp * psb_size(a%val) res = res + psb_sizeof_int * psb_size(a%irp) res = res + psb_sizeof_int * psb_size(a%ja) - + end function d_csr_sizeof function d_csr_get_fmt() result(res) @@ -537,7 +559,13 @@ contains character(len=5) :: res res = 'CSR' end function d_csr_get_fmt - + + function d_csre_get_fmt() result(res) + implicit none + character(len=5) :: res + res = 'CSRe' + end function d_csre_get_fmt + function d_csr_get_nzeros(a) result(res) implicit none class(psb_d_csr_sparse_mat), intent(in) :: a @@ -551,7 +579,7 @@ contains integer(psb_ipk_) :: res res = -1 - + if (allocated(a%ja)) then res = size(a%ja) end if diff --git a/base/modules/serial/psb_d_mat_mod.f90 b/base/modules/serial/psb_d_mat_mod.f90 index f70ae449..b8e3b5f4 100644 --- a/base/modules/serial/psb_d_mat_mod.f90 +++ b/base/modules/serial/psb_d_mat_mod.f90 @@ -72,7 +72,7 @@ module psb_d_mat_mod use psb_d_base_mat_mod - use psb_d_csr_mat_mod, only : psb_d_csr_sparse_mat + use psb_d_csr_mat_mod, only : psb_d_csr_sparse_mat, psb_d_csre_sparse_mat use psb_d_csc_mat_mod, only : psb_d_csc_sparse_mat type :: psb_dspmat_type diff --git a/base/serial/impl/psb_d_csr_impl.f90 b/base/serial/impl/psb_d_csr_impl.f90 index cce845c8..44f9bc76 100644 --- a/base/serial/impl/psb_d_csr_impl.f90 +++ b/base/serial/impl/psb_d_csr_impl.f90 @@ -3180,3 +3180,365 @@ contains end subroutine csr_spspmm end subroutine psb_dcsrspspmm + + + + +! == =================================== +! +! +! +! Computational routines +! +! +! +! +! +! +! == =================================== + +subroutine psb_d_csre_csmv(alpha,a,x,beta,y,info,trans) + use psb_error_mod + use psb_string_mod + use psb_d_csr_mat_mod, psb_protect_name => psb_d_csre_csmv + implicit none + class(psb_d_csre_sparse_mat), intent(in) :: a + real(psb_dpk_), intent(in) :: alpha, beta, x(:) + real(psb_dpk_), intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character, optional, intent(in) :: trans + + character :: trans_ + integer(psb_ipk_) :: i,j,k,m,n, nnz, ir, jc + real(psb_dpk_) :: acc + logical :: tra, ctra + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ierr(5) + character(len=20) :: name='d_csr_csmv' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + info = psb_success_ + if (a%is_dev()) call a%sync() + + if (present(trans)) then + trans_ = trans + else + trans_ = 'N' + end if + + if (.not.a%is_asb()) then + info = psb_err_invalid_mat_state_ + call psb_errpush(info,name) + goto 9999 + endif + + + tra = (psb_toupper(trans_) == 'T') + ctra = (psb_toupper(trans_) == 'C') + + if (tra.or.ctra) then + m = a%get_ncols() + n = a%get_nrows() + else + n = a%get_ncols() + m = a%get_nrows() + end if + + if (size(x,1)