Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
bicgstab_device Module Reference

Provides a device implementation of the BiCGStab method.

Data Types

type  bicgstab_device_t
 Device implementation of the right-preconditioned BiCGStab method. More...
 
interface  hip_bicgstab_part1
 
interface  hip_bicgstab_part2
 
interface  hip_bicgstab_product_and_norm
 
interface  hip_bicgstab_update_p
 

Functions/Subroutines

subroutine device_bicgstab_update_p (p_d, r_d, v_d, beta, omega, n)
 Search direction update \(p = r + \beta (p - \omega v)\).
 
subroutine device_bicgstab_product_and_norm (product, norm_squared, a_d, b_d, mult_d, n)
 Weighted inner product and squared norm in one reduction.
 
real(kind=rp) function device_bicgstab_part1 (s_d, r_d, v_d, mult_d, alpha, n)
 BiCGStab part 1, \(s = r - \alpha v\).
 
subroutine device_bicgstab_part2 (rtr, rho, x_d, r_d, p_hat_d, s_hat_d, s_d, t_d, f_d, mult_d, alpha, omega, n)
 BiCGStab part 2, \(x = x + \alpha \hat{p} + \omega \hat{s}\) and \(r = s - \omega t\).
 
subroutine bicgstab_device_init (this, n, max_iter, m, rel_tol, abs_tol, monitor)
 Initialise a device BiCGStab solver.
 
subroutine bicgstab_device_free (this)
 Free a device BiCGStab solver.
 
type(ksp_monitor_t) function bicgstab_device_solve (this, ax, x, f, n, coef, bc_projector, gs_h, niter)
 Solve a linear system with the device BiCGStab method.
 
subroutine bicgstab_device_check_inner_product (inner_product, norm_a, norm_b, quantity)
 Check an inner product for a BiCGStab breakdown.
 
real(kind=rp) function bicgstab_device_sqrt (value, quantity)
 Return the square root of a valid squared norm.
 
type(ksp_monitor_t) function, dimension(3) bicgstab_device_solve_coupled (this, ax, x, y, z, fx, fy, fz, n, coef, bc_projector, gs_h, niter)
 Solve three independent systems with the device BiCGStab method.
 

Function/Subroutine Documentation

◆ bicgstab_device_check_inner_product()

