QUDA  v1.1.0
A library for QCD on GPUs
command_line_params.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <externals/CLI11.hpp>
5 #include <quda.h>
6 
7 // for compatibility while porting - remove later
8 extern void usage(char **);
9 
10 namespace quda
11 {
12  template <typename T> using mgarray = std::array<T, QUDA_MAX_MG_LEVEL>;
13 }
14 
15 class QUDAApp : public CLI::App
16 {
17 
18 public:
19  QUDAApp(std::string app_description = "", std::string app_name = "") : CLI::App(app_description, app_name) {};
20 
21  virtual ~QUDAApp() {};
22 
23  template <typename T>
24  CLI::Option *add_mgoption(std::string option_name, std::array<T, QUDA_MAX_MG_LEVEL> &variable, CLI::Validator trans,
25  std::string option_description = "", bool defaulted = false)
26  {
27 
28  CLI::callback_t f = [&variable, &option_name, trans](CLI::results_t vals) {
29  size_t l;
30  T j; // results_t is just a vector of strings
31  bool worked = true;
32 
33  CLI::Range validlevel(0, QUDA_MAX_MG_LEVEL);
34  for (size_t i {0}; i < vals.size() / 2; ++i) { // will always be a multiple of 2
35  auto levelok = validlevel(vals.at(2 * i));
36  auto transformok = trans(vals.at(2 * i + 1));
37  if (!levelok.empty()) throw CLI::ValidationError(option_name, levelok);
38  if (!transformok.empty()) throw CLI::ValidationError(option_name, transformok);
39  worked = worked and CLI::detail::lexical_cast(vals.at(2 * i), l);
40  worked = worked and CLI::detail::lexical_cast(vals.at(2 * i + 1), j);
41 
42  if (worked) variable[l] = j;
43  }
44  return worked;
45  };
46  CLI::Option *opt = add_option(option_name, f, option_description);
47  auto valuename = std::string("LEVEL ") + std::string(CLI::detail::type_name<T>());
48  opt->type_name(valuename)->type_size(-2);
49  opt->expected(-1);
50  opt->check(CLI::Validator(trans.get_description()));
51  // opt->transform(trans);
52  // opt->default_str("");
53 
54  return opt;
55  }
56 
57  template <typename T>
58  CLI::Option *add_mgoption(CLI::Option_group *group, std::string option_name, std::array<T, QUDA_MAX_MG_LEVEL> &variable,
59  CLI::Validator trans, std::string option_description = "", bool defaulted = false)
60  {
61 
62  CLI::callback_t f = [&variable, &option_name, trans](CLI::results_t vals) {
63  size_t l;
64  // T j; // results_t is just a vector of strings
65  bool worked = true;
66 
67  CLI::Range validlevel(0, QUDA_MAX_MG_LEVEL);
68  for (size_t i {0}; i < vals.size() / 2; ++i) { // will always be a multiple of 2
69  auto levelok = validlevel(vals.at(2 * i));
70  auto transformok = trans(vals.at(2 * i + 1));
71  if (!levelok.empty()) throw CLI::ValidationError(option_name, levelok);
72  if (!transformok.empty()) throw CLI::ValidationError(option_name, transformok);
73  worked = worked and CLI::detail::lexical_cast(vals.at(2 * i), l);
74  auto &j = variable[l];
75  worked = worked and CLI::detail::lexical_cast(vals.at(2 * i + 1), j);
76 
77  // if (worked) variable[l] = j;
78  }
79  return worked;
80  };
81  CLI::Option *opt = add_option(option_name, f, option_description);
82  auto valuename = std::string("LEVEL ") + std::string(CLI::detail::type_name<T>());
83  opt->type_name(valuename)->type_size(-2);
84  opt->expected(-1);
85  opt->check(CLI::Validator(trans.get_description()));
86  // opt->transform(trans);
87  // opt->default_str("");
88  group->add_option(opt);
89  return opt;
90  }
91 
92  template <typename T>
93  CLI::Option *add_mgoption(CLI::Option_group *group, std::string option_name,
94  std::array<std::array<T, 4>, QUDA_MAX_MG_LEVEL> &variable, CLI::Validator trans,
95  std::string option_description = "", bool defaulted = false)
96  {
97 
98  CLI::callback_t f = [&variable, &option_name, trans](CLI::results_t vals) {
99  size_t l;
100  T j; // results_t is just a vector of strings
101  bool worked = true;
102 
103  CLI::Range validlevel(0, QUDA_MAX_MG_LEVEL);
104  for (size_t i {0}; i < vals.size() / (4 + 1); ++i) {
105  auto levelok = validlevel(vals.at((4 + 1) * i));
106 
107  if (!levelok.empty()) throw CLI::ValidationError(option_name, levelok);
108  worked = worked and CLI::detail::lexical_cast(vals.at((4 + 1) * i), l);
109 
110  for (int k = 0; k < 4; k++) {
111  auto transformok = trans(vals.at((4 + 1) * i + k + 1));
112  if (!transformok.empty()) throw CLI::ValidationError(option_name, transformok);
113  worked = worked and CLI::detail::lexical_cast(vals.at((4 + 1) * i + k + 1), j);
114  if (worked) variable[l][k] = j;
115  }
116  }
117  return worked;
118  };
119  CLI::Option *opt = add_option(option_name, f, option_description);
120  auto valuename = std::string("LEVEL ") + std::string(CLI::detail::type_name<T>());
121  opt->type_name(valuename)->type_size(-4 - 1);
122  opt->expected(-1);
123  opt->check(CLI::Validator(trans.get_description()));
124  // opt->transform(trans);
125  // opt->default_str("");
126  group->add_option(opt);
127  return opt;
128  }
129 };
130 
131 std::shared_ptr<QUDAApp> make_app(std::string app_description = "QUDA internal test", std::string app_name = "");
132 void add_eigen_option_group(std::shared_ptr<QUDAApp> quda_app);
133 void add_deflation_option_group(std::shared_ptr<QUDAApp> quda_app);
134 void add_multigrid_option_group(std::shared_ptr<QUDAApp> quda_app);
135 void add_eofa_option_group(std::shared_ptr<QUDAApp> quda_app);
136 void add_su3_option_group(std::shared_ptr<QUDAApp> quda_app);
137 void add_comms_option_group(std::shared_ptr<QUDAApp> quda_app);
138 
139 template <typename T> std::string inline get_string(CLI::TransformPairs<T> &map, T val)
140 {
141  auto it
142  = std::find_if(map.begin(), map.end(), [&val](const decltype(map.back()) &p) -> bool { return p.second == val; });
143  return it->first;
144 }
145 
146 // template<typename T>
147 // const char* inline get_cstring(CLI::TransformPairs<T> &map, T val){
148 // return get_string(map,val).c_str();
149 // }
150 // parameters
151 
152 extern int device_ordinal;
153 extern int rank_order;
154 extern bool native_blas_lapack;
155 extern std::array<int, 4> gridsize_from_cmdline;
156 extern std::array<int, 4> dim_partitioned;
161 extern QudaPrecision prec;
166 extern QudaPrecision prec_null;
167 extern QudaPrecision prec_ritz;
168 extern QudaVerbosity verbosity;
169 extern std::array<int, 4> dim;
170 extern int &xdim;
171 extern int &ydim;
172 extern int &zdim;
173 extern int &tdim;
174 extern int Lsdim;
175 extern bool dagger;
177 extern int laplace3D;
178 extern char latfile[256];
179 extern bool unit_gauge;
180 extern double gaussian_sigma;
181 extern char gauge_outfile[256];
182 extern int Nsrc;
183 extern int Msrc;
184 extern int niter;
185 extern int maxiter_precondition;
186 extern int gcrNkrylov;
187 extern QudaCABasis ca_basis;
188 extern double ca_lambda_min;
189 extern double ca_lambda_max;
190 extern int pipeline;
192 extern int test_type;
193 extern quda::mgarray<int> nvec;
197 extern bool inv_deflate;
198 extern bool inv_multigrid;
201 extern int precon_schwarz_cycle;
202 extern int multishift;
203 extern bool verify_results;
204 extern bool low_mode_check;
205 extern bool oblique_proj_check;
206 extern double mass;
207 extern double kappa;
208 extern double mu;
209 extern double epsilon;
210 extern double m5;
211 extern double b5;
212 extern double c5;
213 extern double anisotropy;
214 extern double tadpole_factor;
215 extern double eps_naik;
216 extern int n_naiks;
217 extern double clover_csw;
218 extern double clover_coeff;
219 extern bool compute_clover;
220 extern bool compute_fatlong;
221 extern double tol;
222 extern double tol_precondition;
223 extern double tol_hq;
224 extern double reliable_delta;
225 extern bool alternative_reliable;
232 
233 extern int mg_levels;
234 
252 extern bool pre_orthonormalize;
253 extern bool post_orthonormalize;
254 extern double omega;
265 extern bool generate_nullspace;
266 extern bool generate_all_levels;
269 extern bool mg_evolve_thin_updates;
271 
273 extern bool mg_use_mma;
274 
275 extern int n_ev;
276 extern int max_search_dim;
277 extern int deflation_grid;
278 extern double tol_restart;
279 
280 extern int eigcg_max_restarts;
281 extern int max_restart_num;
282 extern double inc_tol;
283 extern double eigenval_tol;
284 
289 
290 // Parameters for the stand alone eigensolver
291 extern int eig_block_size;
292 extern int eig_n_ev;
293 extern int eig_n_kr;
294 extern int eig_n_conv; // If unchanged, will be set to n_ev
295 extern int eig_n_ev_deflate; // If unchanged, will be set to n_conv
296 extern int eig_batched_rotate; // If unchanged, will be set to maximum
297 extern bool eig_require_convergence;
298 extern int eig_check_interval;
299 extern int eig_max_restarts;
300 extern double eig_tol;
301 extern double eig_qr_tol;
302 extern bool eig_use_eigen_qr;
303 extern bool eig_use_poly_acc;
304 extern int eig_poly_deg;
305 extern double eig_amin;
306 extern double eig_amax;
307 extern bool eig_use_normop;
308 extern bool eig_use_dagger;
309 extern bool eig_compute_svd;
310 extern bool eig_compute_gamma5;
312 extern QudaEigType eig_type;
313 extern bool eig_arpack_check;
314 extern char eig_arpack_logfile[256];
315 extern char eig_QUDA_logfile[256];
316 extern char eig_vec_infile[256];
317 extern char eig_vec_outfile[256];
318 extern bool eig_io_parity_inflate;
320 
321 // Parameters for the MG eigensolver.
322 // The coarsest grid params are for deflation,
323 // all others are for PR vectors.
345 
346 extern bool mg_eig_coarse_guess;
347 extern bool mg_eig_preserve_deflation;
348 
349 extern double heatbath_beta_value;
350 extern int heatbath_warmup_steps;
351 extern int heatbath_num_steps;
354 extern bool heatbath_coldstart;
355 
356 extern int eofa_pm;
357 extern double eofa_shift;
358 extern double eofa_mq1;
359 extern double eofa_mq2;
360 extern double eofa_mq3;
361 
362 extern double stout_smear_rho;
363 extern double stout_smear_epsilon;
364 extern double ape_smear_rho;
365 extern int smear_steps;
366 extern double wflow_epsilon;
367 extern int wflow_steps;
369 extern int measurement_interval;
370 
372 
373 extern std::array<int, 4> grid_partition;
378 
379 extern std::array<int, 3> blas_mnk;
380 extern std::array<int, 3> blas_leading_dims;
381 extern std::array<int, 3> blas_offsets;
382 extern std::array<int, 3> blas_strides;
383 extern std::array<double, 2> blas_alpha_re_im;
384 extern std::array<double, 2> blas_beta_re_im;
385 extern int blas_batch;
QUDAApp(std::string app_description="", std::string app_name="")
CLI::Option * add_mgoption(std::string option_name, std::array< T, QUDA_MAX_MG_LEVEL > &variable, CLI::Validator trans, std::string option_description="", bool defaulted=false)
CLI::Option * add_mgoption(CLI::Option_group *group, std::string option_name, std::array< T, QUDA_MAX_MG_LEVEL > &variable, CLI::Validator trans, std::string option_description="", bool defaulted=false)
CLI::Option * add_mgoption(CLI::Option_group *group, std::string option_name, std::array< std::array< T, 4 >, QUDA_MAX_MG_LEVEL > &variable, CLI::Validator trans, std::string option_description="", bool defaulted=false)
virtual ~QUDAApp()
bool inv_multigrid
int heatbath_num_steps
bool mg_use_mma
QudaTransferType staggered_transfer_type
bool generate_all_levels
QudaWFlowType wflow_type
double kappa
int eig_check_interval
double stout_smear_epsilon
int eig_batched_rotate
QudaInverterType precon_type
double reliable_delta
QudaSolveType solve_type
QudaPrecision prec_refinement_sloppy
int laplace3D
quda::mgarray< int > num_setup_iter
int eig_poly_deg
bool eig_io_parity_inflate
double inc_tol
double c5
QudaEigType eig_type
quda::mgarray< int > mg_eig_poly_deg
QudaInverterType inv_type
quda::mgarray< QudaEigType > mg_eig_type
QudaReconstructType link_recon_sloppy
int eig_n_ev
bool mg_eig_preserve_deflation
double clover_csw
quda::mgarray< int > mg_eig_check_interval
quda::mgarray< char[256]> mg_vec_outfile
double eigenval_tol
double tadpole_factor
char eig_vec_infile[256]
bool heatbath_coldstart
bool eig_arpack_check
double eig_tol
double eofa_mq1
quda::mgarray< double > setup_ca_lambda_max
double mass
int precon_schwarz_cycle
QudaPrecision prec_null
double tol
QudaExtLibType solver_ext_lib
QudaReconstructType link_recon
int deflation_grid
int niter
int test_type
quda::mgarray< int > mg_eig_n_ev_deflate
quda::mgarray< bool > mg_eig
std::array< int, 4 > dim
double anisotropy
int device_ordinal
bool eig_compute_svd
int blas_batch
QudaPrecision eig_save_prec
QudaVerbosity verbosity
quda::mgarray< QudaInverterType > coarse_solver
QudaReconstructType link_recon_precondition
quda::mgarray< QudaCABasis > coarse_solver_ca_basis
quda::mgarray< int > n_block_ortho
double tol_hq
int & ydim
void add_multigrid_option_group(std::shared_ptr< QUDAApp > quda_app)
double eofa_shift
bool eig_use_poly_acc
QudaTwistFlavorType twist_flavor
std::array< int, 4 > grid_partition
int eig_n_ev_deflate
double stout_smear_rho
QudaBLASOperation blas_trans_b
QudaPrecision prec_ritz
double gaussian_sigma
quda::mgarray< int > coarse_solver_maxiter
double epsilon
int Msrc
bool compute_clover
bool verify_results
quda::mgarray< char[256]> mg_vec_infile
quda::mgarray< int > nu_post
quda::mgarray< int > nu_pre
char gauge_outfile[256]
quda::mgarray< int > setup_ca_basis_size
bool pre_orthonormalize
int rank_order
quda::mgarray< int > mg_eig_n_kr
quda::mgarray< int > coarse_solver_ca_basis_size
std::shared_ptr< QUDAApp > make_app(std::string app_description="QUDA internal test", std::string app_name="")
std::string get_string(CLI::TransformPairs< T > &map, T val)
char eig_vec_outfile[256]
quda::mgarray< double > mg_eig_amin
double eofa_mq2
bool post_orthonormalize
quda::mgarray< QudaVerbosity > mg_verbosity
quda::mgarray< double > setup_ca_lambda_min
double wflow_epsilon
char latfile[256]
int eig_block_size
int smear_steps
double eig_amax
quda::mgarray< int > setup_maxiter
quda::mgarray< int > nvec
std::array< double, 2 > blas_alpha_re_im
void add_eofa_option_group(std::shared_ptr< QUDAApp > quda_app)
bool eig_use_dagger
bool inv_deflate
QudaBLASDataOrder blas_data_order
quda::mgarray< QudaCABasis > setup_ca_basis
double mu
double eig_qr_tol
int max_search_dim
quda::mgarray< QudaSchwarzType > mg_schwarz_type
bool oblique_proj_check
int gcrNkrylov
int wflow_steps
QudaMemoryType mem_type_ritz
quda::mgarray< QudaEigSpectrumType > mg_eig_spectrum
quda::mgarray< int > mg_eig_max_restarts
int & zdim
double ca_lambda_min
QudaSolutionType solution_type
bool mg_eig_coarse_guess
double m5
bool eig_use_eigen_qr
double eps_naik
int heatbath_num_heatbath_per_step
int max_restart_num
int measurement_interval
QudaDslashType dslash_type
double ca_lambda_max
QudaTboundary fermion_t_boundary
bool eig_use_normop
quda::mgarray< bool > mg_eig_use_dagger
std::array< int, 3 > blas_leading_dims
quda::mgarray< double > mu_factor
QudaExtLibType deflation_ext_lib
bool generate_nullspace
quda::mgarray< double > coarse_solver_ca_lambda_max
bool alternative_reliable
int solution_accumulator_pipeline
bool low_mode_check
std::array< int, 4 > dim_partitioned
std::array< int, 3 > blas_strides
quda::mgarray< int > mg_eig_n_ev
int eig_n_kr
int mg_levels
quda::mgarray< double > mg_eig_amax
double omega
void add_eigen_option_group(std::shared_ptr< QUDAApp > quda_app)
int eig_n_conv
double ape_smear_rho
quda::mgarray< QudaInverterType > setup_inv
bool mg_evolve_thin_updates
double clover_coeff
bool native_blas_lapack
int pipeline
std::array< double, 2 > blas_beta_re_im
QudaMatPCType matpc_type
quda::mgarray< double > setup_tol
int multishift
QudaFieldLocation location_ritz
quda::mgarray< double > coarse_solver_ca_lambda_min
QudaEigSpectrumType eig_spectrum
quda::mgarray< bool > mg_eig_use_poly_acc
double tol_precondition
quda::mgarray< double > mg_eig_qr_tol
QudaPrecision prec_eigensolver
quda::mgarray< QudaSolveType > coarse_solve_type
double tol_restart
bool compute_fatlong
std::array< int, 3 > blas_offsets
int Nsrc
double b5
quda::mgarray< double > mg_eig_tol
QudaSchwarzType precon_schwarz_type
bool unit_gauge
void add_deflation_option_group(std::shared_ptr< QUDAApp > quda_app)
quda::mgarray< int > mg_eig_batched_rotate
QudaPrecision prec_precondition
quda::mgarray< bool > mg_eig_use_normop
quda::mgarray< bool > mg_eig_use_eigen_qr
QudaPrecision prec
QudaReconstructType link_recon_eigensolver
quda::mgarray< QudaPrecision > mg_eig_save_prec
char eig_arpack_logfile[256]
void usage(char **)
void add_su3_option_group(std::shared_ptr< QUDAApp > quda_app)
QudaCABasis ca_basis
int n_naiks
quda::mgarray< double > smoother_tol
QudaSetupType setup_type
QudaContractType contract_type
double heatbath_beta_value
int heatbath_num_overrelax_per_step
int Lsdim
quda::mgarray< QudaSolveType > smoother_solve_type
double eofa_mq3
bool eig_require_convergence
int eig_max_restarts
int & tdim
quda::mgarray< bool > mg_eig_require_convergence
quda::mgarray< int > mg_eig_block_size
int & xdim
quda::mgarray< double > coarse_solver_tol
char eig_QUDA_logfile[256]
bool eig_compute_gamma5
QudaPrecision smoother_halo_prec
int maxiter_precondition
int eigcg_max_restarts
std::array< int, 3 > blas_mnk
quda::mgarray< QudaInverterType > smoother_type
quda::mgarray< int > setup_maxiter_refresh
void add_comms_option_group(std::shared_ptr< QUDAApp > quda_app)
int eofa_pm
QudaBLASOperation blas_trans_a
double eig_amin
quda::mgarray< int > mg_schwarz_cycle
std::array< int, 4 > gridsize_from_cmdline
int heatbath_warmup_steps
bool dagger
QudaMassNormalization normalization
QudaBLASDataType blas_data_type
quda::mgarray< std::array< int, 4 > > geo_block_size
QudaPrecision prec_sloppy
enum QudaSolveType_s QudaSolveType
enum QudaWFlowType_s QudaWFlowType
enum QudaBLASOperation_s QudaBLASOperation
enum QudaPrecision_s QudaPrecision
enum QudaTwistFlavorType_s QudaTwistFlavorType
enum QudaTransferType_s QudaTransferType
enum QudaBLASDataOrder_s QudaBLASDataOrder
enum QudaTboundary_s QudaTboundary
enum QudaDslashType_s QudaDslashType
enum QudaSolutionType_s QudaSolutionType
enum QudaEigSpectrumType_s QudaEigSpectrumType
enum QudaInverterType_s QudaInverterType
enum QudaFieldLocation_s QudaFieldLocation
enum QudaMassNormalization_s QudaMassNormalization
enum QudaBLASDataType_s QudaBLASDataType
enum QudaExtLibType_s QudaExtLibType
enum QudaEigType_s QudaEigType
enum QudaMatPCType_s QudaMatPCType
enum QudaSetupType_s QudaSetupType
enum QudaMemoryType_s QudaMemoryType
enum QudaReconstructType_s QudaReconstructType
enum QudaCABasis_s QudaCABasis
enum QudaContractType_s QudaContractType
enum QudaSchwarzType_s QudaSchwarzType
enum QudaVerbosity_s QudaVerbosity
std::map< TuneKey, TuneParam > map
Definition: tune.cpp:34
std::array< T, QUDA_MAX_MG_LEVEL > mgarray
::std::string string
Definition: gtest-port.h:891
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
Main header file for the QUDA library.
#define QUDA_MAX_MG_LEVEL
Maximum number of multi-grid levels. This number may be increased if needed.