mirror of
https://github.com/sfilippone/amg4psblas.git
synced 2026-10-06 22:55:12 +00:00
Added interface for the allocate_wrk member function of a preconditioner. It handles also allocation on the CUDA/GPU side.
This commit is contained in:
@@ -32,6 +32,7 @@ extern "C" {
|
||||
psb_i_t amg_c_dprecbld_opt(psb_c_dspmat *ah, psb_c_descriptor *cdh,
|
||||
amg_c_dprec *ph, const char *afmt);
|
||||
psb_i_t amg_c_ddescr(amg_c_dprec *ph);
|
||||
psb_i_t amg_c_dallocate_wrk(amg_c_dprec *ph, const char *chfmt);
|
||||
|
||||
psb_i_t amg_c_dkrylov(const char *method, psb_c_dspmat *ah, amg_c_dprec *ph,
|
||||
psb_c_dvector *bh, psb_c_dvector *xh,
|
||||
|
||||
@@ -33,6 +33,7 @@ extern "C" {
|
||||
amg_c_zprec *ph, const char *afmt);
|
||||
|
||||
psb_i_t amg_c_zdescr(amg_c_zprec *ph);
|
||||
psb_i_t amg_c_zallocate_wrk(amg_c_zprec *ph, const char *chfmt);
|
||||
|
||||
psb_i_t amg_c_zkrylov(const char *method, psb_c_zspmat *ah, amg_c_zprec *ph,
|
||||
psb_c_zvector *bh, psb_c_zvector *xh,
|
||||
|
||||
@@ -491,4 +491,55 @@ end function amg_c_dprecapply_opt
|
||||
return
|
||||
end function amg_c_ddescr
|
||||
|
||||
function amg_c_dallocate_wrk(ph,chfmt) bind(c, name="amg_c_dallocate_wrk") result(res)
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
use psb_cuda_mod
|
||||
#endif
|
||||
implicit none
|
||||
|
||||
integer(psb_c_ipk_) :: res
|
||||
type(psb_c_object_type) :: ph
|
||||
character(c_char) :: chfmt(*)
|
||||
integer(psb_ipk_) :: iret
|
||||
type(amg_dprec_type), pointer :: precp
|
||||
character(len=6) :: fchfmt
|
||||
! Local variable
|
||||
integer(psb_ipk_) :: info
|
||||
! Local mold variables
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
type(psb_d_vect_cuda), target :: dvgpu
|
||||
#endif
|
||||
type(psb_d_base_vect_type), target :: dvhost
|
||||
class(psb_d_base_vect_type), pointer :: vmold
|
||||
|
||||
res = -1
|
||||
if (c_associated(ph%item)) then
|
||||
call c_f_pointer(ph%item,precp)
|
||||
else
|
||||
return
|
||||
end if
|
||||
|
||||
call psb_stringc2f(chfmt,fchfmt)
|
||||
select case (psb_toupper(fchfmt))
|
||||
case('HOST','CPU')
|
||||
vmold => dvhost
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
case('GPU','DEVICE')
|
||||
vmold => dvgpu
|
||||
#endif
|
||||
case default
|
||||
write(psb_err_unit,'(A)') 'amg_c_dallocate_wrk: Unknown format ', fchfmt, ' defaulting to HOST/CPU'
|
||||
vmold => dvhost
|
||||
end select
|
||||
|
||||
call precp%allocate_wrk(info,vmold=vmold)
|
||||
|
||||
iret = info
|
||||
|
||||
res = MLDC_ERR_FILTER(iret)
|
||||
MLDC_ERR_HANDLE(res)
|
||||
return
|
||||
|
||||
end function amg_c_dallocate_wrk
|
||||
|
||||
end module amg_dprec_cbind_mod
|
||||
|
||||
@@ -487,4 +487,55 @@ contains
|
||||
return
|
||||
end function amg_c_zdescr
|
||||
|
||||
function amg_c_zallocate_wrk(ph,chfmt) bind(c, name="amg_c_zallocate_wrk") result(res)
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
use psb_cuda_mod
|
||||
#endif
|
||||
implicit none
|
||||
|
||||
integer(psb_c_ipk_) :: res
|
||||
type(psb_c_object_type) :: ph
|
||||
character(c_char) :: chfmt(*)
|
||||
integer(psb_ipk_) :: iret
|
||||
type(amg_zprec_type), pointer :: precp
|
||||
character(len=6) :: fchfmt
|
||||
! Local variable
|
||||
integer(psb_ipk_) :: info
|
||||
! Local mold variables
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
type(psb_z_vect_cuda), target :: zvgpu
|
||||
#endif
|
||||
type(psb_z_base_vect_type), target :: zvhost
|
||||
class(psb_z_base_vect_type), pointer :: vmold
|
||||
|
||||
res = -1
|
||||
if (c_associated(ph%item)) then
|
||||
call c_f_pointer(ph%item,precp)
|
||||
else
|
||||
return
|
||||
end if
|
||||
|
||||
call psb_stringc2f(chfmt,fchfmt)
|
||||
select case (psb_toupper(fchfmt))
|
||||
case('HOST','CPU')
|
||||
vmold => zvhost
|
||||
#if defined (PSB_HAVE_CUDA)
|
||||
case('GPU','DEVICE')
|
||||
vmold => zvgpu
|
||||
#endif
|
||||
case default
|
||||
write(psb_err_unit,'(A)') 'amg_c_zallocate_wrk: Unknown format ', fchfmt, ' defaulting to HOST/CPU'
|
||||
vmold => zvhost
|
||||
end select
|
||||
|
||||
call precp%allocate_wrk(info,vmold=vmold)
|
||||
|
||||
iret = info
|
||||
|
||||
res = MLDC_ERR_FILTER(iret)
|
||||
MLDC_ERR_HANDLE(res)
|
||||
return
|
||||
|
||||
end function amg_c_zallocate_wrk
|
||||
|
||||
end module amg_zprec_cbind_mod
|
||||
|
||||
Reference in New Issue
Block a user