Fix track cuda memory for matrix types

repack-track
Salvatore Filippone 11 months ago
parent d94b3dae58
commit 84981b9135

@ -60,6 +60,7 @@ subroutine psb_c_cuda_cp_elg_from_coo(a,b,info)
if (c_associated(a%deviceMat)) then
call trackCudafree(' c_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -71,12 +72,14 @@ subroutine psb_c_cuda_cp_elg_from_coo(a,b,info)
if (info == 0) info = psi_CopyCooToElg(nr,nc,nza, hacksize,ldv,nzm, &
& a%irn,idisp,b%ja,b%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' c_elg ',a%sizeof())
else
call b%cp_to_coo(tmp,info)
call psi_c_count_ell_from_coo(a,tmp,idisp,ldv,nzm,info,hacksize=hacksize)
if (c_associated(a%deviceMat)) then
call trackCudafree(' c_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -89,6 +92,7 @@ subroutine psb_c_cuda_cp_elg_from_coo(a,b,info)
& a%irn,idisp,tmp%ja,tmp%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' c_elg ',a%sizeof())
end if
if (info /= psb_success_) goto 9999

@ -66,7 +66,7 @@ subroutine psb_c_cuda_elg_to_gpu(a,info,nzrm)
if ((pitch /= gpu_parms%pitch).or.(maxrowsize /= gpu_parms%maxRowSize)) then
if (c_associated(a%deviceMat)) then
call trackCudaAlloc(' c_elg ',a%sizeof())
call trackCudaFree(' c_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
info = FallocEllDevice(a%deviceMat,m,nzm,nzt,n,spgpu_type_complex_float,1)

@ -53,7 +53,7 @@ subroutine psb_c_cuda_hybg_to_gpu(a,info,nzrm)
m = a%get_nrows()
n = a%get_ncols()
nz = a%get_nzeros()
if (c_associated(a%deviceMat%Mat)) then
if (c_associated(a%deviceMat)) then
call trackCudaFree(' c_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if

@ -60,6 +60,7 @@ subroutine psb_d_cuda_cp_elg_from_coo(a,b,info)
if (c_associated(a%deviceMat)) then
call trackCudafree(' d_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -71,12 +72,14 @@ subroutine psb_d_cuda_cp_elg_from_coo(a,b,info)
if (info == 0) info = psi_CopyCooToElg(nr,nc,nza, hacksize,ldv,nzm, &
& a%irn,idisp,b%ja,b%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' d_elg ',a%sizeof())
else
call b%cp_to_coo(tmp,info)
call psi_d_count_ell_from_coo(a,tmp,idisp,ldv,nzm,info,hacksize=hacksize)
if (c_associated(a%deviceMat)) then
call trackCudafree(' d_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -89,6 +92,7 @@ subroutine psb_d_cuda_cp_elg_from_coo(a,b,info)
& a%irn,idisp,tmp%ja,tmp%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' d_elg ',a%sizeof())
end if
if (info /= psb_success_) goto 9999

@ -66,7 +66,7 @@ subroutine psb_d_cuda_elg_to_gpu(a,info,nzrm)
if ((pitch /= gpu_parms%pitch).or.(maxrowsize /= gpu_parms%maxRowSize)) then
if (c_associated(a%deviceMat)) then
call trackCudaAlloc(' d_elg ',a%sizeof())
call trackCudaFree(' d_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
info = FallocEllDevice(a%deviceMat,m,nzm,nzt,n,spgpu_type_double,1)

@ -53,7 +53,7 @@ subroutine psb_d_cuda_hybg_to_gpu(a,info,nzrm)
m = a%get_nrows()
n = a%get_ncols()
nz = a%get_nzeros()
if (c_associated(a%deviceMat%Mat)) then
if (c_associated(a%deviceMat)) then
call trackCudaFree(' d_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if

@ -60,6 +60,7 @@ subroutine psb_s_cuda_cp_elg_from_coo(a,b,info)
if (c_associated(a%deviceMat)) then
call trackCudafree(' s_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -71,12 +72,14 @@ subroutine psb_s_cuda_cp_elg_from_coo(a,b,info)
if (info == 0) info = psi_CopyCooToElg(nr,nc,nza, hacksize,ldv,nzm, &
& a%irn,idisp,b%ja,b%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' s_elg ',a%sizeof())
else
call b%cp_to_coo(tmp,info)
call psi_s_count_ell_from_coo(a,tmp,idisp,ldv,nzm,info,hacksize=hacksize)
if (c_associated(a%deviceMat)) then
call trackCudafree(' s_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -89,6 +92,7 @@ subroutine psb_s_cuda_cp_elg_from_coo(a,b,info)
& a%irn,idisp,tmp%ja,tmp%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' s_elg ',a%sizeof())
end if
if (info /= psb_success_) goto 9999

@ -66,7 +66,7 @@ subroutine psb_s_cuda_elg_to_gpu(a,info,nzrm)
if ((pitch /= gpu_parms%pitch).or.(maxrowsize /= gpu_parms%maxRowSize)) then
if (c_associated(a%deviceMat)) then
call trackCudaAlloc(' s_elg ',a%sizeof())
call trackCudaFree(' s_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
info = FallocEllDevice(a%deviceMat,m,nzm,nzt,n,spgpu_type_float,1)

@ -53,7 +53,7 @@ subroutine psb_s_cuda_hybg_to_gpu(a,info,nzrm)
m = a%get_nrows()
n = a%get_ncols()
nz = a%get_nzeros()
if (c_associated(a%deviceMat%Mat)) then
if (c_associated(a%deviceMat)) then
call trackCudaFree(' s_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if

@ -60,6 +60,7 @@ subroutine psb_z_cuda_cp_elg_from_coo(a,b,info)
if (c_associated(a%deviceMat)) then
call trackCudafree(' z_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -71,12 +72,14 @@ subroutine psb_z_cuda_cp_elg_from_coo(a,b,info)
if (info == 0) info = psi_CopyCooToElg(nr,nc,nza, hacksize,ldv,nzm, &
& a%irn,idisp,b%ja,b%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' z_elg ',a%sizeof())
else
call b%cp_to_coo(tmp,info)
call psi_z_count_ell_from_coo(a,tmp,idisp,ldv,nzm,info,hacksize=hacksize)
if (c_associated(a%deviceMat)) then
call trackCudafree(' z_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
@ -89,6 +92,7 @@ subroutine psb_z_cuda_cp_elg_from_coo(a,b,info)
& a%irn,idisp,tmp%ja,tmp%val, a%deviceMat)
call a%set_dev()
call trackCudaAlloc(' z_elg ',a%sizeof())
end if
if (info /= psb_success_) goto 9999

@ -66,7 +66,7 @@ subroutine psb_z_cuda_elg_to_gpu(a,info,nzrm)
if ((pitch /= gpu_parms%pitch).or.(maxrowsize /= gpu_parms%maxRowSize)) then
if (c_associated(a%deviceMat)) then
call trackCudaAlloc(' z_elg ',a%sizeof())
call trackCudaFree(' z_elg ',a%sizeof())
call freeEllDevice(a%deviceMat)
endif
info = FallocEllDevice(a%deviceMat,m,nzm,nzt,n,spgpu_type_complex_double,1)

@ -53,7 +53,7 @@ subroutine psb_z_cuda_hybg_to_gpu(a,info,nzrm)
m = a%get_nrows()
n = a%get_ncols()
nz = a%get_nzeros()
if (c_associated(a%deviceMat%Mat)) then
if (c_associated(a%deviceMat)) then
call trackCudaFree(' z_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if

@ -353,8 +353,10 @@ contains
class(psb_c_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' c_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat%Mat)) then
call trackCudaFree(' c_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
end if
call a%psb_c_csr_sparse_mat%free()
return
@ -368,7 +370,6 @@ contains
type(psb_c_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' c_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
return

@ -269,7 +269,7 @@ contains
type(psb_c_cuda_dnsg_sparse_mat), intent(inout) :: a
if (c_associated(a%deviceMat)) &
& call freeDnsDevice(a%deviceMat)
& call freeDnsDevice(a%deviceMat)
a%deviceMat = c_null_ptr
return

@ -266,8 +266,10 @@ contains
integer(psb_ipk_) :: info
class(psb_c_cuda_hybg_sparse_mat), intent(inout) :: a
call trackCudaFree(' c_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat)) then
call trackCudaFree(' c_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if
call a%psb_c_csr_sparse_mat%free()
return

@ -353,8 +353,10 @@ contains
class(psb_d_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' d_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat%Mat)) then
call trackCudaFree(' d_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
end if
call a%psb_d_csr_sparse_mat%free()
return
@ -368,7 +370,6 @@ contains
type(psb_d_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' d_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
return

@ -269,7 +269,7 @@ contains
type(psb_d_cuda_dnsg_sparse_mat), intent(inout) :: a
if (c_associated(a%deviceMat)) &
& call freeDnsDevice(a%deviceMat)
& call freeDnsDevice(a%deviceMat)
a%deviceMat = c_null_ptr
return

@ -266,8 +266,10 @@ contains
integer(psb_ipk_) :: info
class(psb_d_cuda_hybg_sparse_mat), intent(inout) :: a
call trackCudaFree(' d_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat)) then
call trackCudaFree(' d_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if
call a%psb_d_csr_sparse_mat%free()
return

@ -353,8 +353,10 @@ contains
class(psb_i_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' i_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat%Mat)) then
call trackCudaFree(' i_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
end if
call a%psb_i_csr_sparse_mat%free()
return
@ -368,7 +370,6 @@ contains
type(psb_i_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' i_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
return

@ -269,7 +269,7 @@ contains
type(psb_i_cuda_dnsg_sparse_mat), intent(inout) :: a
if (c_associated(a%deviceMat)) &
& call freeDnsDevice(a%deviceMat)
& call freeDnsDevice(a%deviceMat)
a%deviceMat = c_null_ptr
return

@ -266,8 +266,10 @@ contains
integer(psb_ipk_) :: info
class(psb_i_cuda_hybg_sparse_mat), intent(inout) :: a
call trackCudaFree(' i_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat)) then
call trackCudaFree(' i_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if
call a%psb_i_csr_sparse_mat%free()
return

@ -353,8 +353,10 @@ contains
class(psb_s_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' s_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat%Mat)) then
call trackCudaFree(' s_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
end if
call a%psb_s_csr_sparse_mat%free()
return
@ -368,7 +370,6 @@ contains
type(psb_s_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' s_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
return

@ -269,7 +269,7 @@ contains
type(psb_s_cuda_dnsg_sparse_mat), intent(inout) :: a
if (c_associated(a%deviceMat)) &
& call freeDnsDevice(a%deviceMat)
& call freeDnsDevice(a%deviceMat)
a%deviceMat = c_null_ptr
return

@ -266,8 +266,10 @@ contains
integer(psb_ipk_) :: info
class(psb_s_cuda_hybg_sparse_mat), intent(inout) :: a
call trackCudaFree(' s_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat)) then
call trackCudaFree(' s_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if
call a%psb_s_csr_sparse_mat%free()
return

@ -353,8 +353,10 @@ contains
class(psb_z_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' z_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat%Mat)) then
call trackCudaFree(' z_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
end if
call a%psb_z_csr_sparse_mat%free()
return
@ -368,7 +370,6 @@ contains
type(psb_z_cuda_csrg_sparse_mat), intent(inout) :: a
call trackCudaFree(' z_csrg ',a%sizeof())
info = CSRGDeviceFree(a%deviceMat)
return

@ -269,7 +269,7 @@ contains
type(psb_z_cuda_dnsg_sparse_mat), intent(inout) :: a
if (c_associated(a%deviceMat)) &
& call freeDnsDevice(a%deviceMat)
& call freeDnsDevice(a%deviceMat)
a%deviceMat = c_null_ptr
return

@ -266,8 +266,10 @@ contains
integer(psb_ipk_) :: info
class(psb_z_cuda_hybg_sparse_mat), intent(inout) :: a
call trackCudaFree(' z_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
if (c_associated(a%deviceMat)) then
call trackCudaFree(' z_hybg ',a%sizeof())
info = HYBGDeviceFree(a%deviceMat)
end if
call a%psb_z_csr_sparse_mat%free()
return

@ -595,7 +595,7 @@ program pdgenmv
! solver parameters
integer(psb_epk_) :: amatsize, precsize, descsize, annz, nbytes
real(psb_dpk_) :: err, eps, td
integer, parameter :: ntests=200, ngpu=50, ncnv=20
integer, parameter :: ntests=200, ngpu=50, ncnv=10
type(psb_d_coo_sparse_mat), target :: acoo
type(psb_d_csr_sparse_mat), target :: acsr
type(psb_d_ell_sparse_mat), target :: aell

Loading…
Cancel
Save