subroutine bicgstab_device::bicgstab_device_check_inner_product ( real(kind=rp), intent(in inner_product,
real(kind=rp), intent(in norm_a,
real(kind=rp), intent(in norm_b,
character(len=*), intent(in quantity 
)
private

The comparison is normalised by both vector norms. Dividing by the larger norm first avoids overflow in their product and preserves scale invariance.

Parameters
inner_productWeighted inner product of the two vectors.
norm_aNorm of the first vector.
norm_bNorm of the second vector.
quantityName of the algorithmic quantity for error reporting.

Definition at line 796 of file bicgstab_device.F90.

Here is the caller graph for this function:

◆ bicgstab_device_free()

subroutine bicgstab_device::bicgstab_device_free ( class(bicgstab_device_t), intent(inout this)
private

Definition at line 557 of file bicgstab_device.F90.

◆ bicgstab_device_init()

subroutine bicgstab_device::bicgstab_device_init ( class(bicgstab_device_t), intent(inout), target  this,
integer, intent(in n,
integer, intent(in max_iter,
class(pc_t), intent(in), optional, target  m,
real(kind=rp), intent(in), optional  rel_tol,
real(kind=rp), intent(in), optional  abs_tol,
logical, intent(in), optional  monitor 
)
private
Parameters
nNumber of degrees of freedom.
max_iterMaximum number of iterations.
MOptional preconditioner. An identity preconditioner is used if absent.
rel_tolOptional relative convergence tolerance.
abs_tolOptional absolute convergence tolerance.
monitorOptional switch for logging the residual at each iteration.

Definition at line 502 of file bicgstab_device.F90.

◆ bicgstab_device_solve()

type(ksp_monitor_t) function bicgstab_device::bicgstab_device_solve ( class(bicgstab_device_t), intent(inout this,
class(ax_t), intent(in ax,
type(field_t), intent(inout x,
real(kind=rp), dimension(n), intent(in f,
integer, intent(in n,
type(coef_t), intent(inout coef,
class(scalar_bc_projector_t), intent(inout bc_projector,
type(gs_t), intent(inout gs_h,
integer, intent(in), optional  niter 
)
private

The initial guess in x is discarded and the iteration starts from zero.

Parameters
AxLinear operator.
xSolution field.
fRight-hand side.
nNumber of degrees of freedom.
coefSpectral element coefficients and multiplicity weights.
bc_projectorProjector for dirichlet boundary nodes.
gs_hGather-scatter handle used to assemble the operator result.
niterOptional maximum number of iterations, overriding the configured value.
Returns
Convergence information for the solve.

Definition at line 632 of file bicgstab_device.F90.

Here is the call graph for this function:

◆ bicgstab_device_solve_coupled()

type(ksp_monitor_t) function, dimension(3) bicgstab_device::bicgstab_device_solve_coupled ( class(bicgstab_device_t), intent(inout this,
class(ax_t), intent(in ax,
type(field_t), intent(inout x,
type(field_t), intent(inout y,
type(field_t), intent(inout z,
real(kind=rp), dimension(n), intent(in fx,
real(kind=rp), dimension(n), intent(in fy,
real(kind=rp), dimension(n), intent(in fz,
integer, intent(in n,
type(coef_t), intent(inout coef,
class(vector_bc_projector_t), intent(inout bc_projector,
type(gs_t), intent(inout gs_h,
integer, intent(in), optional  niter 
)
private

This routine sequentially invokes the scalar solver for each component.

Parameters
AxLinear operator.
xSolution field for the first component.
ySolution field for the second component.
zSolution field for the third component.
fxRight-hand side for the first component.
fyRight-hand side for the second component.
fzRight-hand side for the third component.
nNumber of degrees of freedom per component.
coefSpectral element coefficients and multiplicity weights.
bc_projectorBoundary conditions for the three components.
gs_hGather-scatter handle used to assemble operator results.
niterOptional maximum number of iterations, overriding the configured value.
Returns
Convergence information for each component.

Definition at line 851 of file bicgstab_device.F90.

◆ bicgstab_device_sqrt()

real(kind=rp) function bicgstab_device::bicgstab_device_sqrt ( real(kind=rp), intent(in value,
character(len=*), intent(in quantity 
)
private
Parameters
valueWeighted squared norm.
quantityName of the vector for error reporting.
Returns
The non-negative square root.

Definition at line 821 of file bicgstab_device.F90.

Here is the caller graph for this function:

◆ device_bicgstab_part1()

real(kind=rp) function bicgstab_device::device_bicgstab_part1 ( type(c_ptr)  s_d,
type(c_ptr)  r_d,
type(c_ptr)  v_d,
type(c_ptr)  mult_d,
real(kind=rp)  alpha,
integer  n 
)
private
Parameters
s_dIntermediate residual, written.
r_dResidual.
v_dOperator action \(A\hat{p}\).
mult_dSpectral element multiplicity weights.
alphaBiCGStab \(\alpha\).
nNumber of vector entries.
Returns
The weighted squared norm \(s^T M s\).

Definition at line 398 of file bicgstab_device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_bicgstab_part2()

subroutine bicgstab_device::device_bicgstab_part2 ( real(kind=rp), intent(out rtr,
real(kind=rp), intent(out rho,
type(c_ptr)  x_d,
type(c_ptr)  r_d,
type(c_ptr)  p_hat_d,
type(c_ptr)  s_hat_d,
type(c_ptr)  s_d,
type(c_ptr)  t_d,
type(c_ptr)  f_d,
type(c_ptr)  mult_d,
real(kind=rp)  alpha,
real(kind=rp)  omega,
integer  n 
)
private

The rho inner product of the next iteration is reduced together with the residual norm, since both are taken against the residual this routine writes.

Parameters
rtrWeighted squared norm \(r^T M r\) of the new residual.
rhoWeighted inner product \(f^T M r\) of the new residual.
x_dSolution, updated in place.
r_dResidual, written.
p_hat_dPreconditioned search direction.
s_hat_dPreconditioned intermediate residual.
s_dIntermediate residual.
t_dOperator action \(A\hat{s}\).
f_dRight-hand side, which is also the shadow residual.
mult_dSpectral element multiplicity weights.
alphaBiCGStab \(\alpha\).
omegaBiCGStab \(\omega\).
nNumber of vector entries.

Definition at line 452 of file bicgstab_device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_bicgstab_product_and_norm()

subroutine bicgstab_device::device_bicgstab_product_and_norm ( real(kind=rp), intent(out product,
real(kind=rp), intent(out norm_squared,
type(c_ptr)  a_d,
type(c_ptr)  b_d,
type(c_ptr)  mult_d,
integer  n 
)
private

Combining the two values avoids a global synchronisation solely for the scale used by the breakdown checks.

Parameters
productWeighted inner product of a and b.
norm_squaredWeighted squared norm of b.
a_dFirst vector in the inner product.
b_dSecond vector in the inner product and vector whose norm is taken.
mult_dSpectral element multiplicity weights.
nNumber of vector entries.

Definition at line 351 of file bicgstab_device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_bicgstab_update_p()

subroutine bicgstab_device::device_bicgstab_update_p ( type(c_ptr)  p_d,
type(c_ptr)  r_d,
type(c_ptr)  v_d,
real(kind=rp)  beta,
real(kind=rp)  omega,
integer  n 
)
private
Parameters
p_dSearch direction, updated in place.
r_dResidual.
v_dOperator action \(A\hat{p}\) of the previous iteration.
betaBiCGStab \(\beta\).
omegaBiCGStab \(\omega\) of the previous iteration.
nNumber of vector entries.

Definition at line 319 of file bicgstab_device.F90.

Here is the call graph for this function:
Here is the caller graph for this function: