Skip to content

Commit

Permalink
Apply clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyscientist committed Jan 12, 2024
1 parent 681ecaa commit bd49722
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 95 deletions.
4 changes: 2 additions & 2 deletions include/eigensolve_quda.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ namespace quda
@param[in] locked The number of locked vectors in kSpace
*/
template <typename T>
void rotateVecs(std::vector<ColorSpinorField> &kSpace, const std::vector<T> &rot_array,
int offset, int dim, int keep, int locked);
void rotateVecs(std::vector<ColorSpinorField> &kSpace, const std::vector<T> &rot_array, int offset, int dim,
int keep, int locked);

/**
@brief Permute the vector space using the permutation matrix.
Expand Down
42 changes: 21 additions & 21 deletions include/invert_quda.h
Original file line number Diff line number Diff line change
Expand Up @@ -1691,27 +1691,27 @@ namespace quda {
public:
IncEigCG(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon, SolverParam &param);

virtual ~IncEigCG();
virtual ~IncEigCG();

/**
@brief Expands deflation space.
@param V Composite field container of new eigenvectors
@param n_ev number of vectors to load
*/
void increment(ColorSpinorField &V, int n_ev);

void RestartVT(const double beta, const double rho);
void UpdateVm(ColorSpinorField &res, double beta, double sqrtr2);
// EigCG solver:
int eigCGsolve(ColorSpinorField &out, ColorSpinorField &in);
// InitCG solver:
int initCGsolve(ColorSpinorField &out, ColorSpinorField &in);
// Incremental eigCG solver (for eigcg and initcg calls)
void operator()(ColorSpinorField &out, ColorSpinorField &in);
/**
@brief Expands deflation space.
@param V Composite field container of new eigenvectors
@param n_ev number of vectors to load
*/
void increment(ColorSpinorField &V, int n_ev);

void RestartVT(const double beta, const double rho);
void UpdateVm(ColorSpinorField &res, double beta, double sqrtr2);
// EigCG solver:
int eigCGsolve(ColorSpinorField &out, ColorSpinorField &in);
// InitCG solver:
int initCGsolve(ColorSpinorField &out, ColorSpinorField &in);
// Incremental eigCG solver (for eigcg and initcg calls)
void operator()(ColorSpinorField &out, ColorSpinorField &in);

virtual bool hermitian() const final { return true; } // EigCG is only for Hermitian systems
virtual bool hermitian() const final { return true; } // EigCG is only for Hermitian systems

virtual QudaInverterType getInverterType() const final { return QUDA_INC_EIGCG_INVERTER; }
virtual QudaInverterType getInverterType() const final { return QUDA_INC_EIGCG_INVERTER; }
};

