QUDA  0.9.0
Public Member Functions | Private Attributes | List of all members
quda::MG Class Reference

#include <multigrid.h>

Inheritance diagram for quda::MG:
Inheritance graph
[legend]
Collaboration diagram for quda::MG:
Collaboration graph
[legend]

Public Member Functions

 MG (MGParam &param, TimeProfile &profile)
 
virtual ~MG ()
 
void createSmoother ()
 Create the smoothers. More...
 
void destroySmoother ()
 Free the smoothers. More...
 
void reset ()
 
void verify ()
 
void operator() (ColorSpinorField &out, ColorSpinorField &in)
 
void loadVectors (std::vector< ColorSpinorField *> &B)
 Load the null space vectors in from file. More...
 
void saveVectors (std::vector< ColorSpinorField *> &B)
 Save the null space vectors in from file. More...
 
void generateNullVectors (std::vector< ColorSpinorField *> B)
 Generate the null-space vectors. More...
 
double flops () const
 Return the total flops done on this and all coarser levels. More...
 
- Public Member Functions inherited from quda::Solver
 Solver (SolverParam &param, TimeProfile &profile)
 
virtual ~Solver ()
 
virtual void solve (ColorSpinorField &out, ColorSpinorField &in)
 
bool convergence (const double &r2, const double &hq2, const double &r2_tol, const double &hq_tol)
 
bool convergenceHQ (const double &r2, const double &hq2, const double &r2_tol, const double &hq_tol)
 
bool convergenceL2 (const double &r2, const double &hq2, const double &r2_tol, const double &hq_tol)
 
void PrintStats (const char *, int k, const double &r2, const double &b2, const double &hq2)
 
void PrintSummary (const char *name, int k, const double &r2, const double &b2)
 

Private Attributes

MGParamparam
 
Transfertransfer
 
Solverpresmoother
 
Solverpostsmoother
 
TimeProfileprofile_global
 
TimeProfile profile
 
char prefix [128]
 
char coarse_prefix [128]
 
MGcoarse
 
MGfine
 
Solvercoarse_solver
 
MGParamparam_coarse
 
SolverParamparam_presmooth
 
SolverParamparam_postsmooth
 
SolverParamparam_coarse_solver
 
std::vector< ColorSpinorField * > * B
 
std::vector< ColorSpinorField * > * B_coarse
 
ColorSpinorFieldr
 
ColorSpinorFieldb_tilde
 
ColorSpinorFieldr_coarse
 
ColorSpinorFieldx_coarse
 
ColorSpinorFieldtmp_coarse
 
DiracdiracCoarseResidual
 
DiracdiracCoarseSmoother
 
DiracdiracCoarseSmootherSloppy
 
DiracMatrixmatCoarseResidual
 
DiracMatrixmatCoarseSmoother
 
DiracMatrixmatCoarseSmootherSloppy
 

Additional Inherited Members

- Static Public Member Functions inherited from quda::Solver
static Solvercreate (SolverParam &param, DiracMatrix &mat, DiracMatrix &matSloppy, DiracMatrix &matPrecon, TimeProfile &profile)
 
static double stopping (const double &tol, const double &b2, QudaResidualType residual_type)
 
- Protected Attributes inherited from quda::Solver
SolverParamparam
 
TimeProfileprofile
 

Detailed Description

Adaptive Multigrid solver

Definition at line 172 of file multigrid.h.

Constructor & Destructor Documentation

◆ MG()

quda::MG::MG ( MGParam param,
TimeProfile profile 
)

Constructor for MG class

Parameters
paramMGParam struct that defines all meta data
profileTimeprofile instance used to profile

Definition at line 13 of file multigrid.cpp.

