21 #define MAX(a, b) ((a) > (b) ? (a) : (b))
26 printfQuda(
"prec prec_sloppy multishift matpc_type recon recon_sloppy solve_type S_dimension T_dimension "
27 "Ls_dimension dslash_type normalization\n");
29 "%6s %6s %d %12s %2s %2s %10s %3d/%3d/%3d %3d %2d %14s %8s\n",
38 printfQuda(
" - level %d number of null-space vectors %d\n", i + 1,
nvec[i]);
39 printfQuda(
" - level %d number of pre-smoother applications %d\n", i + 1,
nu_pre[i]);
40 printfQuda(
" - level %d number of post-smoother applications %d\n", i + 1,
nu_post[i]);
50 printfQuda(
" - level %d number of eigenvectors requested n_conv %d\n", i + 1,
nvec[i]);
55 printfQuda(
" - level %d Operator: daggered (%s) , norm-op (%s)\n", i + 1,
61 printfQuda(
" - level %d Chebyshev polynomial maximum will be computed\n", i + 1);
81 printfQuda(
" - Operator: MdagM. Will compute SVD of M\n");
82 printfQuda(
" - ***********************************************************\n");
83 printfQuda(
" - **** Overriding any previous choices of operator type. ****\n");
84 printfQuda(
" - **** SVD demands normal operator, will use MdagM ****\n");
85 printfQuda(
" - ***********************************************************\n");
94 printfQuda(
" - Chebyshev polynomial maximum will be computed\n");
105 int main(
int argc,
char **argv)
114 CLI::TransformPairs<int> test_type_map {{
"full", 0}, {
"full_ee_prec", 1}, {
"full_oo_prec", 2}, {
"even", 3},
115 {
"odd", 4}, {
"mcg_even", 5}, {
"mcg_odd", 6}};
116 app->add_option(
"--test",
test_type,
"Test method")->transform(CLI::CheckedTransformer(test_type_map));
118 app->parse(argc, argv);
119 }
catch (
const CLI::ParseError &e) {
126 printfQuda(
"Error: Cannot use both deflation and multigrid preconditioners on top level solve.\n");
176 bool use_split_grid = num_sub_partition > 1;
191 mg_param.
eig_param[i] = &mg_eig_param[i];
203 if (use_split_grid) {
errorQuda(
"Split grid does not work with deflation yet.\n"); }
218 void* qdp_inlink[4] = {
nullptr,
nullptr,
nullptr,
nullptr};
219 void* qdp_fatlink[4] = {
nullptr,
nullptr,
nullptr,
nullptr};
220 void* qdp_longlink[4] = {
nullptr,
nullptr,
nullptr,
nullptr};
221 void *milc_fatlink =
nullptr;
222 void *milc_longlink =
nullptr;
226 for (
int dir = 0; dir < 4; dir++) {
247 printfQuda(
"Computed plaquette is %e (spatial = %e, temporal = %e)\n", plaq[0], plaq[1], plaq[2]);
252 printfQuda(
"Computed fat link plaquette is %e (spatial = %e, temporal = %e)\n", plaq[0], plaq[1], plaq[2]);
264 cpuFat = GaugeField::Create(cpuFatParam);
269 cpuLong = GaugeField::Create(cpuLongParam);
277 void *mg_preconditioner =
nullptr;
279 if (use_split_grid) {
errorQuda(
"Split grid does not work with MG yet."); }
286 std::vector<quda::ColorSpinorField *> in;
287 std::vector<quda::ColorSpinorField *> out;
292 for (
int k = 0; k <
Nsrc; k++) {
306 std::vector<double> time(
Nsrc);
307 std::vector<double> gflops(
Nsrc);
308 std::vector<int> iter(
Nsrc);
314 void **outArray = (
void **)malloc(
multishift *
sizeof(
void *));
316 std::vector<ColorSpinorField *> qudaOutArray(
multishift);
318 std::vector<quda::ColorSpinorField *> _h_b(
Nsrc,
nullptr);
319 std::vector<quda::ColorSpinorField *> _h_x(
Nsrc,
nullptr);
336 if (!use_split_grid) {
337 for (
int k = 0; k <
Nsrc; k++) {
347 std::vector<void *> _hp_x(
Nsrc);
348 std::vector<void *> _hp_b(
Nsrc);
349 for (
int k = 0; k <
Nsrc; k++) {
350 _hp_x[k] = out[k]->V();
351 _hp_b[k] = in[k]->V();
366 for (
int k = 0; k <
Nsrc; k++) {
376 if (use_split_grid) {
errorQuda(
"Multishift currently doesn't support split grid.\n"); }
386 masses[i] = 0.06 + i * i * 0.01;
393 qudaOutArray[i] = ColorSpinorField::Create(cs_param);
394 outArray[i] = qudaOutArray[i]->V();
397 for (
int k = 0; k <
Nsrc; k++) {
408 printfQuda(
"%dth solution: mass=%f, ", i, masses[i]);
414 for (
int i = 0; i <
multishift; i++)
delete qudaOutArray[i];
417 default:
errorQuda(
"Unsupported test type");
432 for (
int dir = 0; dir < 4; dir++) {
433 if (qdp_inlink[dir] !=
nullptr) {
434 free(qdp_inlink[dir]);
435 qdp_inlink[dir] =
nullptr;
437 if (qdp_fatlink[dir] !=
nullptr) {
438 free(qdp_fatlink[dir]);
439 qdp_fatlink[dir] =
nullptr;
441 if (qdp_longlink[dir] !=
nullptr) {
442 free(qdp_longlink[dir]);
443 qdp_longlink[dir] =
nullptr;
446 if (milc_fatlink !=
nullptr) { free(milc_fatlink); milc_fatlink =
nullptr; }
447 if (milc_longlink !=
nullptr) { free(milc_longlink); milc_longlink =
nullptr; }
449 if (cpuFat !=
nullptr) {
delete cpuFat; cpuFat =
nullptr; }
450 if (cpuLong !=
nullptr) {
delete cpuLong; cpuLong =
nullptr; }
452 for (
auto in_vec : in) {
delete in_vec; }
453 for (
auto out_vec : out) {
delete out_vec; }
458 if (use_split_grid) {
459 for (
auto p : _h_b) {
delete p; }
460 for (
auto p : _h_x) {
delete p; }
static ColorSpinorField * Create(const ColorSpinorParam ¶m)
const void ** Ghost() const
Class declaration to initialize and hold CURAND RNG states.
void comm_allreduce_int(int *data)
void comm_allreduce_max(double *data)
void comm_allreduce(double *data)
quda::mgarray< int > mg_eig_poly_deg
quda::mgarray< QudaEigType > mg_eig_type
QudaReconstructType link_recon_sloppy
std::shared_ptr< QUDAApp > make_app(std::string app_description, std::string app_name)
QudaReconstructType link_recon
quda::mgarray< bool > mg_eig
void add_multigrid_option_group(std::shared_ptr< QUDAApp > quda_app)
std::array< int, 4 > grid_partition
quda::mgarray< int > nu_post
quda::mgarray< int > nu_pre
quda::mgarray< int > mg_eig_n_kr
quda::mgarray< double > mg_eig_amin
quda::mgarray< int > nvec
quda::mgarray< QudaEigSpectrumType > mg_eig_spectrum
QudaDslashType dslash_type
quda::mgarray< bool > mg_eig_use_dagger
quda::mgarray< int > mg_eig_n_ev
quda::mgarray< double > mg_eig_amax
void add_eigen_option_group(std::shared_ptr< QUDAApp > quda_app)
QudaEigSpectrumType eig_spectrum
quda::mgarray< bool > mg_eig_use_poly_acc
quda::mgarray< double > mg_eig_tol
void add_deflation_option_group(std::shared_ptr< QUDAApp > quda_app)
quda::mgarray< bool > mg_eig_use_normop
bool eig_require_convergence
quda::mgarray< bool > mg_eig_require_convergence
quda::mgarray< int > mg_eig_block_size
void add_comms_option_group(std::shared_ptr< QUDAApp > quda_app)
std::array< int, 4 > gridsize_from_cmdline
QudaMassNormalization normalization
QudaPrecision prec_sloppy
cudaColorSpinorField * tmp
QudaGaugeParam gauge_param
QudaInvertParam inv_param
void verifyStaggeredInversion(quda::ColorSpinorField *tmp, quda::ColorSpinorField *ref, quda::ColorSpinorField *in, quda::ColorSpinorField *out, double mass, void *qdp_fatlink[], void *qdp_longlink[], void **ghost_fatlink, void **ghost_longlink, QudaGaugeParam &gauge_param, QudaInvertParam &inv_param, int shift)
@ QUDA_CPU_FIELD_LOCATION
@ QUDA_EIG_BLK_TR_LANCZOS
@ QUDA_GHOST_EXCHANGE_PAD
size_t host_gauge_data_type_size
int dimPartitioned(int dim)
void initComms(int argc, char **argv, std::array< int, 4 > &commDims)
void setQudaMgSolveTypes()
void performanceStats(std::vector< double > &time, std::vector< double > &gflops, std::vector< int > &iter)
void setQudaDefaultMgTestParams()
void dw_setDims(int *X, const int L5)
void setStaggeredInvertParam(QudaInvertParam &inv_param)
void constructStaggeredTestSpinorParam(quda::ColorSpinorParam *csParam, const QudaInvertParam *inv_param, const QudaGaugeParam *gauge_param)
void reorderQDPtoMILC(void *milc_out, void **qdp_in, int V, int siteSize, QudaPrecision out_precision, QudaPrecision in_precision)
void setEigParam(QudaEigParam &eig_param)
void setQudaStaggeredInvTestParams()
void setStaggeredGaugeParam(QudaGaugeParam &gauge_param)
void setStaggeredMGInvertParam(QudaInvertParam &inv_param)
void setMultigridEigParam(QudaEigParam &eig_param, int level)
void constructStaggeredHostGaugeField(void **qdp_inlink, void **qdp_longlink, void **qdp_fatlink, QudaGaugeParam &gauge_param, int argc, char **argv)
void setStaggeredMultigridParam(QudaMultigridParam &mg_param)
void loadFatLongGaugeQuda(QudaInvertParam *inv_param, QudaGaugeParam *gauge_param, void *milc_fatlinks, void *milc_longlinks)
const char * get_matpc_str(QudaMatPCType type)
const char * get_prec_str(QudaPrecision prec)
const char * get_solve_str(QudaSolveType type)
const char * get_eig_spectrum_str(QudaEigSpectrumType type)
const char * get_dslash_str(QudaDslashType type)
const char * get_eig_type_str(QudaEigType type)
const char * get_mass_normalization_str(QudaMassNormalization type)
const char * get_recon_str(QudaReconstructType recon)
void spinorNoise(ColorSpinorField &src, RNG &randstates, QudaNoiseType type)
Generate a random noise spinor. This variant allows the user to manage the RNG state.
Main header file for the QUDA library.
void * newMultigridQuda(QudaMultigridParam *param)
QudaGaugeParam newQudaGaugeParam(void)
void invertMultiShiftQuda(void **_hp_x, void *_hp_b, QudaInvertParam *param)
void initQuda(int device)
void invertMultiSrcStaggeredQuda(void **_hp_x, void **_hp_b, QudaInvertParam *param, void *milc_fatlinks, void *milc_longlinks, QudaGaugeParam *gauge_param)
Really the same with @invertMultiSrcQuda but for staggered-style fermions, by accepting pointers to f...
QudaMultigridParam newQudaMultigridParam(void)
QudaInvertParam newQudaInvertParam(void)
QudaEigParam newQudaEigParam(void)
void destroyMultigridQuda(void *mg_instance)
Free resources allocated by the multigrid solver.
void invertQuda(void *h_x, void *h_b, QudaInvertParam *param)
void computeStaggeredPlaquetteQDPOrder(void **qdp_link, double plaq[3], const QudaGaugeParam &gauge_param_in, const QudaDslashType dslash_type)
int main(int argc, char **argv)
QudaBoolean preserve_deflation
QudaReconstructType reconstruct
QudaFieldLocation location
double tol_hq_offset[QUDA_MAX_MULTI_SHIFT]
int split_grid[QUDA_MAX_DIM]
int num_src_per_sub_partition
double offset[QUDA_MAX_MULTI_SHIFT]
double tol_offset[QUDA_MAX_MULTI_SHIFT]
QudaEigParam * eig_param[QUDA_MAX_MG_LEVEL]
QudaInvertParam * invert_param
QudaGhostExchange ghostExchange
void setVerbosity(QudaVerbosity verbosity)