Improve memory usage in fix_coo, and mv_to/mv_from CSR/CSC.

psblas-3.6-maint
Salvatore Filippone 6 years ago
parent 3238f2c248
commit 00df8edd06

@ -3416,21 +3416,26 @@ subroutine psb_c_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
dupl_ = dupl
allocate(iaux(max(nr,nc,nzin)+2),stat=info)
allocate(iaux(nzin+2),stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(max(nr,nc,nzin)+2), stat=info)
use_buffers = (info == 0)
select case(idir_)
case(psb_row_major_)
! Row major order
if (nr <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
if (.not.( (ia(1) < 1).or.(ia(1)> nr)) ) then
iaux(:) = 0
@ -3752,6 +3757,14 @@ subroutine psb_c_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
case(psb_col_major_)
if (nc <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
iaux(:) = 0
if (.not.( (ja(1) < 1).or.(ja(1)> nc)) ) then

@ -2298,7 +2298,7 @@ subroutine psb_c_mv_csc_from_coo(a,b,info)
call move_alloc(b%ja,itemp)
call move_alloc(b%ia,a%ia)
call move_alloc(b%val,a%val)
call psb_realloc(nc+1,a%icp,info)
call psb_realloc(max(nr+1,nc+1),a%icp,info)
call b%free()
a%icp(:) = 0

@ -999,6 +999,8 @@ contains
end subroutine psb_c_csr_cssv
subroutine psb_c_csr_cssm(alpha,a,x,beta,y,info,trans)
use psb_error_mod
use psb_string_mod
@ -2960,7 +2962,7 @@ subroutine psb_c_cp_csr_from_coo(a,b,info)
call move_alloc(tmp%ia,itemp)
call move_alloc(tmp%ja,a%ja)
call move_alloc(tmp%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call tmp%free()
else
@ -3129,7 +3131,7 @@ subroutine psb_c_mv_csr_from_coo(a,b,info)
call move_alloc(b%ia,itemp)
call move_alloc(b%ja,a%ja)
call move_alloc(b%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call b%free()
@ -3384,7 +3386,7 @@ subroutine psb_ccsrspspmm(a,b,c,info)
! Estimate number of nonzeros on output.
nza = a%get_nzeros()
nzb = b%get_nzeros()
nzc = int(1.25*(nza+nzb))
nzc = 2*(nza+nzb)
call c%allocate(ma,nb,nzc)
call csr_spspmm(a,b,c,info)

@ -3416,21 +3416,26 @@ subroutine psb_d_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
dupl_ = dupl
allocate(iaux(max(nr,nc,nzin)+2),stat=info)
allocate(iaux(nzin+2),stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(max(nr,nc,nzin)+2), stat=info)
use_buffers = (info == 0)
select case(idir_)
case(psb_row_major_)
! Row major order
if (nr <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
if (.not.( (ia(1) < 1).or.(ia(1)> nr)) ) then
iaux(:) = 0
@ -3752,6 +3757,14 @@ subroutine psb_d_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
case(psb_col_major_)
if (nc <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
iaux(:) = 0
if (.not.( (ja(1) < 1).or.(ja(1)> nc)) ) then

@ -2298,7 +2298,7 @@ subroutine psb_d_mv_csc_from_coo(a,b,info)
call move_alloc(b%ja,itemp)
call move_alloc(b%ia,a%ia)
call move_alloc(b%val,a%val)
call psb_realloc(nc+1,a%icp,info)
call psb_realloc(max(nr+1,nc+1),a%icp,info)
call b%free()
a%icp(:) = 0

@ -999,6 +999,8 @@ contains
end subroutine psb_d_csr_cssv
subroutine psb_d_csr_cssm(alpha,a,x,beta,y,info,trans)
use psb_error_mod
use psb_string_mod
@ -2960,7 +2962,7 @@ subroutine psb_d_cp_csr_from_coo(a,b,info)
call move_alloc(tmp%ia,itemp)
call move_alloc(tmp%ja,a%ja)
call move_alloc(tmp%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call tmp%free()
else
@ -3129,7 +3131,7 @@ subroutine psb_d_mv_csr_from_coo(a,b,info)
call move_alloc(b%ia,itemp)
call move_alloc(b%ja,a%ja)
call move_alloc(b%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call b%free()
@ -3384,7 +3386,7 @@ subroutine psb_dcsrspspmm(a,b,c,info)
! Estimate number of nonzeros on output.
nza = a%get_nzeros()
nzb = b%get_nzeros()
nzc = int(1.25*(nza+nzb))
nzc = 2*(nza+nzb)
call c%allocate(ma,nb,nzc)
call csr_spspmm(a,b,c,info)

@ -3416,21 +3416,26 @@ subroutine psb_s_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
dupl_ = dupl
allocate(iaux(max(nr,nc,nzin)+2),stat=info)
allocate(iaux(nzin+2),stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(max(nr,nc,nzin)+2), stat=info)
use_buffers = (info == 0)
select case(idir_)
case(psb_row_major_)
! Row major order
if (nr <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
if (.not.( (ia(1) < 1).or.(ia(1)> nr)) ) then
iaux(:) = 0
@ -3752,6 +3757,14 @@ subroutine psb_s_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
case(psb_col_major_)
if (nc <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
iaux(:) = 0
if (.not.( (ja(1) < 1).or.(ja(1)> nc)) ) then

@ -2298,7 +2298,7 @@ subroutine psb_s_mv_csc_from_coo(a,b,info)
call move_alloc(b%ja,itemp)
call move_alloc(b%ia,a%ia)
call move_alloc(b%val,a%val)
call psb_realloc(nc+1,a%icp,info)
call psb_realloc(max(nr+1,nc+1),a%icp,info)
call b%free()
a%icp(:) = 0

@ -999,6 +999,8 @@ contains
end subroutine psb_s_csr_cssv
subroutine psb_s_csr_cssm(alpha,a,x,beta,y,info,trans)
use psb_error_mod
use psb_string_mod
@ -2960,7 +2962,7 @@ subroutine psb_s_cp_csr_from_coo(a,b,info)
call move_alloc(tmp%ia,itemp)
call move_alloc(tmp%ja,a%ja)
call move_alloc(tmp%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call tmp%free()
else
@ -3129,7 +3131,7 @@ subroutine psb_s_mv_csr_from_coo(a,b,info)
call move_alloc(b%ia,itemp)
call move_alloc(b%ja,a%ja)
call move_alloc(b%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call b%free()
@ -3384,7 +3386,7 @@ subroutine psb_scsrspspmm(a,b,c,info)
! Estimate number of nonzeros on output.
nza = a%get_nzeros()
nzb = b%get_nzeros()
nzc = int(1.25*(nza+nzb))
nzc = 2*(nza+nzb)
call c%allocate(ma,nb,nzc)
call csr_spspmm(a,b,c,info)

@ -3416,21 +3416,26 @@ subroutine psb_z_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
dupl_ = dupl
allocate(iaux(max(nr,nc,nzin)+2),stat=info)
allocate(iaux(nzin+2),stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(max(nr,nc,nzin)+2), stat=info)
use_buffers = (info == 0)
select case(idir_)
case(psb_row_major_)
! Row major order
if (nr <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
if (.not.( (ia(1) < 1).or.(ia(1)> nr)) ) then
iaux(:) = 0
@ -3752,6 +3757,14 @@ subroutine psb_z_fix_coo_inner(nr,nc,nzin,dupl,ia,ja,val,nzout,info,idir)
case(psb_col_major_)
if (nc <= nzin) then
! Avoid strange situations with large indices
allocate(ias(nzin),jas(nzin),vs(nzin),ix2(nzin+2), stat=info)
use_buffers = (info == 0)
else
use_buffers = .false.
end if
if (use_buffers) then
iaux(:) = 0
if (.not.( (ja(1) < 1).or.(ja(1)> nc)) ) then

@ -2298,7 +2298,7 @@ subroutine psb_z_mv_csc_from_coo(a,b,info)
call move_alloc(b%ja,itemp)
call move_alloc(b%ia,a%ia)
call move_alloc(b%val,a%val)
call psb_realloc(nc+1,a%icp,info)
call psb_realloc(max(nr+1,nc+1),a%icp,info)
call b%free()
a%icp(:) = 0

@ -999,6 +999,8 @@ contains
end subroutine psb_z_csr_cssv
subroutine psb_z_csr_cssm(alpha,a,x,beta,y,info,trans)
use psb_error_mod
use psb_string_mod
@ -2960,7 +2962,7 @@ subroutine psb_z_cp_csr_from_coo(a,b,info)
call move_alloc(tmp%ia,itemp)
call move_alloc(tmp%ja,a%ja)
call move_alloc(tmp%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call tmp%free()
else
@ -3129,7 +3131,7 @@ subroutine psb_z_mv_csr_from_coo(a,b,info)
call move_alloc(b%ia,itemp)
call move_alloc(b%ja,a%ja)
call move_alloc(b%val,a%val)
call psb_realloc(nr+1,a%irp,info)
call psb_realloc(max(nr+1,nc+1),a%irp,info)
call b%free()
@ -3384,7 +3386,7 @@ subroutine psb_zcsrspspmm(a,b,c,info)
! Estimate number of nonzeros on output.
nza = a%get_nzeros()
nzb = b%get_nzeros()
nzc = int(1.25*(nza+nzb))
nzc = 2*(nza+nzb)
call c%allocate(ma,nb,nzc)
call csr_spspmm(a,b,c,info)

Loading…
Cancel
Save