From a747cc6abb0bb95891b20dffeeef87c1e1ddfe34 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Fri, 15 Mar 2024 15:47:56 +0100 Subject: [PATCH] Defined memory_use method --- amgprec/amg_c_onelev_mod.f90 | 17 ++ amgprec/amg_c_prec_type.f90 | 16 ++ amgprec/amg_d_onelev_mod.f90 | 17 ++ amgprec/amg_d_prec_type.f90 | 16 ++ amgprec/amg_s_onelev_mod.f90 | 17 ++ amgprec/amg_s_prec_type.f90 | 16 ++ amgprec/amg_z_onelev_mod.f90 | 17 ++ amgprec/amg_z_prec_type.f90 | 16 ++ amgprec/impl/Makefile | 8 +- amgprec/impl/amg_cfile_prec_memory_use.f90 | 149 ++++++++++++++++++ amgprec/impl/amg_dfile_prec_memory_use.f90 | 149 ++++++++++++++++++ amgprec/impl/amg_sfile_prec_memory_use.f90 | 149 ++++++++++++++++++ amgprec/impl/amg_zfile_prec_memory_use.f90 | 149 ++++++++++++++++++ amgprec/impl/level/Makefile | 4 + .../level/amg_c_base_onelev_memory_use.f90 | 113 +++++++++++++ .../level/amg_d_base_onelev_memory_use.f90 | 113 +++++++++++++ .../level/amg_s_base_onelev_memory_use.f90 | 113 +++++++++++++ .../level/amg_z_base_onelev_memory_use.f90 | 113 +++++++++++++ 18 files changed, 1188 insertions(+), 4 deletions(-) create mode 100644 amgprec/impl/amg_cfile_prec_memory_use.f90 create mode 100644 amgprec/impl/amg_dfile_prec_memory_use.f90 create mode 100644 amgprec/impl/amg_sfile_prec_memory_use.f90 create mode 100644 amgprec/impl/amg_zfile_prec_memory_use.f90 create mode 100644 amgprec/impl/level/amg_c_base_onelev_memory_use.f90 create mode 100644 amgprec/impl/level/amg_d_base_onelev_memory_use.f90 create mode 100644 amgprec/impl/level/amg_s_base_onelev_memory_use.f90 create mode 100644 amgprec/impl/level/amg_z_base_onelev_memory_use.f90 diff --git a/amgprec/amg_c_onelev_mod.f90 b/amgprec/amg_c_onelev_mod.f90 index 2cef1397..3a980ff3 100644 --- a/amgprec/amg_c_onelev_mod.f90 +++ b/amgprec/amg_c_onelev_mod.f90 @@ -187,6 +187,7 @@ module amg_c_onelev_mod procedure, pass(lv) :: clone => c_base_onelev_clone procedure, pass(lv) :: cnv => amg_c_base_onelev_cnv procedure, pass(lv) :: descr => amg_c_base_onelev_descr + procedure, pass(lv) :: memory_use => amg_c_base_onelev_memory_use procedure, pass(lv) :: default => c_base_onelev_default procedure, pass(lv) :: free => amg_c_base_onelev_free procedure, pass(lv) :: free_smoothers => amg_c_base_onelev_free_smoothers @@ -273,6 +274,22 @@ module amg_c_onelev_mod end subroutine amg_c_base_onelev_descr end interface + interface + subroutine amg_c_base_onelev_memory_use(lv,il,nl,ilmin,info,iout, verbosity,prefix) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_c_base_onelev_memory_use + end interface + interface subroutine amg_c_base_onelev_cnv(lv,info,amold,vmold,imold) import :: amg_c_onelev_type, psb_c_base_vect_type, psb_spk_, & diff --git a/amgprec/amg_c_prec_type.f90 b/amgprec/amg_c_prec_type.f90 index 9fd5afc5..1afdad53 100644 --- a/amgprec/amg_c_prec_type.f90 +++ b/amgprec/amg_c_prec_type.f90 @@ -139,6 +139,7 @@ module amg_c_prec_type procedure, pass(prec) :: smoothers_build => amg_c_smoothers_bld procedure, pass(prec) :: smoothers_free => amg_c_smoothers_free procedure, pass(prec) :: descr => amg_cfile_prec_descr + procedure, pass(prec) :: memory_use => amg_cfile_prec_memory_use end type amg_cprec_type private :: amg_c_dump, amg_c_get_compl, amg_c_cmp_compl,& @@ -170,6 +171,21 @@ module amg_c_prec_type end subroutine amg_cfile_prec_descr end interface + + interface amg_memory_use + subroutine amg_cfile_prec_memory_use(prec,info,iout,root,verbosity,prefix) + import :: amg_cprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_cfile_prec_memory_use + end interface + interface amg_sizeof module procedure amg_cprec_sizeof end interface diff --git a/amgprec/amg_d_onelev_mod.f90 b/amgprec/amg_d_onelev_mod.f90 index 60ed9448..3f21a2a6 100644 --- a/amgprec/amg_d_onelev_mod.f90 +++ b/amgprec/amg_d_onelev_mod.f90 @@ -188,6 +188,7 @@ module amg_d_onelev_mod procedure, pass(lv) :: clone => d_base_onelev_clone procedure, pass(lv) :: cnv => amg_d_base_onelev_cnv procedure, pass(lv) :: descr => amg_d_base_onelev_descr + procedure, pass(lv) :: memory_use => amg_d_base_onelev_memory_use procedure, pass(lv) :: default => d_base_onelev_default procedure, pass(lv) :: free => amg_d_base_onelev_free procedure, pass(lv) :: free_smoothers => amg_d_base_onelev_free_smoothers @@ -274,6 +275,22 @@ module amg_d_onelev_mod end subroutine amg_d_base_onelev_descr end interface + interface + subroutine amg_d_base_onelev_memory_use(lv,il,nl,ilmin,info,iout, verbosity,prefix) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_d_base_onelev_memory_use + end interface + interface subroutine amg_d_base_onelev_cnv(lv,info,amold,vmold,imold) import :: amg_d_onelev_type, psb_d_base_vect_type, psb_dpk_, & diff --git a/amgprec/amg_d_prec_type.f90 b/amgprec/amg_d_prec_type.f90 index 9fbc2b5d..90f5a2a8 100644 --- a/amgprec/amg_d_prec_type.f90 +++ b/amgprec/amg_d_prec_type.f90 @@ -139,6 +139,7 @@ module amg_d_prec_type procedure, pass(prec) :: smoothers_build => amg_d_smoothers_bld procedure, pass(prec) :: smoothers_free => amg_d_smoothers_free procedure, pass(prec) :: descr => amg_dfile_prec_descr + procedure, pass(prec) :: memory_use => amg_dfile_prec_memory_use end type amg_dprec_type private :: amg_d_dump, amg_d_get_compl, amg_d_cmp_compl,& @@ -170,6 +171,21 @@ module amg_d_prec_type end subroutine amg_dfile_prec_descr end interface + + interface amg_memory_use + subroutine amg_dfile_prec_memory_use(prec,info,iout,root,verbosity,prefix) + import :: amg_dprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_dfile_prec_memory_use + end interface + interface amg_sizeof module procedure amg_dprec_sizeof end interface diff --git a/amgprec/amg_s_onelev_mod.f90 b/amgprec/amg_s_onelev_mod.f90 index c826001d..9019c643 100644 --- a/amgprec/amg_s_onelev_mod.f90 +++ b/amgprec/amg_s_onelev_mod.f90 @@ -188,6 +188,7 @@ module amg_s_onelev_mod procedure, pass(lv) :: clone => s_base_onelev_clone procedure, pass(lv) :: cnv => amg_s_base_onelev_cnv procedure, pass(lv) :: descr => amg_s_base_onelev_descr + procedure, pass(lv) :: memory_use => amg_s_base_onelev_memory_use procedure, pass(lv) :: default => s_base_onelev_default procedure, pass(lv) :: free => amg_s_base_onelev_free procedure, pass(lv) :: free_smoothers => amg_s_base_onelev_free_smoothers @@ -274,6 +275,22 @@ module amg_s_onelev_mod end subroutine amg_s_base_onelev_descr end interface + interface + subroutine amg_s_base_onelev_memory_use(lv,il,nl,ilmin,info,iout, verbosity,prefix) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_s_base_onelev_memory_use + end interface + interface subroutine amg_s_base_onelev_cnv(lv,info,amold,vmold,imold) import :: amg_s_onelev_type, psb_s_base_vect_type, psb_spk_, & diff --git a/amgprec/amg_s_prec_type.f90 b/amgprec/amg_s_prec_type.f90 index 88a22078..246e763c 100644 --- a/amgprec/amg_s_prec_type.f90 +++ b/amgprec/amg_s_prec_type.f90 @@ -139,6 +139,7 @@ module amg_s_prec_type procedure, pass(prec) :: smoothers_build => amg_s_smoothers_bld procedure, pass(prec) :: smoothers_free => amg_s_smoothers_free procedure, pass(prec) :: descr => amg_sfile_prec_descr + procedure, pass(prec) :: memory_use => amg_sfile_prec_memory_use end type amg_sprec_type private :: amg_s_dump, amg_s_get_compl, amg_s_cmp_compl,& @@ -170,6 +171,21 @@ module amg_s_prec_type end subroutine amg_sfile_prec_descr end interface + + interface amg_memory_use + subroutine amg_sfile_prec_memory_use(prec,info,iout,root,verbosity,prefix) + import :: amg_sprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_sfile_prec_memory_use + end interface + interface amg_sizeof module procedure amg_sprec_sizeof end interface diff --git a/amgprec/amg_z_onelev_mod.f90 b/amgprec/amg_z_onelev_mod.f90 index 78259f4d..538ea9fa 100644 --- a/amgprec/amg_z_onelev_mod.f90 +++ b/amgprec/amg_z_onelev_mod.f90 @@ -187,6 +187,7 @@ module amg_z_onelev_mod procedure, pass(lv) :: clone => z_base_onelev_clone procedure, pass(lv) :: cnv => amg_z_base_onelev_cnv procedure, pass(lv) :: descr => amg_z_base_onelev_descr + procedure, pass(lv) :: memory_use => amg_z_base_onelev_memory_use procedure, pass(lv) :: default => z_base_onelev_default procedure, pass(lv) :: free => amg_z_base_onelev_free procedure, pass(lv) :: free_smoothers => amg_z_base_onelev_free_smoothers @@ -273,6 +274,22 @@ module amg_z_onelev_mod end subroutine amg_z_base_onelev_descr end interface + interface + subroutine amg_z_base_onelev_memory_use(lv,il,nl,ilmin,info,iout, verbosity,prefix) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_z_base_onelev_memory_use + end interface + interface subroutine amg_z_base_onelev_cnv(lv,info,amold,vmold,imold) import :: amg_z_onelev_type, psb_z_base_vect_type, psb_dpk_, & diff --git a/amgprec/amg_z_prec_type.f90 b/amgprec/amg_z_prec_type.f90 index 7b9ad346..1d1addc6 100644 --- a/amgprec/amg_z_prec_type.f90 +++ b/amgprec/amg_z_prec_type.f90 @@ -139,6 +139,7 @@ module amg_z_prec_type procedure, pass(prec) :: smoothers_build => amg_z_smoothers_bld procedure, pass(prec) :: smoothers_free => amg_z_smoothers_free procedure, pass(prec) :: descr => amg_zfile_prec_descr + procedure, pass(prec) :: memory_use => amg_zfile_prec_memory_use end type amg_zprec_type private :: amg_z_dump, amg_z_get_compl, amg_z_cmp_compl,& @@ -170,6 +171,21 @@ module amg_z_prec_type end subroutine amg_zfile_prec_descr end interface + + interface amg_memory_use + subroutine amg_zfile_prec_memory_use(prec,info,iout,root,verbosity,prefix) + import :: amg_zprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + end subroutine amg_zfile_prec_memory_use + end interface + interface amg_sizeof module procedure amg_zprec_sizeof end interface diff --git a/amgprec/impl/Makefile b/amgprec/impl/Makefile index 826c7dd1..08065b8d 100644 --- a/amgprec/impl/Makefile +++ b/amgprec/impl/Makefile @@ -22,22 +22,22 @@ MPFOBJS=$(SMPFOBJS) $(DMPFOBJS) $(CMPFOBJS) $(ZMPFOBJS) MPCOBJS=amg_dslud_interface.o amg_zslud_interface.o -DINNEROBJS= amg_dmlprec_bld.o amg_dfile_prec_descr.o \ +DINNEROBJS= amg_dmlprec_bld.o amg_dfile_prec_descr.o amg_dfile_prec_memory_use.o \ amg_d_smoothers_bld.o amg_d_hierarchy_bld.o amg_d_hierarchy_rebld.o \ amg_dmlprec_aply.o \ $(DMPFOBJS) amg_d_extprol_bld.o -SINNEROBJS= amg_smlprec_bld.o amg_sfile_prec_descr.o \ +SINNEROBJS= amg_smlprec_bld.o amg_sfile_prec_descr.o amg_sfile_prec_memory_use.o \ amg_s_smoothers_bld.o amg_s_hierarchy_bld.o amg_s_hierarchy_rebld.o \ amg_smlprec_aply.o \ $(SMPFOBJS) amg_s_extprol_bld.o -ZINNEROBJS= amg_zmlprec_bld.o amg_zfile_prec_descr.o \ +ZINNEROBJS= amg_zmlprec_bld.o amg_zfile_prec_descr.o amg_zfile_prec_memory_use.o \ amg_z_smoothers_bld.o amg_z_hierarchy_bld.o amg_z_hierarchy_rebld.o \ amg_zmlprec_aply.o \ $(ZMPFOBJS) amg_z_extprol_bld.o -CINNEROBJS= amg_cmlprec_bld.o amg_cfile_prec_descr.o \ +CINNEROBJS= amg_cmlprec_bld.o amg_cfile_prec_descr.o amg_cfile_prec_memory_use.o \ amg_c_smoothers_bld.o amg_c_hierarchy_bld.o amg_c_hierarchy_rebld.o \ amg_cmlprec_aply.o \ $(CMPFOBJS) amg_c_extprol_bld.o diff --git a/amgprec/impl/amg_cfile_prec_memory_use.f90 b/amgprec/impl/amg_cfile_prec_memory_use.f90 new file mode 100644 index 00000000..b71cefe2 --- /dev/null +++ b/amgprec/impl/amg_cfile_prec_memory_use.f90 @@ -0,0 +1,149 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_memory_use.f90 +! +! +! Subroutine: amg_file_prec_memory_use +! Version: complex +! +! This routine prints a memory_useiption of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_cfile_prec_memory_use(prec,info,iout,root, verbosity,prefix) + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cfile_prec_memory_use + use amg_c_inner_mod + use amg_c_gs_solver + + implicit none + ! Arguments + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, nswps + type(psb_ctxt_type) :: ctxt + integer(psb_ipk_) :: me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_memory_use' + integer(psb_ipk_) :: iout_, root_, verbosity_ + character(1024) :: prefix_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + ctxt = prec%ctxt + + if (allocated(prec%precv)) then + + call psb_info(ctxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + if (verbosity_ >=0) then + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + + write(iout_,*) + write(iout_,'(a,1x,a)') trim(prefix_),'Preconditioner memory usage' + nlev = size(prec%precv) + do ilev=1,nlev + call prec%precv(ilev)%memory_use(ilev,nlev,ilmin,info, & + & iout=iout_,verbosity=verbosity,prefix=prefix) + end do + end if + end if + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif +9998 continue +end subroutine amg_cfile_prec_memory_use diff --git a/amgprec/impl/amg_dfile_prec_memory_use.f90 b/amgprec/impl/amg_dfile_prec_memory_use.f90 new file mode 100644 index 00000000..9eb63c8b --- /dev/null +++ b/amgprec/impl/amg_dfile_prec_memory_use.f90 @@ -0,0 +1,149 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_memory_use.f90 +! +! +! Subroutine: amg_file_prec_memory_use +! Version: real +! +! This routine prints a memory_useiption of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_dfile_prec_memory_use(prec,info,iout,root, verbosity,prefix) + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dfile_prec_memory_use + use amg_d_inner_mod + use amg_d_gs_solver + + implicit none + ! Arguments + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, nswps + type(psb_ctxt_type) :: ctxt + integer(psb_ipk_) :: me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_memory_use' + integer(psb_ipk_) :: iout_, root_, verbosity_ + character(1024) :: prefix_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + ctxt = prec%ctxt + + if (allocated(prec%precv)) then + + call psb_info(ctxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + if (verbosity_ >=0) then + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + + write(iout_,*) + write(iout_,'(a,1x,a)') trim(prefix_),'Preconditioner memory usage' + nlev = size(prec%precv) + do ilev=1,nlev + call prec%precv(ilev)%memory_use(ilev,nlev,ilmin,info, & + & iout=iout_,verbosity=verbosity,prefix=prefix) + end do + end if + end if + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif +9998 continue +end subroutine amg_dfile_prec_memory_use diff --git a/amgprec/impl/amg_sfile_prec_memory_use.f90 b/amgprec/impl/amg_sfile_prec_memory_use.f90 new file mode 100644 index 00000000..49373233 --- /dev/null +++ b/amgprec/impl/amg_sfile_prec_memory_use.f90 @@ -0,0 +1,149 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_memory_use.f90 +! +! +! Subroutine: amg_file_prec_memory_use +! Version: real +! +! This routine prints a memory_useiption of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_sfile_prec_memory_use(prec,info,iout,root, verbosity,prefix) + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sfile_prec_memory_use + use amg_s_inner_mod + use amg_s_gs_solver + + implicit none + ! Arguments + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, nswps + type(psb_ctxt_type) :: ctxt + integer(psb_ipk_) :: me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_memory_use' + integer(psb_ipk_) :: iout_, root_, verbosity_ + character(1024) :: prefix_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + ctxt = prec%ctxt + + if (allocated(prec%precv)) then + + call psb_info(ctxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + if (verbosity_ >=0) then + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + + write(iout_,*) + write(iout_,'(a,1x,a)') trim(prefix_),'Preconditioner memory usage' + nlev = size(prec%precv) + do ilev=1,nlev + call prec%precv(ilev)%memory_use(ilev,nlev,ilmin,info, & + & iout=iout_,verbosity=verbosity,prefix=prefix) + end do + end if + end if + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif +9998 continue +end subroutine amg_sfile_prec_memory_use diff --git a/amgprec/impl/amg_zfile_prec_memory_use.f90 b/amgprec/impl/amg_zfile_prec_memory_use.f90 new file mode 100644 index 00000000..3657e9a5 --- /dev/null +++ b/amgprec/impl/amg_zfile_prec_memory_use.f90 @@ -0,0 +1,149 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_memory_use.f90 +! +! +! Subroutine: amg_file_prec_memory_use +! Version: complex +! +! This routine prints a memory_useiption of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_zfile_prec_memory_use(prec,info,iout,root, verbosity,prefix) + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zfile_prec_memory_use + use amg_z_inner_mod + use amg_z_gs_solver + + implicit none + ! Arguments + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, nswps + type(psb_ctxt_type) :: ctxt + integer(psb_ipk_) :: me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_memory_use' + integer(psb_ipk_) :: iout_, root_, verbosity_ + character(1024) :: prefix_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + ctxt = prec%ctxt + + if (allocated(prec%precv)) then + + call psb_info(ctxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + if (verbosity_ >=0) then + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + + write(iout_,*) + write(iout_,'(a,1x,a)') trim(prefix_),'Preconditioner memory usage' + nlev = size(prec%precv) + do ilev=1,nlev + call prec%precv(ilev)%memory_use(ilev,nlev,ilmin,info, & + & iout=iout_,verbosity=verbosity,prefix=prefix) + end do + end if + end if + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif +9998 continue +end subroutine amg_zfile_prec_memory_use diff --git a/amgprec/impl/level/Makefile b/amgprec/impl/level/Makefile index 4ea569bd..e7542084 100644 --- a/amgprec/impl/level/Makefile +++ b/amgprec/impl/level/Makefile @@ -15,6 +15,7 @@ amg_c_base_onelev_csetc.o \ amg_c_base_onelev_cseti.o \ amg_c_base_onelev_csetr.o \ amg_c_base_onelev_descr.o \ +amg_c_base_onelev_memory_use.o \ amg_c_base_onelev_dump.o \ amg_c_base_onelev_free.o \ amg_c_base_onelev_free_smoothers.o \ @@ -31,6 +32,7 @@ amg_d_base_onelev_csetc.o \ amg_d_base_onelev_cseti.o \ amg_d_base_onelev_csetr.o \ amg_d_base_onelev_descr.o \ +amg_d_base_onelev_memory_use.o \ amg_d_base_onelev_dump.o \ amg_d_base_onelev_free.o \ amg_d_base_onelev_free_smoothers.o \ @@ -47,6 +49,7 @@ amg_s_base_onelev_csetc.o \ amg_s_base_onelev_cseti.o \ amg_s_base_onelev_csetr.o \ amg_s_base_onelev_descr.o \ +amg_s_base_onelev_memory_use.o \ amg_s_base_onelev_dump.o \ amg_s_base_onelev_free.o \ amg_s_base_onelev_free_smoothers.o \ @@ -63,6 +66,7 @@ amg_z_base_onelev_csetc.o \ amg_z_base_onelev_cseti.o \ amg_z_base_onelev_csetr.o \ amg_z_base_onelev_descr.o \ +amg_z_base_onelev_memory_use.o \ amg_z_base_onelev_dump.o \ amg_z_base_onelev_free.o \ amg_z_base_onelev_free_smoothers.o \ diff --git a/amgprec/impl/level/amg_c_base_onelev_memory_use.f90 b/amgprec/impl/level/amg_c_base_onelev_memory_use.f90 new file mode 100644 index 00000000..517c3892 --- /dev/null +++ b/amgprec/impl/level/amg_c_base_onelev_memory_use.f90 @@ -0,0 +1,113 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_c_base_onelev_memory_use(lv,il,nl,ilmin,info,iout,verbosity,prefix) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_memory_use + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_base_onelev_memory_use' + integer(psb_ipk_) :: iout_, verbosity_ + logical :: coarse + character(1024) :: prefix_ + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + write(iout_,*) trim(prefix_) + + if (coarse) then + write(iout_,*) trim(prefix_), ' Level ',il,' (coarse)' + else + write(iout_,*) trim(prefix_), ' Level ',il + end if + + write(iout_,*) trim(prefix_), ' Matrix:', lv%base_a%sizeof() + write(iout_,*) trim(prefix_), ' Descriptor:', lv%base_desc%sizeof() + if (il >1) write(iout_,*) trim(prefix_), ' Linear map:', lv%linmap%sizeof() + if (allocated(lv%sm)) write(iout_,*) trim(prefix_), ' Smoother:', lv%sm%sizeof() + if (allocated(lv%sm2a)) write(iout_,*) trim(prefix_), ' Smoother 2:', lv%sm2a%sizeof() + if (allocated(lv%wrk)) write(iout_,*) trim(prefix_), ' Workspace:', lv%wrk%sizeof() + + +9998 continue + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_memory_use diff --git a/amgprec/impl/level/amg_d_base_onelev_memory_use.f90 b/amgprec/impl/level/amg_d_base_onelev_memory_use.f90 new file mode 100644 index 00000000..d339d3a9 --- /dev/null +++ b/amgprec/impl/level/amg_d_base_onelev_memory_use.f90 @@ -0,0 +1,113 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_d_base_onelev_memory_use(lv,il,nl,ilmin,info,iout,verbosity,prefix) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_memory_use + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_base_onelev_memory_use' + integer(psb_ipk_) :: iout_, verbosity_ + logical :: coarse + character(1024) :: prefix_ + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + write(iout_,*) trim(prefix_) + + if (coarse) then + write(iout_,*) trim(prefix_), ' Level ',il,' (coarse)' + else + write(iout_,*) trim(prefix_), ' Level ',il + end if + + write(iout_,*) trim(prefix_), ' Matrix:', lv%base_a%sizeof() + write(iout_,*) trim(prefix_), ' Descriptor:', lv%base_desc%sizeof() + if (il >1) write(iout_,*) trim(prefix_), ' Linear map:', lv%linmap%sizeof() + if (allocated(lv%sm)) write(iout_,*) trim(prefix_), ' Smoother:', lv%sm%sizeof() + if (allocated(lv%sm2a)) write(iout_,*) trim(prefix_), ' Smoother 2:', lv%sm2a%sizeof() + if (allocated(lv%wrk)) write(iout_,*) trim(prefix_), ' Workspace:', lv%wrk%sizeof() + + +9998 continue + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_memory_use diff --git a/amgprec/impl/level/amg_s_base_onelev_memory_use.f90 b/amgprec/impl/level/amg_s_base_onelev_memory_use.f90 new file mode 100644 index 00000000..a8c130e6 --- /dev/null +++ b/amgprec/impl/level/amg_s_base_onelev_memory_use.f90 @@ -0,0 +1,113 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_s_base_onelev_memory_use(lv,il,nl,ilmin,info,iout,verbosity,prefix) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_memory_use + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_base_onelev_memory_use' + integer(psb_ipk_) :: iout_, verbosity_ + logical :: coarse + character(1024) :: prefix_ + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + write(iout_,*) trim(prefix_) + + if (coarse) then + write(iout_,*) trim(prefix_), ' Level ',il,' (coarse)' + else + write(iout_,*) trim(prefix_), ' Level ',il + end if + + write(iout_,*) trim(prefix_), ' Matrix:', lv%base_a%sizeof() + write(iout_,*) trim(prefix_), ' Descriptor:', lv%base_desc%sizeof() + if (il >1) write(iout_,*) trim(prefix_), ' Linear map:', lv%linmap%sizeof() + if (allocated(lv%sm)) write(iout_,*) trim(prefix_), ' Smoother:', lv%sm%sizeof() + if (allocated(lv%sm2a)) write(iout_,*) trim(prefix_), ' Smoother 2:', lv%sm2a%sizeof() + if (allocated(lv%wrk)) write(iout_,*) trim(prefix_), ' Workspace:', lv%wrk%sizeof() + + +9998 continue + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_memory_use diff --git a/amgprec/impl/level/amg_z_base_onelev_memory_use.f90 b/amgprec/impl/level/amg_z_base_onelev_memory_use.f90 new file mode 100644 index 00000000..db73ac0b --- /dev/null +++ b/amgprec/impl/level/amg_z_base_onelev_memory_use.f90 @@ -0,0 +1,113 @@ +! +! +! AMG4PSBLAS version 1.0 +! Algebraic Multigrid Package +! based on PSBLAS (Parallel Sparse BLAS version 3.7) +! +! (C) Copyright 2021 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Fabio Durastante +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the AMG4PSBLAS group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! verbosity: +! <0: suppress all messages +! 0: normal +! >1: increased details +! +subroutine amg_z_base_onelev_memory_use(lv,il,nl,ilmin,info,iout,verbosity,prefix) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_memory_use + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: verbosity + character(len=*), intent(in), optional :: prefix + + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_base_onelev_memory_use' + integer(psb_ipk_) :: iout_, verbosity_ + logical :: coarse + character(1024) :: prefix_ + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (present(verbosity)) then + verbosity_ = verbosity + else + verbosity_ = 0 + end if + if (verbosity_ < 0) goto 9998 + if (present(prefix)) then + prefix_ = prefix + else + prefix_ = "" + end if + + write(iout_,*) trim(prefix_) + + if (coarse) then + write(iout_,*) trim(prefix_), ' Level ',il,' (coarse)' + else + write(iout_,*) trim(prefix_), ' Level ',il + end if + + write(iout_,*) trim(prefix_), ' Matrix:', lv%base_a%sizeof() + write(iout_,*) trim(prefix_), ' Descriptor:', lv%base_desc%sizeof() + if (il >1) write(iout_,*) trim(prefix_), ' Linear map:', lv%linmap%sizeof() + if (allocated(lv%sm)) write(iout_,*) trim(prefix_), ' Smoother:', lv%sm%sizeof() + if (allocated(lv%sm2a)) write(iout_,*) trim(prefix_), ' Smoother 2:', lv%sm2a%sizeof() + if (allocated(lv%wrk)) write(iout_,*) trim(prefix_), ' Workspace:', lv%wrk%sizeof() + + +9998 continue + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_memory_use