References quda::MGParam::B, B_coarse, b_tilde, coarse, quda::MGParam::coarse_grid_solution_type, QudaMultigridParam_s::coarse_grid_solution_type, coarse_prefix, coarse_solver, QudaMultigridParam_s::compute_null_vector, quda::SolverParam::compute_true_res, quda::Solver::create(), quda::ColorSpinorField::Create(), createSmoother(), csParam, quda::MGParam::cycle_type, quda::DiracParam::dagger, quda::SolverParam::delta, quda::DiracParam::dirac, diracCoarseResidual, diracCoarseSmoother, diracCoarseSmootherSloppy, e, errorQuda, quda::ColorSpinorField::Even(), quda::DiracMatrix::Expose(), quda::MGParam::fine, QudaMultigridParam_s::generate_all_levels, generateNullVectors(), QudaMultigridParam_s::geo_block_size, quda::MGParam::geoBlockSize, getVerbosity(), quda::SolverParam::global_reduction, fused_exterior_ndeg_tm_dslash_cuda_gen::i, quda::SolverParam::inv_type, quda::SolverParam::inv_type_precondition, QudaMultigridParam_s::invert_param, quda::SolverParam::is_preconditioner, quda::DiracParam::kappa, quda::Dirac::Kappa(), quda::MGParam::level, loadVectors(), quda::MGParam::location, QudaMultigridParam_s::location, matCoarseResidual, matCoarseSmoother, matCoarseSmootherSloppy, matpc_type, QudaInvertParam_s::matpc_type, quda::DiracParam::matpcType, quda::MGParam::matResidual, quda::MGParam::matSmooth, quda::SolverParam::maxiter, quda::MGParam::mg_global, quda::DiracParam::mu, quda::Dirac::Mu(), quda::DiracParam::mu_factor, QudaMultigridParam_s::mu_factor, QudaMultigridParam_s::n_vec, quda::SolverParam::Nkrylov, quda::MGParam::Nlevel, quda::MGParam::Nvec, param, param_coarse, param_coarse_solver, quda::SolverParam::pipeline, quda::SolverParam::precision_precondition, quda::SolverParam::precision_sloppy, quda::SolverParam::preconditioner, prefix, quda::SolverParam::preserve_source, quda::TimeProfile::Print(), printfQuda, profile, profile_global, QUDA_BOOLEAN_NO, QUDA_BOOLEAN_YES, QUDA_COARSE_DIRAC, QUDA_COARSEPC_DIRAC, QUDA_COMPUTE_NULL_VECTOR_YES, QUDA_CUDA_FIELD_LOCATION, QUDA_DAG_NO, QUDA_DEGRAND_ROSSI_GAMMA_BASIS, QUDA_DIRECT_PC_SOLVE, QUDA_DOUBLE_PRECISION, QUDA_FLOAT2_FIELD_ORDER, QUDA_FLOAT4_FIELD_ORDER, QUDA_GCR_INVERTER, QUDA_MATPC_SOLUTION, QUDA_MAX_MG_LEVEL, QUDA_MG_CYCLE_RECURSIVE, QUDA_MG_CYCLE_VCYCLE, QUDA_MG_INVERTER, QUDA_NULL_FIELD_CREATE, QUDA_PARITY_SITE_SUBSET, QUDA_PRESERVE_SOURCE_YES, QUDA_SUMMARIZE, QUDA_UKQCD_GAMMA_BASIS, QUDA_USE_INIT_GUESS_NO, quda::Transfer::R(), r, r_coarse, reset(), QudaMultigridParam_s::run_verify, setOutputPrefix(), quda::MGParam::smoother_solve_type, QudaMultigridParam_s::smoother_solve_type, QudaMultigridParam_s::smoother_tol, quda::MGParam::spinBlockSize, sprintf(), strcmp(), quda::DiracParam::tmp1, tmp_coarse, quda::SolverParam::tol, quda::DiracParam::transfer, transfer, quda::DiracParam::type, quda::SolverParam::use_init_guess, QudaMultigridParam_s::vec_infile, QudaMultigridParam_s::verbosity, quda::SolverParam::verbosity_precondition, verify(), x_coarse, and quda::zero().

Here is the call graph for this function:

◆ ~MG()

quda::MG::~MG ( )
virtual

Member Function Documentation

◆ createSmoother()

void quda::MG::createSmoother ( )

◆ destroySmoother()

void quda::MG::destroySmoother ( )

Free the smoothers.

Definition at line 254 of file multigrid.cpp.

References quda::MGParam::level, quda::MGParam::Nlevel, param, param_postsmooth, param_presmooth, postsmoother, and presmoother.

Referenced by updateMultigridQuda(), and ~MG().

Here is the caller graph for this function:

◆ flops()

double quda::MG::flops ( ) const
virtual

Return the total flops done on this and all coarser levels.

Reimplemented from quda::Solver.

Definition at line 303 of file multigrid.cpp.

References coarse, quda::Transfer::flops(), flops(), quda::SolverParam::gflops, quda::MGParam::level, quda::MGParam::Nlevel, param, param_postsmooth, param_presmooth, and transfer.

Referenced by flops().

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

◆ generateNullVectors()

void quda::MG::generateNullVectors ( std::vector< ColorSpinorField *>  B)

Generate the null-space vectors.

Parameters
BGenerated null-space vectors