//forward declaration
Expand All @@ -1737,9 +1737,9 @@ namespace quda {
bool init = false;

public:
GMResDR(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon, SolverParam &param);
GMResDR(const DiracMatrix &mat, Solver &K, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon,
SolverParam &param);
GMResDR(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon, SolverParam &param);
GMResDR(const DiracMatrix &mat, Solver &K, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon,
SolverParam &param);

virtual ~GMResDR();

Expand Down
3 changes: 1 addition & 2 deletions lib/eig_block_trlm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
namespace quda
{
// Thick Restarted Block Lanczos Method constructor
BLKTRLM::BLKTRLM(const DiracMatrix &mat, QudaEigParam *eig_param) :
TRLM(mat, eig_param)
BLKTRLM::BLKTRLM(const DiracMatrix &mat, QudaEigParam *eig_param) : TRLM(mat, eig_param)
{
getProfile().TPSTART(QUDA_PROFILE_INIT);

Expand Down
3 changes: 1 addition & 2 deletions lib/eig_iram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
namespace quda
{
// Implicitly Restarted Arnoldi Method constructor
IRAM::IRAM(const DiracMatrix &mat, QudaEigParam *eig_param) :
EigenSolver(mat, eig_param)
IRAM::IRAM(const DiracMatrix &mat, QudaEigParam *eig_param) : EigenSolver(mat, eig_param)
{
getProfile().TPSTART(QUDA_PROFILE_INIT);

Expand Down
3 changes: 1 addition & 2 deletions lib/eig_trlm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
namespace quda
{
// Thick Restarted Lanczos Method constructor
TRLM::TRLM(const DiracMatrix &mat, QudaEigParam *eig_param) :
EigenSolver(mat, eig_param)
TRLM::TRLM(const DiracMatrix &mat, QudaEigParam *eig_param) : EigenSolver(mat, eig_param)
{
getProfile().TPSTART(QUDA_PROFILE_INIT);

Expand Down
18 changes: 9 additions & 9 deletions lib/eigensolve_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ namespace quda

// Eigensolver class
//-----------------------------------------------------------------------------
EigenSolver::EigenSolver(const DiracMatrix &mat, QudaEigParam *eig_param) :
mat(mat),
eig_param(eig_param)
EigenSolver::EigenSolver(const DiracMatrix &mat, QudaEigParam *eig_param) : mat(mat), eig_param(eig_param)
{
getProfile().TPSTART(QUDA_PROFILE_INIT);

Expand Down Expand Up @@ -776,8 +774,8 @@ namespace quda
template <class T> using eigen_matrix_t = typename eigen_matrix_map<T>::type;

template <typename T>
void EigenSolver::rotateVecs(std::vector<ColorSpinorField> &kSpace, const std::vector<T> &rot_array,
int offset, int dim, int keep, int locked)
void EigenSolver::rotateVecs(std::vector<ColorSpinorField> &kSpace, const std::vector<T> &rot_array, int offset,
int dim, int keep, int locked)
{
using matrix_t = eigen_matrix_t<T>;

Expand Down Expand Up @@ -901,10 +899,12 @@ namespace quda
}
}

template void EigenSolver::rotateVecs<double>(std::vector<ColorSpinorField> &kSpace, const std::vector<double> &rot_array,
int offset, int dim, int keep, int locked);
template void EigenSolver::rotateVecs<double>(std::vector<ColorSpinorField> &kSpace,
const std::vector<double> &rot_array, int offset, int dim, int keep,
int locked);

template void EigenSolver::rotateVecs<Complex>(std::vector<ColorSpinorField> &kSpace, const std::vector<Complex> &rot_array,
int offset, int dim, int keep, int locked);
template void EigenSolver::rotateVecs<Complex>(std::vector<ColorSpinorField> &kSpace,
const std::vector<Complex> &rot_array, int offset, int dim, int keep,
int locked);

} // namespace quda
2 changes: 1 addition & 1 deletion lib/interface_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ multigrid_solver::multigrid_solver(QudaMultigridParam &mg_param)
saveTuneCache();
}

void* newMultigridQuda(QudaMultigridParam *mg_param)
void *newMultigridQuda(QudaMultigridParam *mg_param)
{
profilerStart(__func__);
auto profile = pushProfile(profileInvert, mg_param->secs, mg_param->gflops);
Expand Down
16 changes: 6 additions & 10 deletions lib/inv_bicgstab_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ namespace quda {

BiCGstab::BiCGstab(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon,
const DiracMatrix &matEig, SolverParam &param) :
Solver(mat, matSloppy, matPrecon, matEig, param),
matMdagM(matEig.Expose())
Solver(mat, matSloppy, matPrecon, matEig, param), matMdagM(matEig.Expose())
{
}

BiCGstab::~BiCGstab()
{
destroyDeflationSpace();
}
BiCGstab::~BiCGstab() { destroyDeflationSpace(); }

void BiCGstab::create(ColorSpinorField &x, const ColorSpinorField &b)
{
Expand Down Expand Up @@ -208,8 +204,8 @@ namespace quda {

bool converged = convergence(r2, heavy_quark_res, stop, param.tol_hq);

logQuda(QUDA_DEBUG_VERBOSE, "BiCGstab debug: x2=%e, r2=%e, v2=%e, p2=%e, r0=%e, t2=%e\n", blas::norm2(x), blas::norm2(r_sloppy),
blas::norm2(v), blas::norm2(p), blas::norm2(r0), blas::norm2(t));
logQuda(QUDA_DEBUG_VERBOSE, "BiCGstab debug: x2=%e, r2=%e, v2=%e, p2=%e, r0=%e, t2=%e\n", blas::norm2(x),
blas::norm2(r_sloppy), blas::norm2(v), blas::norm2(p), blas::norm2(r0), blas::norm2(t));

// track if we just performed an exact recalculation of y, r, r2
bool just_updated = false;
Expand Down Expand Up @@ -309,8 +305,8 @@ namespace quda {
k++;

PrintStats("BiCGstab", k, r2, b2, heavy_quark_res);
logQuda(QUDA_DEBUG_VERBOSE, "BiCGstab debug: x2=%e, r2=%e, v2=%e, p2=%e, r0=%e, t2=%e\n", blas::norm2(x), blas::norm2(r_sloppy),
blas::norm2(v), blas::norm2(p), blas::norm2(r0), blas::norm2(t));
logQuda(QUDA_DEBUG_VERBOSE, "BiCGstab debug: x2=%e, r2=%e, v2=%e, p2=%e, r0=%e, t2=%e\n", blas::norm2(x),
blas::norm2(r_sloppy), blas::norm2(v), blas::norm2(p), blas::norm2(r0), blas::norm2(t));

converged = convergence(r2, heavy_quark_res, stop, param.tol_hq);

Expand Down
4 changes: 1 addition & 3 deletions lib/inv_bicgstabl_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ namespace quda {

BiCGstabL::BiCGstabL(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matEig,
SolverParam &param) :
Solver(mat, matSloppy, matSloppy, matEig, param),
matMdagM(matEig.Expose()),
n_krylov(param.Nkrylov)
Solver(mat, matSloppy, matSloppy, matEig, param), matMdagM(matEig.Expose()), n_krylov(param.Nkrylov)
{
r.resize(n_krylov + 1);
u.resize(n_krylov + 1);
Expand Down
3 changes: 1 addition & 2 deletions lib/inv_cg3_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ namespace quda {
}
}

CG3NR::CG3NR(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon,
SolverParam &param) :
CG3NR::CG3NR(const DiracMatrix &mat, const DiracMatrix &matSloppy, const DiracMatrix &matPrecon, SolverParam &param) :
CG3(mdagm, mdagmSloppy, mdagmPrecon, param),
mdagm(mat.Expose()),
mdagmSloppy(matSloppy.Expose()),
Expand Down
2 changes: 1 addition & 1 deletion lib/inv_eigcg_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace quda {
else {
printfQuda("\nDeflation space is complete, running initCG solver.");
fillInitCGSolverParam(Kparam, param);
//K = new CG(mat, matPrecon, Kparam);//Preconditioned Mat has comms flag on
// K = new CG(mat, matPrecon, Kparam);//Preconditioned Mat has comms flag on
return;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/inv_gcr_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ namespace quda {
// Check to see that we're not trying to invert on a zero-field source
if (b2 == 0) {
if (param.compute_null_vector == QUDA_COMPUTE_NULL_VECTOR_NO) {
getProfile().TPSTOP(QUDA_PROFILE_INIT);
warningQuda("inverting on zero-field source\n");
getProfile().TPSTOP(QUDA_PROFILE_INIT);
warningQuda("inverting on zero-field source\n");
x = b;
param.true_res = 0.0;
param.true_res_hq = 0.0;
Expand Down
4 changes: 3 additions & 1 deletion lib/inv_multi_cg_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ namespace quda {
}

MultiShiftCG::MultiShiftCG(const DiracMatrix &mat, const DiracMatrix &matSloppy, SolverParam &param) :
MultiShiftSolver(mat, matSloppy, param), init(false) { }
MultiShiftSolver(mat, matSloppy, param), init(false)
{
}

void MultiShiftCG::create(std::vector<ColorSpinorField> &x, const ColorSpinorField &b, std::vector<ColorSpinorField> &p)
{
Expand Down
10 changes: 3 additions & 7 deletions lib/inv_sd_quda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ namespace quda {

using namespace blas;

SD::SD(const DiracMatrix &mat, SolverParam &param) :
Solver(mat, mat, mat, mat, param)
{

}
SD::SD(const DiracMatrix &mat, SolverParam &param) : Solver(mat, mat, mat, mat, param) { }

SD::~SD(){
if(!param.is_preconditioner) getProfile().TPSTART(QUDA_PROFILE_FREE);
if (!param.is_preconditioner) getProfile().TPSTART(QUDA_PROFILE_FREE);
if(init){
delete r;
delete Ar;
}
if(!param.is_preconditioner) getProfile().TPSTOP(QUDA_PROFILE_FREE);
if (!param.is_preconditioner) getProfile().TPSTOP(QUDA_PROFILE_FREE);
}


Expand Down
6 changes: 4 additions & 2 deletions lib/multigrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,15 @@ namespace quda
*matCoarseSmoother, *matCoarseSmoother);
sprintf(coarse_prefix, "MG level %d (%s): ", param.level + 1,
param.mg_global.location[param.level + 1] == QUDA_CUDA_FIELD_LOCATION ? "GPU" : "CPU");
coarse_solver = new PreconditionedSolver(*solver, *matCoarseSmoother->Expose(), *param_coarse_solver, coarse_prefix);
coarse_solver
= new PreconditionedSolver(*solver, *matCoarseSmoother->Expose(), *param_coarse_solver, coarse_prefix);
} else {
Solver *solver = Solver::create(*param_coarse_solver, *matCoarseResidual, *matCoarseResidual,
*matCoarseResidual, *matCoarseResidual);
sprintf(coarse_prefix, "MG level %d (%s): ", param.level + 1,
param.mg_global.location[param.level + 1] == QUDA_CUDA_FIELD_LOCATION ? "GPU" : "CPU");
coarse_solver = new PreconditionedSolver(*solver, *matCoarseResidual->Expose(), *param_coarse_solver, coarse_prefix);
coarse_solver
= new PreconditionedSolver(*solver, *matCoarseResidual->Expose(), *param_coarse_solver, coarse_prefix);
}

setOutputPrefix(prefix); // restore since we just popped back from coarse grid
Expand Down
44 changes: 22 additions & 22 deletions lib/quda_arpack_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,40 +382,40 @@ namespace quda

for (int i = 0; i < nconv; i++) {

getProfile().TPSTART(QUDA_PROFILE_H2D);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_H2D);
getProfile().TPSTART(QUDA_PROFILE_H2D);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_H2D);

getProfile().TPSTART(QUDA_PROFILE_COMPUTE);
// M*Rev_i = M*Rsv_i = sigma_i Lsv_i
getProfile().TPSTART(QUDA_PROFILE_COMPUTE);
// M*Rev_i = M*Rsv_i = sigma_i Lsv_i
mat.Expose()->M(d_v2, d_v);
// sigma_i = sqrt(sigma_i (Lsv_i)^dag * sigma_i * Lsv_i )
double sigma_tmp = sqrt(blas::norm2(d_v2));
// Normalise the Lsv: sigma_i Lsv_i -> Lsv_i
blas::ax(1.0 / sigma_tmp, d_v2);
getProfile().TPSTOP(QUDA_PROFILE_COMPUTE);
getProfile().TPSTOP(QUDA_PROFILE_COMPUTE);

if (getVerbosity() >= QUDA_SUMMARIZE)
if (getVerbosity() >= QUDA_SUMMARIZE)
printfQuda("Sval[%04d] = %+.16e sigma - sqrt(|lambda|) = %+.16e\n", i, sigma_tmp,
sigma_tmp - sqrt(abs(evals[i].real())));
}
} else {
printfQuda("Computing Eigenvalues\n");
for (int i = 0; i < nconv; i++) {

getProfile().TPSTART(QUDA_PROFILE_D2H);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_D2H);
getProfile().TPSTART(QUDA_PROFILE_D2H);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_D2H);

getProfile().TPSTART(QUDA_PROFILE_COMPUTE);
// d_v2 = M*v = lambda_measured * v
getProfile().TPSTART(QUDA_PROFILE_COMPUTE);
// d_v2 = M*v = lambda_measured * v
mat(d_v2, d_v);
// d_v = ||lambda_measured*v - lambda_arpack*v||
blas::caxpby(Complex {1.0, 0.0}, d_v2, -evals[i], d_v);
double L2norm = blas::norm2(d_v);
getProfile().TPSTOP(QUDA_PROFILE_COMPUTE);
getProfile().TPSTOP(QUDA_PROFILE_COMPUTE);

if (getVerbosity() >= QUDA_SUMMARIZE)
if (getVerbosity() >= QUDA_SUMMARIZE)
printfQuda("Eval[%04d] = (%+.16e %+.16e) ||%+.16e|| Residual: %.16e\n", i, evals[i].real(), evals[i].imag(),
abs(evals[i]), sqrt(L2norm));
}
Expand All @@ -425,11 +425,11 @@ namespace quda
if (eig_param->compute_svd) {
for (int i = 0; i < nconv; i++) {

getProfile().TPSTART(QUDA_PROFILE_H2D);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_H2D);
getProfile().TPSTART(QUDA_PROFILE_H2D);
d_v = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTOP(QUDA_PROFILE_H2D);

// M*Rev_i = M*Rsv_i = sigma_i Lsv_i
// M*Rev_i = M*Rsv_i = sigma_i Lsv_i
mat.Expose()->M(d_v2, d_v);

// sigma_i = sqrt(sigma_i (Lsv_i)^dag * sigma_i * Lsv_i )
Expand All @@ -439,11 +439,11 @@ namespace quda
blas::ax(1.0 / sigma_tmp, d_v2);

h_evecs[i] = h_evecs_arpack[arpack_index[i]];
getProfile().TPSTART(QUDA_PROFILE_D2H);
h_evecs[i + nconv] = d_v2;
getProfile().TPSTOP(QUDA_PROFILE_D2H);
getProfile().TPSTART(QUDA_PROFILE_D2H);
h_evecs[i + nconv] = d_v2;
getProfile().TPSTOP(QUDA_PROFILE_D2H);

h_evals[i].real(sigma_tmp);
h_evals[i].real(sigma_tmp);
h_evals[i].imag(0.0);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ namespace quda {
multigrid_solver *mg = static_cast<multigrid_solver*>(param.preconditioner);
// FIXME dirty hack to ensure that preconditioner precision set in interface isn't used in the outer GCR-MG solver
param.precision_precondition = param.precision_sloppy;
solver = new GMResDR(mat, *(mg->mg), matSloppy, matPrecon, param);
solver = new GMResDR(mat, *(mg->mg), matSloppy, matPrecon, param);
} else {
solver = new GMResDR(mat, matSloppy, matPrecon, param);
solver = new GMResDR(mat, matSloppy, matPrecon, param);
}
break;
case QUDA_CGNE_INVERTER:
Expand Down
Loading

0 comments on commit bd49722

Please sign in to comment.