10 matMdagM(matEig.Expose()),
26 if (alpha)
delete []alpha;
28 for (
int i=0; i<
param.
Nkrylov+1; i++)
if (i>0 || !use_source)
delete p[i];
30 for (
int i=0; i<
param.
Nkrylov; i++)
if (i>0 || !use_source)
delete p[i];
33 if (tmp_sloppy)
delete tmp_sloppy;
34 if (tmpp)
delete tmpp;
66 warningQuda(
"CA-GCR does not support any basis besides QUDA_POWER_BASIS. Switching to QUDA_POWER_BASIS...\n");
76 if (i>0) q[i-1] = p[i];
96 void CAGCR::solve(
Complex *psi_, std::vector<ColorSpinorField*> &q, ColorSpinorField &b)
101 const int N = q.size();
102 vector phi(N), psi(N);
108 std::vector<ColorSpinorField*> Q;
109 for (
int i=0; i<N; i++) Q.push_back(q[i]);
115 for (
int i=0; i<N; i++) {
116 phi(i) = A_[i*(N+1)+N];
117 for (
int j=0; j<N; j++) {
118 A(i,j) = A_[i*(N+1)+j];
125 std::vector<ColorSpinorField*> B;
129 for (
int i=0; i<N; i++) phi(i) = phi_[i];
135 for (
int i=0; i<N; i++)
136 for (
int j=0; j<N; j++)
148 LDLT<matrix> cholesky(A);
149 psi = cholesky.solve(phi);
151 for (
int i=0; i<N; i++) psi_[i] = psi(i);
190 double b2 = !fixed_iteration ?
blas::norm2(b) : 1.0;
226 if (!fixed_iteration) {
244 if (!fixed_iteration) {
275 double heavy_quark_res = 0.0;
279 int resIncreaseTotal = 0;
289 double maxr_deflate =
sqrt(r2);
290 bool l2_converge =
false;
294 PrintStats(
"CA-GCR", total_iter, r2, b2, heavy_quark_res);
298 for (
int k = 0; k < n_krylov; k++) {
303 solve(alpha, q, *p[0]);
306 std::vector<ColorSpinorField*> X;
309 std::vector<ColorSpinorField*> P;
310 for (
int i = 0; i < n_krylov; i++) P.push_back(p[i]);
317 std::vector<ColorSpinorField*> R;
319 for (
int i = 0; i < n_krylov; i++) alpha[i] = -alpha[i];
323 total_iter += n_krylov;
329 PrintStats(
"CA-GCR", total_iter, r2, b2, heavy_quark_res);
347 maxr_deflate =
sqrt(r2);
356 warningQuda(
"CA-GCR: new reliable residual norm %e is greater than previous reliable residual norm %e (total #inc %i)",
357 sqrt(r2),
sqrt(r2_old), resIncreaseTotal);
358 if (resIncrease > maxResIncrease or resIncreaseTotal > maxResIncreaseTotal) {
359 warningQuda(
"CA-GCR: solver exiting due to too many true residual norm increases");
373 PrintStats(
"CA-GCR (restart)", restart, r2, b2, heavy_quark_res);
379 if (r2 <
stop) l2_converge =
true;
CAGCR(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon, const DiracMatrix &matEig, SolverParam ¶m, TimeProfile &profile)
void operator()(ColorSpinorField &out, ColorSpinorField &in)
ColorSpinorField * CreateAlias(const ColorSpinorParam ¶m)
Create a field that aliases this field's storage. The alias field can use a different precision than ...
static ColorSpinorField * Create(const ColorSpinorParam ¶m)
unsigned long long flops() const
void deflateSVD(std::vector< ColorSpinorField * > &sol, const std::vector< ColorSpinorField * > &vec, const std::vector< ColorSpinorField * > &evecs, const std::vector< Complex > &evals, bool accumulate=false) const
Deflate a set of source vectors with a set of left and right singular vectors.
void computeEvals(const DiracMatrix &mat, std::vector< ColorSpinorField * > &evecs, std::vector< Complex > &evals, int size)
Compute eigenvalues and their residiua.
void computeSVD(const DiracMatrix &mat, std::vector< ColorSpinorField * > &evecs, std::vector< Complex > &evals)
Computes Left/Right SVD from pre computed Right/Left.
bool convergence(double r2, double hq2, double r2_tol, double hq_tol)
std::vector< ColorSpinorField * > evecs
void destroyDeflationSpace()
Destroy the allocated deflation space.
void PrintSummary(const char *name, int k, double r2, double b2, double r2_tol, double hq_tol)
Prints out the summary of the solver convergence (requires a verbosity of QUDA_SUMMARIZE)....
static double stopping(double tol, double b2, QudaResidualType residual_type)
Set the solver L2 stopping condition.
void extendSVDDeflationSpace()
Extends the deflation space to twice its size for SVD deflation.
std::vector< Complex > evals
void PrintStats(const char *name, int k, double r2, double b2, double hq2)
Prints out the running statistics of the solver (requires a verbosity of QUDA_VERBOSE)
void constructDeflationSpace(const ColorSpinorField &meta, const DiracMatrix &mat)
Constructs the deflation space and eigensolver.
const DiracMatrix & matPrecon
const DiracMatrix & matSloppy
double Last(QudaProfileType idx)
void mat(void *out, void **link, void *in, int dagger_bit, int mu, QudaPrecision sPrecision, QudaPrecision gPrecision)
cudaColorSpinorField * tmp
@ QUDA_USE_INIT_GUESS_YES
@ QUDA_HEAVY_QUARK_RESIDUAL
@ QUDA_EIG_BLK_TR_LANCZOS
@ QUDA_PRESERVE_SOURCE_NO
@ QUDA_PRESERVE_SOURCE_YES
@ QUDA_COMPUTE_NULL_VECTOR_NO
#define checkPrecision(...)
void init()
Create the BLAS context.
double3 HeavyQuarkResidualNorm(ColorSpinorField &x, ColorSpinorField &r)
double xmyNorm(ColorSpinorField &x, ColorSpinorField &y)
void xpay(ColorSpinorField &x, double a, ColorSpinorField &y)
void hDotProduct(Complex *result, std::vector< ColorSpinorField * > &a, std::vector< ColorSpinorField * > &b)
Computes the matrix of inner products between the vector set a and the vector set b....
void zero(ColorSpinorField &a)
double norm2(const ColorSpinorField &a)
void caxpy(const Complex &a, ColorSpinorField &x, ColorSpinorField &y)
void copy(ColorSpinorField &dst, const ColorSpinorField &src)
Complex cDotProduct(ColorSpinorField &, ColorSpinorField &)
void stop()
Stop profiling.
std::complex< double > Complex
__host__ __device__ ValueType sqrt(ValueType x)
#define qudaDeviceSynchronize()
QudaPreserveSource preserve_source
QudaComputeNullVector compute_null_vector
bool is_preconditioner
verbosity to use for preconditioner
int max_res_increase_total
QudaResidualType residual_type
QudaPrecision precision_sloppy
QudaUseInitGuess use_init_guess
QudaVerbosity getVerbosity()