Definition at line 744 of file multigrid.cpp.

References quda::ax(), b, B, quda::blas::caxpy(), quda::blas::cDotProduct(), quda::SolverParam::compute_null_vector, quda::Solver::create(), quda::ColorSpinorField::Create(), csParam, QudaInvertParam_s::cuda_prec_precondition, quda::SolverParam::delta, dirac, e, errorQuda, quda::DiracMatrix::Expose(), getVerbosity(), fused_exterior_ndeg_tm_dslash_cuda_gen::i, in, int, quda::SolverParam::inv_type, quda::SolverParam::inv_type_precondition, QudaMultigridParam_s::invert_param, quda::MGParam::level, quda::MGParam::matSmooth, quda::MGParam::matSmoothSloppy, quda::SolverParam::maxiter, quda::SolverParam::maxiter_precondition, quda::MGParam::mg_global, quda::SolverParam::Nkrylov, quda::norm2(), QudaMultigridParam_s::nu_post, QudaMultigridParam_s::nu_pre, out, param, quda::SolverParam::pipeline, quda::SolverParam::precision_precondition, quda::SolverParam::precision_sloppy, quda::SolverParam::precondition_cycle, printfQuda, profile, QUDA_BICGSTABL_INVERTER, QUDA_CG_INVERTER, QUDA_COMPUTE_NULL_VECTOR_YES, QUDA_CUDA_FIELD_LOCATION, QUDA_DOUBLE_PRECISION, QUDA_FLOAT2_FIELD_ORDER, QUDA_GCR_INVERTER, QUDA_HALF_PRECISION, QUDA_L2_RELATIVE_RESIDUAL, QUDA_MAT_SOLUTION, QUDA_NULL_FIELD_CREATE, QUDA_RANDOM_SOURCE, QUDA_UKQCD_GAMMA_BASIS, QUDA_USE_INIT_GUESS_YES, QUDA_VERBOSE, QUDA_ZERO_FIELD_CREATE, quda::SolverParam::residual_type, saveVectors(), QudaMultigridParam_s::setup_inv_type, QudaMultigridParam_s::setup_tol, QudaMultigridParam_s::smoother, QudaMultigridParam_s::smoother_tol, quda::Solver::solve(), quda::sqrt(), strcmp(), quda::SolverParam::tol, quda::SolverParam::tol_precondition, quda::SolverParam::use_init_guess, QudaMultigridParam_s::vec_outfile, x, and quda::zero().

Referenced by MG().

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

◆ loadVectors()

void quda::MG::loadVectors ( std::vector< ColorSpinorField *> &  B)

Load the null space vectors in from file.

Parameters
BLoaded null-space vectors (pre-allocated)

Definition at line 648 of file multigrid.cpp.

References B, c, quda::ColorSpinorField::Create(), csParam, errorQuda, fused_exterior_ndeg_tm_dslash_cuda_gen::i, quda::MGParam::level, quda::MGParam::mg_global, param, printfQuda, profile_global, QUDA_CONSTANT_SOURCE, quda::QUDA_PROFILE_INIT, quda::QUDA_PROFILE_IO, QUDA_RANDOM_SOURCE, QUDA_ZERO_FIELD_CREATE, read_spinor_field(), s, strcmp(), tmp, V, vec_infile, QudaMultigridParam_s::vec_infile, quda::blas::xpy(), and quda::zero().

Referenced by MG().

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

◆ operator()()

void quda::MG::operator() ( ColorSpinorField out,
ColorSpinorField in 
)
virtual

◆ reset()

void quda::MG::reset ( )

This method is a placeholder for reseting the solver, e.g., when a parameter has changed such as the mass. For now, all it does is call Transfer::setSiteSubset to resize the on-GPU null-space components to single-parity if we're doing a single-parity solve (memory saving technique).

Definition at line 203 of file multigrid.cpp.

References coarse, quda::MGParam::coarse_grid_solution_type, QudaMultigridParam_s::invert_param, quda::MGParam::level, matpc_type, QudaInvertParam_s::matpc_type, quda::MGParam::mg_global, quda::MGParam::Nlevel, param, parity, QUDA_EVEN_PARITY, QUDA_FULL_SITE_SUBSET, QUDA_MATPC_EVEN_EVEN, QUDA_MATPC_EVEN_EVEN_ASYMMETRIC, QUDA_MATPC_SOLUTION, QUDA_ODD_PARITY, QUDA_PARITY_SITE_SUBSET, reset(), quda::Transfer::setSiteSubset(), and transfer.

