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
37 #elif defined CHECK_PARAM
39 #else
42 #endif
43
44 #if defined CHECK_PARAM
47 #else
49 #endif
50
51 #if defined INIT_PARAM
53 #else
55 #endif
56
58
59 #if defined INIT_PARAM
62 P(scale, 1.0);
63 #else
69 }
70 #endif
71
78
79 #ifndef CHECK_PARAM
88 #else
104 #endif
105
108
109 #if defined INIT_PARAM
111 P(staggered_phase_applied, 0);
112 P(i_mu, 0.0);
113 P(overlap, 0);
114 #else
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
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
155 #elif defined CHECK_PARAM
157 #else
160 #endif
161
162 #if defined CHECK_PARAM
165 #else
167 #endif
168
169 #if defined INIT_PARAM
172 P(poly_deg, 0);
173 P(a_min, 0.0);
174 P(a_max, 0.0);
176 P(preserve_deflation_space, 0);
184 P(n_kr, 0);
185 P(n_conv, 0);
186 P(n_ev_deflate, -1);
187 P(batched_rotate, 0);
189 P(qr_tol, 0.0);
190 P(check_interval, 0);
191 P(max_restarts, 0);
193 P(nk, 0);
194 P(np, 0);
198 #else
225 #endif
226
227 // only need to enfore block size checking if doing a block eigen solve
228 #ifdef CHECK__PARAM
230 #endif
232
233 #if defined INIT_PARAM
235 #else
237 #endif
238
239 #if defined INIT_PARAM
241 #else
243 #endif
244
245 #if defined INIT_PARAM
247 #else
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
259 {
261 #elif defined CHECK_PARAM
263 {
264 #else
266 {
267 #endif
268
269 #if defined CHECK_PARAM
272 #else
274 #endif
275
276 #if defined INIT_PARAM
278 #else
280 #endif
281
282 #ifndef INIT_PARAM
285 #endif
288
289 #ifndef CHECK_PARAM
294 #else
296 param->clover_cuda_prec_sloppy =
param->clover_cuda_prec;
298 param->clover_cuda_prec_refinement_sloppy =
param->clover_cuda_prec_sloppy;
300 param->clover_cuda_prec_precondition =
param->clover_cuda_prec_sloppy;
302 param->clover_cuda_prec_eigensolver =
param->clover_cuda_prec_sloppy;
303 #endif
304
305 #ifdef INIT_PARAM
306 P(compute_clover_trlog, 0);
308 P(compute_clover_inverse, 0);
309 P(return_clover, 0);
310 P(return_clover_inverse, 0);
311 P(clover_rho, 0.0);
314 #else
323 #endif
326
327 #ifndef INIT_PARAM
328 }
329 #endif
330 }
331
332 // define the appropriate function for InvertParam
333
334 #if defined INIT_PARAM
336 {
339 #elif defined CHECK_PARAM
340 static void checkInvertParam(
QudaInvertParam *
param,
void *out_ptr=
nullptr,
void *in_ptr=
nullptr) {
341 #else
344 #endif
345
346 #if defined CHECK_PARAM
349 #else
351 #endif
352
355
356 #if defined INIT_PARAM
364 #else
365 // asqtad and domain wall use mass parameterization
370 } else { // Wilson and clover use kappa parameterization
372 }
378 }
382 }
383 #endif
384
386
387 #ifdef INIT_PARAM
389 #else
391 #endif
392
395 }
396
399 #ifndef CHECK_PARAM
401 #else
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
423 #endif
424
425 #ifndef CHECK_PARAM
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); }
438 #endif
439
440 #ifdef INIT_PARAM
441 P(compute_action, 0);
442 P(compute_true_res, 1);
443 #else
446 #endif
447
448 if (
param->num_offset > 0) {
449
450 for (
int i=0; i<
param->num_offset; i++) {
455 #ifndef CHECK_PARAM
458 #endif
460 }
461 #ifndef CHECK_PARAM
464 #endif
465 }
466
472 #ifndef CHECK_PARAM
474 #endif
478
479 #ifndef CHECK_PARAM
484 #else
492 #endif
493
494 // leave the default behaviour to cpu pointers
495 #if defined INIT_PARAM
499 #else
503 #endif
504
505 #ifdef CHECK_PARAM
509 }
510
514 }
515 #endif
516
520
521 #if defined INIT_PARAM
523 #else
526 }
527 #endif
528
529 #if defined INIT_PARAM
531 #else
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
545 P(preconditioner, 0);
550 P(precondition_cycle, 1); // defaults match previous interface behaviour
551 #else
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
567 P(
omega, 1.0);
// set default to no relaxation
568 #else
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
585 #else
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)
607 #endif
608
609
610 #if defined INIT_PARAM
614 P(rhs_idx, 0);
616
622 #else
633 #endif
634
635 #if defined INIT_PARAM
636 P(use_resident_solution, 0);
637 P(make_resident_solution, 0);
638 #else
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
656 #endif
657
658 #if !defined CHECK_PARAM
660 #else
661 // default the chrono precision to using outer precision
663 #endif
664
665 #if defined INIT_PARAM
667 #else
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
686 #elif defined CHECK_PARAM
688 #else
691 #endif
692
693 #if defined CHECK_PARAM
696 #else
698 #endif
699
700 #ifdef INIT_PARAM
701 // do nothing
702 #elif defined CHECK_PARAM
703 checkInvertParam(
param->invert_param);
704 #else
706 #endif
707
709
710 #ifdef INIT_PARAM
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
737 #else
739 #endif
740 #ifdef INIT_PARAM
742 #else
744 #endif
745 #ifdef INIT_PARAM
747 #else
749 #endif
750 #ifdef INIT_PARAM
752 #else
754 #endif
755 #ifdef INIT_PARAM
759 #else
763 #endif
764
765 #ifdef INIT_PARAM
770 #else
775 #endif
776
777 #ifdef INIT_PARAM
779 #else
781 #endif
782
787
788 #ifdef INIT_PARAM
793 #else
798 #endif
799
800 #ifndef CHECK_PARAM
803 P(smoother_schwarz_cycle[i], 1);
804 #else
806 #endif
807
808 // these parameters are not set for the bottom grid
809 if (i<n_level-1) {
812 #ifdef INIT_PARAM
814 #else
816 #endif
821 }
822
823 #ifdef INIT_PARAM
826 }
827 #else
828 if (i<n_level-1) {
830 }
831 #endif
832
833 #ifdef INIT_PARAM
835 #else
837 #endif
838
839 #ifdef INIT_PARAM
841 #else
843 #endif
846 #ifdef INIT_PARAM
848 #else
850 #endif
851
854
855 #ifdef INIT_PARAM
857 #else
859 #endif
860 }
861
862 #ifdef INIT_PARAM
864 #else
866 #endif
867
870
871 #ifdef CHECK_PARAM
872 // if only doing top-level null-space generation, check that n_vec
873 // is equal on all levels
875 for (int i=1; i<n_level-1; i++)
877 errorQuda(
"n_vec %d != %d must be equal on all levels if generate_all_levels == false",
879 }
880 #endif
881
883
884 #ifdef INIT_PARAM
889 #else
894 #endif
895
896 for (int i = 0; i < n_level - 1; i++) {
897 #ifdef INIT_PARAM
900 #else
903 #endif
904 }
905
906 #ifdef INIT_PARAM
907 P(gflops, 0.0);
908 P(secs, 0.0);
909 #elif defined(PRINT_PARAM)
912 #endif
913
914 #ifdef INIT_PARAM
915 #if (CUDA_VERSION >= 10010 && __COMPUTE_CAPABILITY__ >= 700)
917 #else
919 #endif
920 #else
922 #endif
923
924 #ifdef INIT_PARAM
926 #else
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
941 {
942 #else
944 {
945 printfQuda(
"QUDA Gauge-Observable Parameters:\n");
946 #endif
947
948 #if defined CHECK_PARAM
951 #else
953 #endif
954
955 #ifdef INIT_PARAM
960 P(qcharge_density, nullptr);
961 #else
966 #endif
967
968 #ifdef INIT_PARAM
969 return ret;
970 #endif
971 }
972
973 #if defined INIT_PARAM
975 {
977 #elif defined CHECK_PARAM
979 {
980 #else
982 {
984 #endif
985
986 #if defined CHECK_PARAM
989 #else
991 #endif
992
993 #ifdef INIT_PARAM
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);
1011 #else
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 ¶m)
void printQudaMultigridParam(QudaMultigridParam *param)
void printQudaInvertParam(QudaInvertParam *param)
void printQudaEigParam(QudaEigParam *param)
void printQudaCloverParam(QudaInvertParam *param)
void printQudaBLASParam(QudaBLASParam *param)
void printQudaGaugeParam(QudaGaugeParam *param)
void printQudaGaugeObservableParam(QudaGaugeObservableParam *param)
quda::mgarray< int > num_setup_iter
QudaInverterType inv_type
quda::mgarray< double > setup_ca_lambda_max
quda::mgarray< QudaInverterType > coarse_solver
quda::mgarray< QudaCABasis > coarse_solver_ca_basis
quda::mgarray< int > n_block_ortho
QudaTwistFlavorType twist_flavor
quda::mgarray< int > coarse_solver_maxiter
quda::mgarray< int > nu_post
quda::mgarray< int > nu_pre
quda::mgarray< int > setup_ca_basis_size
quda::mgarray< int > coarse_solver_ca_basis_size
quda::mgarray< double > setup_ca_lambda_min
quda::mgarray< int > setup_maxiter
quda::mgarray< QudaCABasis > setup_ca_basis
QudaMemoryType mem_type_ritz
QudaSolutionType solution_type
QudaDslashType dslash_type
quda::mgarray< double > mu_factor
quda::mgarray< double > coarse_solver_ca_lambda_max
int solution_accumulator_pipeline
quda::mgarray< double > setup_tol
quda::mgarray< double > coarse_solver_ca_lambda_min
quda::mgarray< double > smoother_tol
quda::mgarray< QudaSolveType > smoother_solve_type
quda::mgarray< double > coarse_solver_tol
quda::mgarray< int > setup_maxiter_refresh
quda::mgarray< std::array< int, 4 > > geo_block_size
@ QUDA_DEFAULT_NORMALIZATION
@ QUDA_INVALID_CLOVER_ORDER
@ QUDA_INVALID_SETUP_TYPE
@ QUDA_STAGGERED_PHASE_NO
@ QUDA_STAGGERED_PHASE_INVALID
@ QUDA_TWISTED_CLOVER_DSLASH
@ QUDA_CLOVER_WILSON_DSLASH
@ QUDA_TWISTED_MASS_DSLASH
@ QUDA_DOMAIN_WALL_DSLASH
@ QUDA_CLOVER_HASENBUSCH_TWIST_DSLASH
@ QUDA_DOMAIN_WALL_4D_DSLASH
@ QUDA_CUDA_FIELD_LOCATION
@ QUDA_CPU_FIELD_LOCATION
@ QUDA_INVALID_FIELD_LOCATION
@ QUDA_INVALID_NORMALIZATION
@ QUDA_USE_INIT_GUESS_INVALID
@ QUDA_BLAS_DATATYPE_INVALID
@ QUDA_INVALID_GAMMA_BASIS
@ QUDA_RECONSTRUCT_INVALID
@ QUDA_INVALID_T_BOUNDARY
@ QUDA_INVALID_DIRAC_ORDER
@ QUDA_HEAVY_QUARK_RESIDUAL
@ QUDA_L2_RELATIVE_RESIDUAL
@ QUDA_TRANSFER_AGGREGATE
@ QUDA_EIG_BLK_TR_LANCZOS
@ QUDA_GAUGE_FIXED_INVALID
@ QUDA_BLAS_DATAORDER_ROW
@ QUDA_BLAS_DATAORDER_INVALID
@ QUDA_MPBICGSTAB_INVERTER
@ QUDA_PRESERVE_SOURCE_INVALID
@ QUDA_INVALID_GAUGE_ORDER
@ QUDA_COMPUTE_NULL_VECTOR_INVALID
@ QUDA_COMPUTE_NULL_VECTOR_YES
QudaGaugeFieldOrder gauge_order
QudaPrecision & cuda_prec
QudaPrecision & cuda_prec_sloppy
QudaPrecision & cuda_prec_eigensolver
QudaPrecision & cuda_prec_precondition
QudaPrecision & cuda_prec_refinement_sloppy
QudaPrecision & cuda_prec_ritz
QudaFieldLocation get_pointer_location(const void *ptr)
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
QudaReconstructType reconstruct
QudaPrecision cuda_prec_precondition
QudaPrecision cuda_prec_refinement_sloppy
QudaPrecision cuda_prec_sloppy
QudaReconstructType reconstruct_sloppy
QudaReconstructType reconstruct_eigensolver
QudaReconstructType reconstruct_refinement_sloppy
QudaPrecision cuda_prec_eigensolver