QUDA  v1.1.0
A library for QCD on GPUs
check_params.h
Go to the documentation of this file.
1 // check_params.h
2 
3 // This file defines functions to either initialize, check, or print
4 // the QUDA gauge and inverter parameters. It gets included in
5 // interface_quda.cpp, after either INIT_PARAM, CHECK_PARAM, or
6 // PRINT_PARAM is defined.
7 //
8 // If you're reading this file because it was mentioned in a "QUDA
9 // error" message, it probably means that you forgot to set one of the
10 // gauge or inverter parameters in your application before calling
11 // loadGaugeQuda() or invertQuda().
12 
13 #include <float.h>
14 #define INVALID_INT QUDA_INVALID_ENUM
15 #define INVALID_DOUBLE DBL_MIN
16 
17 // define macro to carry out the appropriate action for a given parameter
18 
19 #if defined INIT_PARAM
20 #define P(x, val) ret.x = val
21 #elif defined CHECK_PARAM
22 #define P(x, val) if (param->x == val) errorQuda("Parameter " #x " undefined")
23 #elif defined PRINT_PARAM
24 #define P(x, val) \
25  { if (val == INVALID_DOUBLE) printfQuda(#x " = %g\n", (double)param->x); \
26  else printfQuda(#x " = %d\n", (int)param->x); }
27 #else
28 #error INIT_PARAM, CHECK_PARAM, and PRINT_PARAM all undefined in check_params.h
29 #endif
30 
31 
32 // define the appropriate function for GaugeParam
33 
34 #if defined INIT_PARAM
36  QudaGaugeParam ret;
37 #elif defined CHECK_PARAM
38 static void checkGaugeParam(QudaGaugeParam *param) {
39 #else
41  printfQuda("QUDA Gauge Parameters:\n");
42 #endif
43 
44 #if defined CHECK_PARAM
45  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
46  errorQuda("Unexpected QudaGaugeParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
47 #else
48  P(struct_size, (size_t)INVALID_INT);
49 #endif
50 
51 #if defined INIT_PARAM
52  P(location, QUDA_CPU_FIELD_LOCATION);
53 #else
54  P(location, QUDA_INVALID_FIELD_LOCATION);
55 #endif
56 
57  for (int i=0; i<4; i++) P(X[i], INVALID_INT);
58 
59 #if defined INIT_PARAM
61  P(tadpole_coeff, INVALID_DOUBLE);
62  P(scale, 1.0);
63 #else
64  if (param->type == QUDA_WILSON_LINKS) {
66  } else if (param->type == QUDA_ASQTAD_LONG_LINKS) {
67  P(tadpole_coeff, INVALID_DOUBLE);
68  P(scale, INVALID_DOUBLE);
69  }
70 #endif
71 
72  P(type, QUDA_INVALID_LINKS);
74  P(t_boundary, QUDA_INVALID_T_BOUNDARY);
77  P(reconstruct, QUDA_RECONSTRUCT_INVALID);
78 
79 #ifndef CHECK_PARAM
81  P(reconstruct_sloppy, QUDA_RECONSTRUCT_INVALID);
83  P(reconstruct_refinement_sloppy, QUDA_RECONSTRUCT_INVALID);
85  P(reconstruct_precondition, QUDA_RECONSTRUCT_INVALID);
87  P(reconstruct_eigensolver, QUDA_RECONSTRUCT_INVALID);
88 #else
104 #endif
105 
106  P(gauge_fix, QUDA_GAUGE_FIXED_INVALID);
107  P(ga_pad, INVALID_INT);
108 
109 #if defined INIT_PARAM
110  P(staggered_phase_type, QUDA_STAGGERED_PHASE_NO);
111  P(staggered_phase_applied, 0);
112  P(i_mu, 0.0);
113  P(overlap, 0);
114 #else
115  P(staggered_phase_type, QUDA_STAGGERED_PHASE_INVALID);
116  P(staggered_phase_applied, INVALID_INT);
117  P(i_mu, INVALID_DOUBLE);
118  P(overlap, INVALID_INT);
119 #endif
120 
121 #if defined INIT_PARAM
122  P(overwrite_mom, 0);
123  P(use_resident_gauge, 0);
124  P(use_resident_mom, 0);
125  P(make_resident_gauge, 0);
126  P(make_resident_mom, 0);
127  P(return_result_gauge, 1);
128  P(return_result_mom, 1);
129  P(gauge_offset, 0);
130  P(mom_offset, 0);
131  P(site_size, 0);
132 #else
133  P(overwrite_mom, INVALID_INT);
134  P(use_resident_gauge, INVALID_INT);
135  P(use_resident_mom, INVALID_INT);
136  P(make_resident_gauge, INVALID_INT);
137  P(make_resident_mom, INVALID_INT);
138  P(return_result_gauge, INVALID_INT);
139  P(return_result_mom, INVALID_INT);
140  P(gauge_offset, (size_t)INVALID_INT);
141  P(mom_offset, (size_t)INVALID_INT);
142  P(site_size, (size_t)INVALID_INT);
143 #endif
144 
145 #ifdef INIT_PARAM
146  return ret;
147 #endif
148 }
149 
150 // define the appropriate function for EigParam
151 
152 #if defined INIT_PARAM
154  QudaEigParam ret;
155 #elif defined CHECK_PARAM
156 static void checkEigParam(QudaEigParam *param) {
157 #else
159  printfQuda("QUDA Eig Parameters:\n");
160 #endif
161 
162 #if defined CHECK_PARAM
163  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
164  errorQuda("Unexpected QudaEigParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
165 #else
166  P(struct_size, (size_t)INVALID_INT);
167 #endif
168 
169 #if defined INIT_PARAM
170  P(use_eigen_qr, QUDA_BOOLEAN_FALSE);
171  P(use_poly_acc, QUDA_BOOLEAN_FALSE);
172  P(poly_deg, 0);
173  P(a_min, 0.0);
174  P(a_max, 0.0);
175  P(preserve_deflation, QUDA_BOOLEAN_FALSE);
176  P(preserve_deflation_space, 0);
177  P(preserve_evals, QUDA_BOOLEAN_TRUE);
178  P(use_dagger, QUDA_BOOLEAN_FALSE);
179  P(use_norm_op, QUDA_BOOLEAN_FALSE);
180  P(compute_svd, QUDA_BOOLEAN_FALSE);
181  P(require_convergence, QUDA_BOOLEAN_TRUE);
182  P(spectrum, QUDA_SPECTRUM_LR_EIG);
183  P(n_ev, 0);
184  P(n_kr, 0);
185  P(n_conv, 0);
186  P(n_ev_deflate, -1);
187  P(batched_rotate, 0);
188  P(tol, 0.0);
189  P(qr_tol, 0.0);
190  P(check_interval, 0);
191  P(max_restarts, 0);
192  P(arpack_check, QUDA_BOOLEAN_FALSE);
193  P(nk, 0);
194  P(np, 0);
196  P(extlib_type, QUDA_EIGEN_EXTLIB);
198 #else
199  P(use_eigen_qr, QUDA_BOOLEAN_INVALID);
200  P(use_poly_acc, QUDA_BOOLEAN_INVALID);
201  P(poly_deg, INVALID_INT);
202  P(a_min, INVALID_DOUBLE);
203  P(a_max, INVALID_DOUBLE);
204  P(preserve_deflation, QUDA_BOOLEAN_INVALID);
205  P(preserve_evals, QUDA_BOOLEAN_INVALID);
206  P(use_dagger, QUDA_BOOLEAN_INVALID);
207  P(use_norm_op, QUDA_BOOLEAN_INVALID);
208  P(compute_svd, QUDA_BOOLEAN_INVALID);
209  P(require_convergence, QUDA_BOOLEAN_INVALID);
210  P(n_ev, INVALID_INT);
211  P(n_kr, INVALID_INT);
212  P(n_conv, INVALID_INT);
213  P(n_ev_deflate, INVALID_INT);
214  P(batched_rotate, INVALID_INT);
215  P(tol, INVALID_DOUBLE);
216  P(qr_tol, INVALID_DOUBLE);
217  P(check_interval, INVALID_INT);
218  P(max_restarts, INVALID_INT);
219  P(arpack_check, QUDA_BOOLEAN_INVALID);
220  P(nk, INVALID_INT);
221  P(np, INVALID_INT);
223  P(extlib_type, QUDA_EXTLIB_INVALID);
225 #endif
226 
227  // only need to enfore block size checking if doing a block eigen solve
228 #ifdef CHECK__PARAM
229  if (param->eig_type == QUDA_EIG_BLK_TR_LANCZOS)
230 #endif
231  P(block_size, INVALID_INT);
232 
233 #if defined INIT_PARAM
234  P(location, QUDA_CUDA_FIELD_LOCATION);
235 #else
236  P(location, QUDA_INVALID_FIELD_LOCATION);
237 #endif
238 
239 #if defined INIT_PARAM
240  P(save_prec, QUDA_DOUBLE_PRECISION);
241 #else
242  P(save_prec, QUDA_INVALID_PRECISION);
243 #endif
244 
245 #if defined INIT_PARAM
246  P(io_parity_inflate, QUDA_BOOLEAN_FALSE);
247 #else
248  P(io_parity_inflate, QUDA_BOOLEAN_INVALID);
249 #endif
250 
251 #ifdef INIT_PARAM
252  return ret;
253 #endif
254 }
255 
256 // define the appropriate function for clover subset from InvertParam
257 #if defined INIT_PARAM
258 void newQudaCloverParam(QudaInvertParam *param)
259 {
260  QudaInvertParam &ret = *param;
261 #elif defined CHECK_PARAM
262 static void checkCloverParam(QudaInvertParam *param)
263 {
264 #else
266 {
267 #endif
268 
269 #if defined CHECK_PARAM
270  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
271  errorQuda("Unexpected QudaInvertParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
272 #else
273  P(struct_size, (size_t)INVALID_INT);
274 #endif
275 
276 #if defined INIT_PARAM
277  P(clover_location, QUDA_CPU_FIELD_LOCATION);
278 #else
279  P(clover_location, QUDA_INVALID_FIELD_LOCATION);
280 #endif
281 
282 #ifndef INIT_PARAM
283  if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH || param->dslash_type == QUDA_TWISTED_CLOVER_DSLASH
284  || param->dslash_type == QUDA_CLOVER_HASENBUSCH_TWIST_DSLASH) {
285 #endif
286  P(clover_cpu_prec, QUDA_INVALID_PRECISION);
287  P(clover_cuda_prec, QUDA_INVALID_PRECISION);
288 
289 #ifndef CHECK_PARAM
290  P(clover_cuda_prec_sloppy, QUDA_INVALID_PRECISION);
291  P(clover_cuda_prec_refinement_sloppy, QUDA_INVALID_PRECISION);
292  P(clover_cuda_prec_precondition, QUDA_INVALID_PRECISION);
293  P(clover_cuda_prec_eigensolver, QUDA_INVALID_PRECISION);
294 #else
295  if (param->clover_cuda_prec_sloppy == QUDA_INVALID_PRECISION)
296  param->clover_cuda_prec_sloppy = param->clover_cuda_prec;
297  if (param->clover_cuda_prec_refinement_sloppy == QUDA_INVALID_PRECISION)
298  param->clover_cuda_prec_refinement_sloppy = param->clover_cuda_prec_sloppy;
299  if (param->clover_cuda_prec_precondition == QUDA_INVALID_PRECISION)
300  param->clover_cuda_prec_precondition = param->clover_cuda_prec_sloppy;
301  if (param->clover_cuda_prec_eigensolver == QUDA_INVALID_PRECISION)
302  param->clover_cuda_prec_eigensolver = param->clover_cuda_prec_sloppy;
303 #endif
304 
305 #ifdef INIT_PARAM
306  P(compute_clover_trlog, 0);
307  P(compute_clover, 0);
308  P(compute_clover_inverse, 0);
309  P(return_clover, 0);
310  P(return_clover_inverse, 0);
311  P(clover_rho, 0.0);
312  P(clover_coeff, 0.0);
313  P(clover_csw, 0.0);
314 #else
315  P(compute_clover_trlog, QUDA_INVALID_PRECISION);
317  P(compute_clover_inverse, QUDA_INVALID_PRECISION);
318  P(return_clover, QUDA_INVALID_PRECISION);
319  P(return_clover_inverse, QUDA_INVALID_PRECISION);
320  P(clover_rho, INVALID_DOUBLE);
323 #endif
324  P(clover_order, QUDA_INVALID_CLOVER_ORDER);
325  P(cl_pad, INVALID_INT);
326 
327 #ifndef INIT_PARAM
328  }
329 #endif
330 }
331 
332 // define the appropriate function for InvertParam
333 
334 #if defined INIT_PARAM
336 {
337  QudaInvertParam ret;
338  QudaInvertParam *param=&ret;
339 #elif defined CHECK_PARAM
340 static void checkInvertParam(QudaInvertParam *param, void *out_ptr=nullptr, void *in_ptr=nullptr) {
341 #else
343  printfQuda("QUDA Inverter Parameters:\n");
344 #endif
345 
346 #if defined CHECK_PARAM
347  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
348  errorQuda("Unexpected QudaInvertParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
349 #else
350  P(struct_size, (size_t)INVALID_INT);
351 #endif
352 
355 
356 #if defined INIT_PARAM
357  P(mass, INVALID_DOUBLE);
358  P(kappa, INVALID_DOUBLE);
359  P(m5, INVALID_DOUBLE);
360  P(Ls, INVALID_INT);
361  P(mu, INVALID_DOUBLE);
364 #else
365  // asqtad and domain wall use mass parameterization
366  if (param->dslash_type == QUDA_STAGGERED_DSLASH || param->dslash_type == QUDA_ASQTAD_DSLASH
367  || param->dslash_type == QUDA_DOMAIN_WALL_DSLASH || param->dslash_type == QUDA_DOMAIN_WALL_4D_DSLASH
368  || param->dslash_type == QUDA_MOBIUS_DWF_DSLASH) {
369  P(mass, INVALID_DOUBLE);
370  } else { // Wilson and clover use kappa parameterization
371  P(kappa, INVALID_DOUBLE);
372  }
373  if (param->dslash_type == QUDA_DOMAIN_WALL_DSLASH ||
374  param->dslash_type == QUDA_DOMAIN_WALL_4D_DSLASH ||
375  param->dslash_type == QUDA_MOBIUS_DWF_DSLASH ) {
376  P(m5, INVALID_DOUBLE);
377  P(Ls, INVALID_INT);
378  }
379  if (param->dslash_type == QUDA_TWISTED_MASS_DSLASH) {
380  P(mu, INVALID_DOUBLE);
382  }
383 #endif
384 
385  P(tol, INVALID_DOUBLE);
386 
387 #ifdef INIT_PARAM
388  P(residual_type, QUDA_L2_RELATIVE_RESIDUAL);
389 #else
390  P(residual_type, QUDA_INVALID_RESIDUAL);
391 #endif
392 
393  if (param->residual_type & QUDA_HEAVY_QUARK_RESIDUAL) {
395  }
396 
397  P(maxiter, INVALID_INT);
399 #ifndef CHECK_PARAM
400  P(reliable_delta_refinement, INVALID_DOUBLE);
401 #else
402  if (param->reliable_delta_refinement == INVALID_DOUBLE) param->reliable_delta_refinement = param->reliable_delta;
403 #endif
404 
405 #ifdef INIT_PARAM
406  P(use_alternative_reliable, 0);
407  P(use_sloppy_partial_accumulator, 0);
409  P(max_res_increase, 1);
410  P(max_res_increase_total, 10);
411  P(max_hq_res_increase, 1);
412  P(max_hq_res_restart_total, 10);
413  P(heavy_quark_check, 10);
414  #else
415  P(use_alternative_reliable, INVALID_INT);
416  P(use_sloppy_partial_accumulator, INVALID_INT);
418  P(max_res_increase, INVALID_INT);
419  P(max_res_increase_total, INVALID_INT);
420  P(max_hq_res_increase, INVALID_INT);
421  P(max_hq_res_restart_total, INVALID_INT);
422  P(heavy_quark_check, INVALID_INT);
423 #endif
424 
425 #ifndef CHECK_PARAM
426  P(pipeline, 0);
427  P(num_offset, 0);
428  P(num_src, 1);
429  P(overlap, 0);
430 #endif
431 
432 #ifdef INIT_PARAM
433  for (int d = 0; d < 4; d++) { P(split_grid[d], 1); }
434  P(num_src_per_sub_partition, 1);
435 #else
436  for (int d = 0; d < 4; d++) { P(split_grid[d], INVALID_INT); }
437  P(num_src_per_sub_partition, INVALID_INT);
438 #endif
439 
440 #ifdef INIT_PARAM
441  P(compute_action, 0);
442  P(compute_true_res, 1);
443 #else
444  P(compute_action, INVALID_INT);
445  P(compute_true_res, INVALID_INT);
446 #endif
447 
448  if (param->num_offset > 0) {
449 
450  for (int i=0; i<param->num_offset; i++) {
451  P(offset[i], INVALID_DOUBLE);
452  P(tol_offset[i], INVALID_DOUBLE);
453  if (param->residual_type & QUDA_HEAVY_QUARK_RESIDUAL)
454  P(tol_hq_offset[i], INVALID_DOUBLE);
455 #ifndef CHECK_PARAM
456  P(true_res_offset[i], INVALID_DOUBLE);
457  P(iter_res_offset[i], INVALID_DOUBLE);
458 #endif
459  if (param->compute_action) P(residue[i], INVALID_DOUBLE);
460  }
461 #ifndef CHECK_PARAM
462  P(action[0], INVALID_DOUBLE);
463  P(action[1], INVALID_DOUBLE);
464 #endif
465  }
466 
471  P(mass_normalization, QUDA_INVALID_NORMALIZATION);
472 #ifndef CHECK_PARAM
473  P(solver_normalization, QUDA_DEFAULT_NORMALIZATION);
474 #endif
475  P(preserve_source, QUDA_PRESERVE_SOURCE_INVALID);
478 
479 #ifndef CHECK_PARAM
484 #else
492 #endif
493 
494  // leave the default behaviour to cpu pointers
495 #if defined INIT_PARAM
496  P(input_location, QUDA_CPU_FIELD_LOCATION);
497  P(output_location, QUDA_CPU_FIELD_LOCATION);
498  P(clover_location, QUDA_CPU_FIELD_LOCATION);
499 #else
500  P(input_location, QUDA_INVALID_FIELD_LOCATION);
501  P(output_location, QUDA_INVALID_FIELD_LOCATION);
502  P(clover_location, QUDA_INVALID_FIELD_LOCATION);
503 #endif
504 
505 #ifdef CHECK_PARAM
506  if (in_ptr && quda::get_pointer_location(in_ptr) != param->input_location) {
507  warningQuda("input_location=%d, however supplied pointer is location=%d", param->input_location, quda::get_pointer_location(in_ptr));
508  param->input_location = quda::get_pointer_location(in_ptr);
509  }
510 
511  if (out_ptr && quda::get_pointer_location(out_ptr) != param->output_location) {
512  warningQuda("output_location=%d, however supplied pointer is location=%d", param->output_location, quda::get_pointer_location(out_ptr));
513  param->output_location = quda::get_pointer_location(out_ptr);
514  }
515 #endif
516 
517  P(gamma_basis, QUDA_INVALID_GAMMA_BASIS);
518  P(dirac_order, QUDA_INVALID_DIRAC_ORDER);
519  P(sp_pad, INVALID_INT);
520 
521 #if defined INIT_PARAM
522  P(Nsteps, INVALID_INT);
523 #else
524  if(param->inv_type == QUDA_MPCG_INVERTER || param->inv_type == QUDA_MPBICGSTAB_INVERTER){
525  P(Nsteps, INVALID_INT);
526  }
527 #endif
528 
529 #if defined INIT_PARAM
531 #else
532  if (param->inv_type == QUDA_GCR_INVERTER ||
533  param->inv_type == QUDA_CA_GCR_INVERTER ||
534  param->inv_type == QUDA_CA_CG_INVERTER ||
535  param->inv_type == QUDA_CA_CGNE_INVERTER ||
536  param->inv_type == QUDA_CA_CGNR_INVERTER) {
538  }
539 #endif
540 
541  // domain decomposition parameters
542  //P(inv_type_sloppy, QUDA_INVALID_INVERTER); // disable since invalid means no preconditioner
543 #if defined INIT_PARAM
544  P(inv_type_precondition, QUDA_INVALID_INVERTER);
545  P(preconditioner, 0);
548  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
549  P(schwarz_type, QUDA_INVALID_SCHWARZ);
550  P(precondition_cycle, 1); // defaults match previous interface behaviour
551 #else
552  if (param->inv_type_precondition == QUDA_BICGSTAB_INVERTER || param->inv_type_precondition == QUDA_CG_INVERTER
553  || param->inv_type_precondition == QUDA_MR_INVERTER) {
556  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
557  P(precondition_cycle, 0);
558  }
559 #endif
560 
561 #if defined(INIT_PARAM)
562  P(eig_param, 0);
563 #endif
564 
565 #ifdef INIT_PARAM
566  P(use_init_guess, QUDA_USE_INIT_GUESS_NO); //set the default to no
567  P(omega, 1.0); // set default to no relaxation
568 #else
569  P(use_init_guess, QUDA_USE_INIT_GUESS_INVALID);
570  P(omega, INVALID_DOUBLE);
571 #endif
572 
573 #if defined(INIT_PARAM)
574  newQudaCloverParam(param);
575 #elif defined(CHECK_PARAM)
576  checkCloverParam(param);
577 #else
579 #endif
580 
581 #ifdef INIT_PARAM
583  P(ca_lambda_min, 0.0);
584  P(ca_lambda_max, -1.0);
585 #else
586  if (param->inv_type == QUDA_CA_CG_INVERTER ||
587  param->inv_type == QUDA_CA_CGNE_INVERTER ||
588  param->inv_type == QUDA_CA_CGNR_INVERTER) {
590  if (param->ca_basis == QUDA_CHEBYSHEV_BASIS) {
593  }
594  }
595 #endif
596 
598 
599 #ifdef INIT_PARAM
600  P(iter, 0);
601  P(gflops, 0.0);
602  P(secs, 0.0);
603 #elif defined(PRINT_PARAM)
604  P(iter, INVALID_INT);
605  P(gflops, INVALID_DOUBLE);
606  P(secs, INVALID_DOUBLE);
607 #endif
608 
609 
610 #if defined INIT_PARAM
612  P(n_ev, 8);
613  P(max_search_dim, 64);
614  P(rhs_idx, 0);
615  P(deflation_grid, 1);
616 
617  P(eigcg_max_restarts, 4);
618  P(max_restart_num, 3);
619  P(tol_restart,5e-5);
620  P(inc_tol, 1e-2);
621  P(eigenval_tol, 1e-1);
622 #else
624  P(n_ev, INVALID_INT);
626  P(rhs_idx, INVALID_INT);
633 #endif
634 
635 #if defined INIT_PARAM
636  P(use_resident_solution, 0);
637  P(make_resident_solution, 0);
638 #else
639  P(use_resident_solution, INVALID_INT);
640  P(make_resident_solution, INVALID_INT);
641 #endif
642 
643 
644 #if defined INIT_PARAM
645  P(chrono_use_resident, 0);
646  P(chrono_make_resident, 0);
647  P(chrono_replace_last, 0);
648  P(chrono_max_dim, 0);
649  P(chrono_index, 0);
650 #else
651  P(chrono_use_resident, INVALID_INT);
652  P(chrono_make_resident, INVALID_INT);
653  P(chrono_replace_last, INVALID_INT);
654  P(chrono_max_dim, INVALID_INT);
655  P(chrono_index, INVALID_INT);
656 #endif
657 
658 #if !defined CHECK_PARAM
659  P(chrono_precision, QUDA_INVALID_PRECISION);
660 #else
661  // default the chrono precision to using outer precision
662  if (param->chrono_precision == QUDA_INVALID_PRECISION) param->chrono_precision = param->cuda_prec;
663 #endif
664 
665 #if defined INIT_PARAM
666  P(extlib_type, QUDA_EIGEN_EXTLIB);
667 #else
668  P(extlib_type, QUDA_EXTLIB_INVALID);
669 #endif
670 
671 #if defined INIT_PARAM
673 #else
675 #endif
676 
677 #ifdef INIT_PARAM
678  return ret;
679 #endif
680 }
681 
682 
683 #if defined INIT_PARAM
685  QudaMultigridParam ret;
686 #elif defined CHECK_PARAM
687  static void checkMultigridParam(QudaMultigridParam *param) {
688 #else
690  printfQuda("QUDA Multigrid Parameters:\n");
691 #endif
692 
693 #if defined CHECK_PARAM
694  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
695  errorQuda("Unexpected QudaMultigridParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
696 #else
697  P(struct_size, (size_t)INVALID_INT);
698 #endif
699 
700 #ifdef INIT_PARAM
701  // do nothing
702 #elif defined CHECK_PARAM
703  checkInvertParam(param->invert_param);
704 #else
705  printQudaInvertParam(param->invert_param);
706 #endif
707 
708  P(n_level, INVALID_INT);
709 
710 #ifdef INIT_PARAM
711  int n_level = QUDA_MAX_MG_LEVEL;
712 #else
713  int n_level = param->n_level;
714 #endif
715 
716 #ifdef INIT_PARAM
718 #else
720 #endif
721 
722 #ifdef INIT_PARAM
724 #else
726 #endif
727 
728 #ifdef INIT_PARAM
730 #else
732 #endif
733 
734  for (int i=0; i<n_level; i++) {
735 #ifdef INIT_PARAM
736  P(verbosity[i], QUDA_SILENT);
737 #else
739 #endif
740 #ifdef INIT_PARAM
741  P(setup_inv_type[i], QUDA_BICGSTAB_INVERTER);
742 #else
743  P(setup_inv_type[i], QUDA_INVALID_INVERTER);
744 #endif
745 #ifdef INIT_PARAM
746  P(num_setup_iter[i], 1);
747 #else
749 #endif
750 #ifdef INIT_PARAM
751  P(use_eig_solver[i], QUDA_BOOLEAN_FALSE);
752 #else
753  P(use_eig_solver[i], QUDA_BOOLEAN_INVALID);
754 #endif
755 #ifdef INIT_PARAM
756  P(setup_tol[i], 5e-6);
757  P(setup_maxiter[i], 500);
758  P(setup_maxiter_refresh[i], 0);
759 #else
760  P(setup_tol[i], INVALID_DOUBLE);
761  P(setup_maxiter[i], INVALID_INT);
763 #endif
764 
765 #ifdef INIT_PARAM
767  P(setup_ca_basis_size[i], 4);
768  P(setup_ca_lambda_min[i], 0.0);
769  P(setup_ca_lambda_max[i], -1.0);
770 #else
775 #endif
776 
777 #ifdef INIT_PARAM
778  P(n_block_ortho[i], 1);
779 #else
780  P(n_block_ortho[i], INVALID_INT);
781 #endif
782 
785  P(smoother[i], QUDA_INVALID_INVERTER);
787 
788 #ifdef INIT_PARAM
791  P(coarse_solver_ca_lambda_min[i], 0.0);
792  P(coarse_solver_ca_lambda_max[i], -1.0);
793 #else
798 #endif
799 
800 #ifndef CHECK_PARAM
801  P(smoother_halo_precision[i], QUDA_INVALID_PRECISION);
802  P(smoother_schwarz_type[i], QUDA_INVALID_SCHWARZ);
803  P(smoother_schwarz_cycle[i], 1);
804 #else
805  P(smoother_schwarz_cycle[i], INVALID_INT);
806 #endif
807 
808  // these parameters are not set for the bottom grid
809  if (i<n_level-1) {
810  for (int j=0; j<4; j++) P(geo_block_size[i][j], INVALID_INT);
811  P(spin_block_size[i], INVALID_INT);
812 #ifdef INIT_PARAM
813  P(precision_null[i], QUDA_SINGLE_PRECISION);
814 #else
815  P(precision_null[i], INVALID_INT);
816 #endif
817  P(cycle_type[i], QUDA_MG_CYCLE_INVALID);
818  P(nu_pre[i], INVALID_INT);
819  P(nu_post[i], INVALID_INT);
820  P(coarse_grid_solution_type[i], QUDA_INVALID_SOLUTION);
821  }
822 
823 #ifdef INIT_PARAM
824  if (i<QUDA_MAX_MG_LEVEL) {
825  P(n_vec[i], INVALID_INT);
826  }
827 #else
828  if (i<n_level-1) {
829  P(n_vec[i], INVALID_INT);
830  }
831 #endif
832 
833 #ifdef INIT_PARAM
834  P(transfer_type[i], QUDA_TRANSFER_AGGREGATE);
835 #else
836  P(transfer_type[i], QUDA_TRANSFER_INVALID);
837 #endif
838 
839 #ifdef INIT_PARAM
840  P(mu_factor[i], 1);
841 #else
842  P(mu_factor[i], INVALID_DOUBLE);
843 #endif
846 #ifdef INIT_PARAM
847  P(global_reduction[i], QUDA_BOOLEAN_TRUE);
848 #else
849  P(global_reduction[i], QUDA_BOOLEAN_INVALID);
850 #endif
851 
852  P(omega[i], INVALID_DOUBLE);
853  P(location[i], QUDA_INVALID_FIELD_LOCATION);
854 
855 #ifdef INIT_PARAM
856  P(setup_location[i], QUDA_CUDA_FIELD_LOCATION);
857 #else
858  P(setup_location[i], QUDA_INVALID_FIELD_LOCATION);
859 #endif
860  }
861 
862 #ifdef INIT_PARAM
863  P(setup_minimize_memory, QUDA_BOOLEAN_FALSE);
864 #else
865  P(setup_minimize_memory, QUDA_BOOLEAN_INVALID);
866 #endif
867 
868  P(compute_null_vector, QUDA_COMPUTE_NULL_VECTOR_INVALID);
870 
871 #ifdef CHECK_PARAM
872  // if only doing top-level null-space generation, check that n_vec
873  // is equal on all levels
874  if (param->generate_all_levels == QUDA_BOOLEAN_FALSE && param->compute_null_vector == QUDA_COMPUTE_NULL_VECTOR_YES) {
875  for (int i=1; i<n_level-1; i++)
876  if (param->n_vec[0] != param->n_vec[i])
877  errorQuda("n_vec %d != %d must be equal on all levels if generate_all_levels == false",
878  param->n_vec[0], param->n_vec[i]);
879  }
880 #endif
881 
882  P(run_verify, QUDA_BOOLEAN_INVALID);
883 
884 #ifdef INIT_PARAM
885  P(run_low_mode_check, QUDA_BOOLEAN_FALSE);
886  P(run_oblique_proj_check, QUDA_BOOLEAN_FALSE);
887  P(coarse_guess, QUDA_BOOLEAN_FALSE);
888  P(preserve_deflation, QUDA_BOOLEAN_FALSE);
889 #else
890  P(run_low_mode_check, QUDA_BOOLEAN_INVALID);
891  P(run_oblique_proj_check, QUDA_BOOLEAN_INVALID);
892  P(coarse_guess, QUDA_BOOLEAN_INVALID);
893  P(preserve_deflation, QUDA_BOOLEAN_INVALID);
894 #endif
895 
896  for (int i = 0; i < n_level - 1; i++) {
897 #ifdef INIT_PARAM
898  P(vec_load[i], QUDA_BOOLEAN_FALSE);
899  P(vec_store[i], QUDA_BOOLEAN_FALSE);
900 #else
901  P(vec_load[i], QUDA_BOOLEAN_INVALID);
902  P(vec_store[i], QUDA_BOOLEAN_INVALID);
903 #endif
904  }
905 
906 #ifdef INIT_PARAM
907  P(gflops, 0.0);
908  P(secs, 0.0);
909 #elif defined(PRINT_PARAM)
910  P(gflops, INVALID_DOUBLE);
911  P(secs, INVALID_DOUBLE);
912 #endif
913 
914 #ifdef INIT_PARAM
915 #if (CUDA_VERSION >= 10010 && __COMPUTE_CAPABILITY__ >= 700)
916  P(use_mma, QUDA_BOOLEAN_TRUE);
917 #else
918  P(use_mma, QUDA_BOOLEAN_FALSE);
919 #endif
920 #else
921  P(use_mma, QUDA_BOOLEAN_INVALID);
922 #endif
923 
924 #ifdef INIT_PARAM
925  P(thin_update_only, QUDA_BOOLEAN_FALSE);
926 #else
927  P(thin_update_only, QUDA_BOOLEAN_INVALID);
928 #endif
929 
930 #ifdef INIT_PARAM
931  return ret;
932 #endif
933 }
934 
935 #if defined INIT_PARAM
937 {
939 #elif defined CHECK_PARAM
940 static void checkGaugeObservableParam(QudaGaugeObservableParam *param)
941 {
942 #else
944 {
945  printfQuda("QUDA Gauge-Observable Parameters:\n");
946 #endif
947 
948 #if defined CHECK_PARAM
949  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
950  errorQuda("Unexpected QudaGaugeObervableParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
951 #else
952  P(struct_size, (size_t)INVALID_INT);
953 #endif
954 
955 #ifdef INIT_PARAM
956  P(su_project, QUDA_BOOLEAN_FALSE);
957  P(compute_plaquette, QUDA_BOOLEAN_FALSE);
958  P(compute_qcharge, QUDA_BOOLEAN_FALSE);
959  P(compute_qcharge_density, QUDA_BOOLEAN_FALSE);
960  P(qcharge_density, nullptr);
961 #else
962  P(su_project, QUDA_BOOLEAN_INVALID);
963  P(compute_plaquette, QUDA_BOOLEAN_INVALID);
964  P(compute_qcharge, QUDA_BOOLEAN_INVALID);
965  P(compute_qcharge_density, QUDA_BOOLEAN_INVALID);
966 #endif
967 
968 #ifdef INIT_PARAM
969  return ret;
970 #endif
971 }
972 
973 #if defined INIT_PARAM
975 {
976  QudaBLASParam ret;
977 #elif defined CHECK_PARAM
978 static void checkBLASParam(QudaBLASParam *param)
979 {
980 #else
982 {
983  printfQuda("QUDA blas parameters:\n");
984 #endif
985 
986 #if defined CHECK_PARAM
987  if (param->struct_size != (size_t)INVALID_INT && param->struct_size != sizeof(*param))
988  errorQuda("Unexpected QudaBLASParam struct size %lu, expected %lu", param->struct_size, sizeof(*param));
989 #else
990  P(struct_size, (size_t)INVALID_INT);
991 #endif
992 
993 #ifdef INIT_PARAM
994  P(trans_a, QUDA_BLAS_OP_N);
995  P(trans_b, QUDA_BLAS_OP_N);
996  P(m, INVALID_INT);
997  P(n, INVALID_INT);
998  P(k, INVALID_INT);
999  P(lda, INVALID_INT);
1000  P(ldb, INVALID_INT);
1001  P(ldc, INVALID_INT);
1002  P(a_offset, 0);
1003  P(b_offset, 0);
1004  P(c_offset, 0);
1005  P(a_stride, 1);
1006  P(b_stride, 1);
1007  P(c_stride, 1);
1008  P(batch_count, 1);
1009  P(data_type, QUDA_BLAS_DATATYPE_S);
1010  P(data_order, QUDA_BLAS_DATAORDER_ROW);
1011 #else
1012  P(trans_a, QUDA_BLAS_OP_INVALID);
1013  P(trans_b, QUDA_BLAS_OP_INVALID);
1014  P(m, INVALID_INT);
1015  P(n, INVALID_INT);
1016  P(k, INVALID_INT);
1017  P(lda, INVALID_INT);
1018  P(ldb, INVALID_INT);
1019  P(ldc, INVALID_INT);
1020  P(a_offset, INVALID_INT);
1021  P(b_offset, INVALID_INT);
1022  P(c_offset, INVALID_INT);
1023  P(a_stride, INVALID_INT);
1024  P(b_stride, INVALID_INT);
1025  P(c_stride, INVALID_INT);
1026  P(batch_count, INVALID_INT);
1027  P(data_type, QUDA_BLAS_DATATYPE_INVALID);
1028  P(data_order, QUDA_BLAS_DATAORDER_INVALID);
1029 #endif
1030 
1031 #ifdef INIT_PARAM
1032  return ret;
1033 #endif
1034 }
1035 
1036 // clean up
1037 
1038 #undef INVALID_INT
1039 #undef INVALID_DOUBLE
1040 #undef P
void checkBLASParam(QudaBLASParam &param)
void printQudaMultigridParam(QudaMultigridParam *param)
Definition: check_params.h:689
void printQudaInvertParam(QudaInvertParam *param)
Definition: check_params.h:342
void printQudaEigParam(QudaEigParam *param)
Definition: check_params.h:158
#define INVALID_DOUBLE
Definition: check_params.h:15
void printQudaCloverParam(QudaInvertParam *param)
Definition: check_params.h:265
void printQudaBLASParam(QudaBLASParam *param)
Definition: check_params.h:981
void printQudaGaugeParam(QudaGaugeParam *param)
Definition: check_params.h:40
void printQudaGaugeObservableParam(QudaGaugeObservableParam *param)
Definition: check_params.h:943
#define INVALID_INT
Definition: check_params.h:14
bool generate_all_levels
double kappa
double reliable_delta
QudaSolveType solve_type
int laplace3D
quda::mgarray< int > num_setup_iter
double inc_tol
QudaEigType eig_type
QudaInverterType inv_type
double clover_csw
double eigenval_tol
quda::mgarray< double > setup_ca_lambda_max
double mass
double tol
int deflation_grid
double anisotropy
QudaVerbosity verbosity
quda::mgarray< QudaInverterType > coarse_solver
quda::mgarray< QudaCABasis > coarse_solver_ca_basis
quda::mgarray< int > n_block_ortho
double tol_hq
QudaTwistFlavorType twist_flavor
quda::mgarray< int > coarse_solver_maxiter
bool compute_clover
quda::mgarray< int > nu_post
quda::mgarray< int > nu_pre
quda::mgarray< int > setup_ca_basis_size
bool pre_orthonormalize
quda::mgarray< int > coarse_solver_ca_basis_size
bool post_orthonormalize
quda::mgarray< double > setup_ca_lambda_min
quda::mgarray< int > setup_maxiter
quda::mgarray< QudaCABasis > setup_ca_basis
double mu
int max_search_dim
int gcrNkrylov
QudaMemoryType mem_type_ritz
double ca_lambda_min
QudaSolutionType solution_type
double m5
int max_restart_num
QudaDslashType dslash_type
double ca_lambda_max
quda::mgarray< double > mu_factor
quda::mgarray< double > coarse_solver_ca_lambda_max
int solution_accumulator_pipeline
double omega
double clover_coeff
bool native_blas_lapack
int pipeline
QudaMatPCType matpc_type
quda::mgarray< double > setup_tol
quda::mgarray< double > coarse_solver_ca_lambda_min
double tol_precondition
double tol_restart
QudaCABasis ca_basis
quda::mgarray< double > smoother_tol
QudaSetupType setup_type
quda::mgarray< QudaSolveType > smoother_solve_type
quda::mgarray< double > coarse_solver_tol
int maxiter_precondition
int eigcg_max_restarts
quda::mgarray< int > setup_maxiter_refresh
bool dagger
quda::mgarray< std::array< int, 4 > > geo_block_size
@ QUDA_DEFAULT_NORMALIZATION
Definition: enum_quda.h:233
@ QUDA_MG_CYCLE_INVALID
Definition: enum_quda.h:183
@ QUDA_INVALID_CLOVER_ORDER
Definition: enum_quda.h:261
@ QUDA_INVALID_SETUP_TYPE
Definition: enum_quda.h:449
@ QUDA_NULL_VECTOR_SETUP
Definition: enum_quda.h:447
@ QUDA_CHEBYSHEV_BASIS
Definition: enum_quda.h:202
@ QUDA_INVALID_BASIS
Definition: enum_quda.h:203
@ QUDA_POWER_BASIS
Definition: enum_quda.h:201
@ QUDA_STAGGERED_PHASE_NO
Definition: enum_quda.h:515
@ QUDA_STAGGERED_PHASE_INVALID
Definition: enum_quda.h:519
@ QUDA_TWISTED_CLOVER_DSLASH
Definition: enum_quda.h:100
@ QUDA_STAGGERED_DSLASH
Definition: enum_quda.h:97
@ QUDA_INVALID_DSLASH
Definition: enum_quda.h:103
@ QUDA_MOBIUS_DWF_DSLASH
Definition: enum_quda.h:95
@ QUDA_CLOVER_WILSON_DSLASH
Definition: enum_quda.h:91
@ QUDA_TWISTED_MASS_DSLASH
Definition: enum_quda.h:99
@ QUDA_DOMAIN_WALL_DSLASH
Definition: enum_quda.h:93
@ QUDA_ASQTAD_DSLASH
Definition: enum_quda.h:98
@ QUDA_CLOVER_HASENBUSCH_TWIST_DSLASH
Definition: enum_quda.h:92
@ QUDA_DOMAIN_WALL_4D_DSLASH
Definition: enum_quda.h:94
@ QUDA_CUDA_FIELD_LOCATION
Definition: enum_quda.h:326
@ QUDA_CPU_FIELD_LOCATION
Definition: enum_quda.h:325
@ QUDA_INVALID_FIELD_LOCATION
Definition: enum_quda.h:327
@ QUDA_INVALID_NORMALIZATION
Definition: enum_quda.h:229
@ QUDA_DAG_INVALID
Definition: enum_quda.h:223
@ QUDA_USE_INIT_GUESS_NO
Definition: enum_quda.h:429
@ QUDA_USE_INIT_GUESS_INVALID
Definition: enum_quda.h:431
@ QUDA_SILENT
Definition: enum_quda.h:265
@ QUDA_INVALID_VERBOSITY
Definition: enum_quda.h:269
@ QUDA_BLAS_DATATYPE_INVALID
Definition: enum_quda.h:481
@ QUDA_BLAS_DATATYPE_S
Definition: enum_quda.h:477
@ QUDA_BOOLEAN_FALSE
Definition: enum_quda.h:460
@ QUDA_BOOLEAN_INVALID
Definition: enum_quda.h:462
@ QUDA_BOOLEAN_TRUE
Definition: enum_quda.h:461
@ QUDA_INVALID_GAMMA_BASIS
Definition: enum_quda.h:371
@ QUDA_RECONSTRUCT_INVALID
Definition: enum_quda.h:76
@ QUDA_INVALID_T_BOUNDARY
Definition: enum_quda.h:58
@ QUDA_MEMORY_DEVICE
Definition: enum_quda.h:13
@ QUDA_MEMORY_INVALID
Definition: enum_quda.h:16
@ QUDA_INVALID_DIRAC_ORDER
Definition: enum_quda.h:251
@ QUDA_HEAVY_QUARK_RESIDUAL
Definition: enum_quda.h:195
@ QUDA_INVALID_RESIDUAL
Definition: enum_quda.h:196
@ QUDA_L2_RELATIVE_RESIDUAL
Definition: enum_quda.h:193
@ QUDA_TRANSFER_AGGREGATE
Definition: enum_quda.h:453
@ QUDA_TRANSFER_INVALID
Definition: enum_quda.h:456
@ QUDA_EIG_INVALID
Definition: enum_quda.h:141
@ QUDA_EIG_BLK_TR_LANCZOS
Definition: enum_quda.h:138
@ QUDA_EIG_TR_LANCZOS
Definition: enum_quda.h:137
@ QUDA_GAUGE_FIXED_INVALID
Definition: enum_quda.h:82
@ QUDA_MATPC_INVALID
Definition: enum_quda.h:220
@ QUDA_BLAS_DATAORDER_ROW
Definition: enum_quda.h:485
@ QUDA_BLAS_DATAORDER_INVALID
Definition: enum_quda.h:487
@ QUDA_CA_CGNE_INVERTER
Definition: enum_quda.h:130
@ QUDA_GCR_INVERTER
Definition: enum_quda.h:109
@ QUDA_MR_INVERTER
Definition: enum_quda.h:110
@ QUDA_CA_CG_INVERTER
Definition: enum_quda.h:129
@ QUDA_MPCG_INVERTER
Definition: enum_quda.h:115
@ QUDA_CA_GCR_INVERTER
Definition: enum_quda.h:132
@ QUDA_MPBICGSTAB_INVERTER
Definition: enum_quda.h:111
@ QUDA_CG_INVERTER
Definition: enum_quda.h:107
@ QUDA_CA_CGNR_INVERTER
Definition: enum_quda.h:131
@ QUDA_INVALID_INVERTER
Definition: enum_quda.h:133
@ QUDA_BICGSTAB_INVERTER
Definition: enum_quda.h:108
@ QUDA_PRESERVE_SOURCE_INVALID
Definition: enum_quda.h:240
@ QUDA_BLAS_OP_N
Definition: enum_quda.h:470
@ QUDA_BLAS_OP_INVALID
Definition: enum_quda.h:473
@ QUDA_INVALID_SOLUTION
Definition: enum_quda.h:163
@ QUDA_DOUBLE_PRECISION
Definition: enum_quda.h:65
@ QUDA_SINGLE_PRECISION
Definition: enum_quda.h:64
@ QUDA_INVALID_PRECISION
Definition: enum_quda.h:66
@ QUDA_INVALID_SCHWARZ
Definition: enum_quda.h:189
@ QUDA_INVALID_GAUGE_ORDER
Definition: enum_quda.h:52
@ QUDA_EXTLIB_INVALID
Definition: enum_quda.h:559
@ QUDA_EIGEN_EXTLIB
Definition: enum_quda.h:557
@ QUDA_SPECTRUM_LR_EIG
Definition: enum_quda.h:149
@ QUDA_TWIST_INVALID
Definition: enum_quda.h:404
@ QUDA_INVALID_SOLVE
Definition: enum_quda.h:175
@ QUDA_ASQTAD_LONG_LINKS
Definition: enum_quda.h:32
@ QUDA_INVALID_LINKS
Definition: enum_quda.h:35
@ QUDA_WILSON_LINKS
Definition: enum_quda.h:30
@ QUDA_COMPUTE_NULL_VECTOR_INVALID
Definition: enum_quda.h:443
@ QUDA_COMPUTE_NULL_VECTOR_YES
Definition: enum_quda.h:442
QudaGaugeFieldOrder gauge_order
QudaPrecision & cuda_prec
Definition: host_utils.cpp:58
QudaPrecision & cuda_prec_sloppy
Definition: host_utils.cpp:59
QudaPrecision & cuda_prec_eigensolver
Definition: host_utils.cpp:62
QudaPrecision & cuda_prec_precondition
Definition: host_utils.cpp:61
QudaPrecision & cuda_prec_refinement_sloppy
Definition: host_utils.cpp:60
QudaPrecision & cpu_prec
Definition: host_utils.cpp:57
int Ls
Definition: host_utils.cpp:48
QudaPrecision & cuda_prec_ritz
Definition: host_utils.cpp:63
QudaFieldLocation get_pointer_location(const void *ptr)
Definition: malloc.cpp:566
QudaGaugeParam param
Definition: pack_test.cpp:18
QudaBLASParam newQudaBLASParam(void)
QudaGaugeParam newQudaGaugeParam(void)
QudaMultigridParam newQudaMultigridParam(void)
QudaGaugeObservableParam newQudaGaugeObservableParam(void)
QudaInvertParam newQudaInvertParam(void)
QudaEigParam newQudaEigParam(void)
#define QUDA_MAX_MG_LEVEL
Maximum number of multi-grid levels. This number may be increased if needed.
QudaReconstructType reconstruct_precondition
Definition: quda.h:58
QudaReconstructType reconstruct
Definition: quda.h:49
QudaPrecision cuda_prec_precondition
Definition: quda.h:57
QudaLinkType type
Definition: quda.h:41
QudaPrecision cuda_prec_refinement_sloppy
Definition: quda.h:54
QudaPrecision cuda_prec_sloppy
Definition: quda.h:51
size_t struct_size
Definition: quda.h:32
QudaReconstructType reconstruct_sloppy
Definition: quda.h:52
QudaPrecision cuda_prec
Definition: quda.h:48
QudaReconstructType reconstruct_eigensolver
Definition: quda.h:61
QudaReconstructType reconstruct_refinement_sloppy
Definition: quda.h:55
QudaPrecision cuda_prec_eigensolver
Definition: quda.h:60
#define printfQuda(...)
Definition: util_quda.h:114
#define warningQuda(...)
Definition: util_quda.h:132
#define errorQuda(...)
Definition: util_quda.h:120