Referenced by MG(), and reset().

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

◆ saveVectors()

void quda::MG::saveVectors ( std::vector< ColorSpinorField *> &  B)

Save the null space vectors in from file.

Parameters
BSave null-space vectors from here

Definition at line 708 of file multigrid.cpp.

References B, errorQuda, host_free, fused_exterior_ndeg_tm_dslash_cuda_gen::i, quda::MGParam::level, quda::MGParam::mg_global, param, printfQuda, profile_global, quda::QUDA_PROFILE_INIT, quda::QUDA_PROFILE_IO, safe_malloc, strcmp(), V, vec_outfile, QudaMultigridParam_s::vec_outfile, and write_spinor_field().

Referenced by generateNullVectors().

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

◆ verify()

void quda::MG::verify ( )

This method verifies the correctness of the MG method. It checks:

  1. Null-space vectors are exactly preserved: v_k = P R v_k
  2. Any coarse vector is exactly preserved on the fine grid: eta_c = R P eta_c
  3. The emulated coarse Dirac operator matches the native one: D_c = R D P

Verification that the constructed multigrid operator is valid

Definition at line 327 of file multigrid.cpp.

References quda::arpackSolve(), quda::MGParam::B, quda::blas::cDotProduct(), coarse, quda::MGParam::coarse_grid_solution_type, quda::ColorSpinorParam::create, quda::ColorSpinorField::Create(), csParam, dirac, dot(), e, errorQuda, quda::DiracMatrix::Expose(), fabs(), quda::ColorSpinorParam::fieldOrder, free(), quda::MGParam::geoBlockSize, fused_exterior_ndeg_tm_dslash_cuda_gen::i, quda::Dirac::Kappa(), kappa, quda::MGParam::level, quda::ColorSpinorParam::location, QudaMultigridParam_s::location, malloc(), quda::MGParam::matResidual, quda::MGParam::matSmooth, quda::Dirac::MdagM(), quda::MGParam::mg_global, quda::Dirac::Mu(), QudaMultigridParam_s::mu_factor, quda::MGParam::Nlevel, quda::norm2(), quda::MGParam::Nvec, quda::Transfer::P(), param, param_coarse, pow(), prefix, printfQuda, QUDA_CPU_FIELD_LOCATION, QUDA_DIRECT_PC_SOLVE, QUDA_DOUBLE_PRECISION, QUDA_EVEN_PARITY, QUDA_MATPC_SOLUTION, QUDA_NULL_FIELD_CREATE, QUDA_ODD_PARITY, QUDA_PARITY_SITE_SUBSET, QUDA_RANDOM_SOURCE, QUDA_SINGLE_PRECISION, QUDA_SPACE_SPIN_COLOR_FIELD_ORDER, QUDA_ZERO_FIELD_CREATE, quda::Transfer::R(), r, r_coarse, setOutputPrefix(), quda::LatticeFieldParam::siteSubset, quda::MGParam::smoother_solve_type, quda::ColorSpinorField::Source(), quda::MGParam::spinBlockSize, sprintf(), quda::sqrt(), tmp1, tmp2, tmp_coarse, tol, transfer, quda::ColorSpinorField::TwistFlavor(), quda::Transfer::Vectors(), verify(), quda::ColorSpinorField::Volume(), warningQuda, quda::LatticeFieldParam::x, x, x_coarse, quda::blas::xmyNorm(), and quda::zero().

Referenced by MG(), and verify().

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

Member Data Documentation

◆ B

std::vector<ColorSpinorField*>* quda::MG::B
private

The fine-grid representation of the null space vectors

Definition at line 218 of file multigrid.h.

Referenced by generateNullVectors(), loadVectors(), and saveVectors().

◆ B_coarse

std::vector<ColorSpinorField*>* quda::MG::B_coarse
private

The coarse-grid representation of the null space vectors

Definition at line 221 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ b_tilde

ColorSpinorField* quda::MG::b_tilde
private

Projected source vector for preconditioned syste, else just points to source

Definition at line 227 of file multigrid.h.

Referenced by MG(), operator()(), and ~MG().

◆ coarse

MG* quda::MG::coarse
private

This is the next lower level

Definition at line 197 of file multigrid.h.

Referenced by flops(), MG(), reset(), verify(), and ~MG().

◆ coarse_prefix

char quda::MG::coarse_prefix[128]
private

Prefix label used for printf on next coarse level

Definition at line 194 of file multigrid.h.

Referenced by MG().

◆ coarse_solver

Solver* quda::MG::coarse_solver
private

The coarse grid solver - this either points at "coarse" or a solver preconditioned by "coarse"

Definition at line 203 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ diracCoarseResidual

Dirac* quda::MG::diracCoarseResidual
private

The coarse operator used for computing inter-grid residuals

Definition at line 239 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ diracCoarseSmoother

Dirac* quda::MG::diracCoarseSmoother
private

The coarse operator used for doing smoothing

Definition at line 242 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ diracCoarseSmootherSloppy

Dirac* quda::MG::diracCoarseSmootherSloppy
private

The coarse operator used for doing sloppy smoothing

Definition at line 245 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ fine

MG* quda::MG::fine
private

This is the next coarser level

Definition at line 200 of file multigrid.h.

◆ matCoarseResidual

DiracMatrix* quda::MG::matCoarseResidual
private

Wrapper for the residual coarse grid operator

Definition at line 248 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ matCoarseSmoother

DiracMatrix* quda::MG::matCoarseSmoother
private

Wrapper for the smoothing coarse grid operator

Definition at line 251 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ matCoarseSmootherSloppy

DiracMatrix* quda::MG::matCoarseSmootherSloppy
private

Wrapper for the sloppy smoothing coarse grid operator

Definition at line 254 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ param

MGParam& quda::MG::param
private

Local copy of the multigrid metadata

Definition at line 176 of file multigrid.h.

Referenced by createSmoother(), destroySmoother(), flops(), generateNullVectors(), loadVectors(), MG(), operator()(), reset(), saveVectors(), verify(), and ~MG().

◆ param_coarse

MGParam* quda::MG::param_coarse
private

Storage for the parameter struct for the coarse grid

Definition at line 206 of file multigrid.h.

Referenced by MG(), verify(), and ~MG().

◆ param_coarse_solver

SolverParam* quda::MG::param_coarse_solver
private

Storage for the parameter struct for the coarse solver

Definition at line 215 of file multigrid.h.

Referenced by MG(), and ~MG().

◆ param_postsmooth

SolverParam* quda::MG::param_postsmooth
private

Storage for the parameter struct for the post-smoother

Definition at line 212 of file multigrid.h.

Referenced by createSmoother(), destroySmoother(), and flops().

◆ param_presmooth

SolverParam* quda::MG::param_presmooth
private

Storage for the parameter struct for the pre-smoother

Definition at line 209 of file multigrid.h.

Referenced by createSmoother(), destroySmoother(), and flops().

◆ postsmoother

Solver * quda::MG::postsmoother
private

Definition at line 182 of file multigrid.h.

Referenced by createSmoother(), and destroySmoother().

◆ prefix

char quda::MG::prefix[128]
private

Prefix label used for printf at this level

Definition at line 191 of file multigrid.h.

Referenced by MG(), operator()(), and verify().

◆ presmoother

Solver* quda::MG::presmoother
private

This is the smoother used

Definition at line 182 of file multigrid.h.

Referenced by createSmoother(), and destroySmoother().

◆ profile

TimeProfile quda::MG::profile
private

TimeProfile for this level

Definition at line 188 of file multigrid.h.

Referenced by createSmoother(), generateNullVectors(), MG(), and ~MG().

◆ profile_global

TimeProfile& quda::MG::profile_global
private

TimeProfile for all levels (refers to profile from parent solver)

Definition at line 185 of file multigrid.h.

Referenced by loadVectors(), MG(), and saveVectors().

◆ r

ColorSpinorField* quda::MG::r
private

Residual vector

Definition at line 224 of file multigrid.h.

Referenced by MG(), operator()(), verify(), and ~MG().

◆ r_coarse

ColorSpinorField* quda::MG::r_coarse
private

Coarse residual vector

Definition at line 230 of file multigrid.h.

Referenced by MG(), operator()(), verify(), and ~MG().

◆ tmp_coarse

ColorSpinorField* quda::MG::tmp_coarse
private

Coarse temporary vector

Definition at line 236 of file multigrid.h.

Referenced by MG(), verify(), and ~MG().

◆ transfer

Transfer* quda::MG::transfer
private

This is the transfer operator that defines the prolongation and restriction operators

Definition at line 179 of file multigrid.h.

Referenced by flops(), MG(), operator()(), reset(), verify(), and ~MG().

◆ x_coarse

ColorSpinorField* quda::MG::x_coarse
private

Coarse solution vector

Definition at line 233 of file multigrid.h.

Referenced by MG(), operator()(), verify(), and ~MG().


The documentation for this class was generated from the following files: