QUDA  v0.7.0
A library for QCD on GPUs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 INIT_PARAM
46 #else
48 #endif
49 
50  for (int i=0; i<4; i++) P(X[i], INVALID_INT);
51 
52 #if defined INIT_PARAM
54  P(tadpole_coeff, INVALID_DOUBLE);
55  P(scale, INVALID_DOUBLE);
56 #else
57  if (param->type == QUDA_WILSON_LINKS) {
59  } else if (param->type == QUDA_ASQTAD_FAT_LINKS ||
60  param->type == QUDA_ASQTAD_LONG_LINKS) {
61  P(tadpole_coeff, INVALID_DOUBLE);
62  //P(scale, INVALID_DOUBLE);
63  }
64 #endif
65 
66  P(type, QUDA_INVALID_LINKS);
71  P(reconstruct, QUDA_RECONSTRUCT_INVALID);
72  P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
73  P(reconstruct_sloppy, QUDA_RECONSTRUCT_INVALID);
74 #if defined INIT_PARAM
75  P(cuda_prec_precondition, QUDA_INVALID_PRECISION);
76  P(reconstruct_precondition, QUDA_RECONSTRUCT_INVALID);
77 #else
82 #endif
83 
84  P(gauge_fix, QUDA_GAUGE_FIXED_INVALID);
85  P(ga_pad, INVALID_INT);
86 
87 #if defined INIT_PARAM
88  P(gaugeGiB, 0.0);
89 #else
90  P(gaugeGiB, INVALID_DOUBLE);
91 #endif
92 
93 
94 #if defined INIT_PARAM
95  P(overlap, 0);
96  P(preserve_gauge, 0);
97 #else
98  P(preserve_gauge, INVALID_INT);
99 #endif
100 
101 #if defined INIT_PARAM
102  P(use_resident_gauge, 0);
103  P(use_resident_mom, 0);
104  P(make_resident_gauge, 0);
105  P(make_resident_mom, 0);
106 #else
107  P(use_resident_gauge, INVALID_INT);
108  P(use_resident_mom, INVALID_INT);
109  P(make_resident_gauge, INVALID_INT);
110  P(make_resident_mom, INVALID_INT);
111 #endif
112 
113 #ifdef INIT_PARAM
114  return ret;
115 #endif
116 }
117 
118 // define the appropriate function for EigParam
119 
120 #if defined INIT_PARAM
122  QudaEigParam ret;
123 #elif defined CHECK_PARAM
124 static void checkEigParam(QudaEigParam *param) {
125 #else
127  printfQuda("QUDA Eig Parameters:\n");
128 #endif
129 
130 #if defined INIT_PARAM
131  P(RitzMat_lanczos, QUDA_INVALID_SOLUTION);
132  P(RitzMat_Convcheck, QUDA_INVALID_SOLUTION);
133  P(eig_type, QUDA_INVALID_TYPE);
134  P(NPoly, 0);
135  P(Stp_residual, 0.0);
136  P(nk, 0);
137  P(np, 0);
138  P(f_size, 0);
139  P(eigen_shift, 0.0);
140 #else
141  P(NPoly, INVALID_INT);
142  P(Stp_residual, INVALID_DOUBLE);
143  P(nk, INVALID_INT);
144  P(np, INVALID_INT);
145  P(f_size, INVALID_INT);
146  P(eigen_shift, INVALID_DOUBLE);
147 #endif
148 
149 #ifdef INIT_PARAM
150  return ret;
151 #endif
152 }
153 // define the appropriate function for InvertParam
154 
155 #if defined INIT_PARAM
157  QudaInvertParam ret;
158  QudaInvertParam *param=&ret;
159 #elif defined CHECK_PARAM
160 static void checkInvertParam(QudaInvertParam *param) {
161 #else
163  printfQuda("QUDA Inverter Parameters:\n");
164 #endif
165 
168 
169 #if defined INIT_PARAM
170  P(mass, INVALID_DOUBLE);
171  P(kappa, INVALID_DOUBLE);
172  P(m5, INVALID_DOUBLE);
173  P(Ls, INVALID_INT);
174  P(mu, INVALID_DOUBLE);
176 #else
177  // asqtad and domain wall use mass parameterization
178  if (param->dslash_type == QUDA_STAGGERED_DSLASH ||
179  param->dslash_type == QUDA_ASQTAD_DSLASH ||
182  param->dslash_type == QUDA_MOBIUS_DWF_DSLASH ) {
183  P(mass, INVALID_DOUBLE);
184  } else { // Wilson and clover use kappa parameterization
185  P(kappa, INVALID_DOUBLE);
186  }
187  if (param->dslash_type == QUDA_DOMAIN_WALL_DSLASH ||
189  param->dslash_type == QUDA_MOBIUS_DWF_DSLASH ) {
190  P(m5, INVALID_DOUBLE);
191  P(Ls, INVALID_INT);
192  }
193  if (param->dslash_type == QUDA_TWISTED_MASS_DSLASH) {
194  P(mu, INVALID_DOUBLE);
196  }
197 #endif
198 
199  P(tol, INVALID_DOUBLE);
200 
201 #ifdef INIT_PARAM
202  P(residual_type, QUDA_L2_RELATIVE_RESIDUAL);
203 #else
204  P(residual_type, QUDA_INVALID_RESIDUAL);
205 #endif
206 
208  P(tol_hq, INVALID_DOUBLE);
209  }
210 
211  P(maxiter, INVALID_INT);
212  P(reliable_delta, INVALID_DOUBLE);
213 #ifdef INIT_PARAM
214  P(use_sloppy_partial_accumulator, 0);
215  P(max_res_increase, 1);
216  P(max_res_increase_total, 10);
217 #else
218  P(use_sloppy_partial_accumulator, INVALID_INT);
219  P(max_res_increase, INVALID_INT);
220  P(max_res_increase_total, INVALID_INT);
221 #endif
222 
223 #ifndef CHECK_PARAM
224  P(pipeline, 0);
225  P(num_offset, 0);
226  P(overlap, 0);
227 #endif
228 
229  if (param->num_offset > 0) {
230  for (int i=0; i<param->num_offset; i++) {
231  P(offset[i], INVALID_DOUBLE);
232  P(tol_offset[i], INVALID_DOUBLE);
234  P(tol_hq_offset[i], INVALID_DOUBLE);
235 #ifndef CHECK_PARAM
236  P(true_res_offset[i], INVALID_DOUBLE);
237 #endif
238  }
239  }
240 
241  P(solution_type, QUDA_INVALID_SOLUTION);
242  P(solve_type, QUDA_INVALID_SOLVE);
245  P(mass_normalization, QUDA_INVALID_NORMALIZATION);
246 #ifndef CHECK_PARAM
247  P(solver_normalization, QUDA_DEFAULT_NORMALIZATION);
248 #endif
249  P(preserve_source, QUDA_PRESERVE_SOURCE_INVALID);
252  P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
253 
254  // leave the default behviour to cpu pointers
255 #if defined INIT_PARAM
256  P(input_location, QUDA_CPU_FIELD_LOCATION);
257  P(output_location, QUDA_CPU_FIELD_LOCATION);
258  P(clover_location, QUDA_CPU_FIELD_LOCATION);
259 #else
260  P(input_location, QUDA_INVALID_FIELD_LOCATION);
261  P(output_location, QUDA_INVALID_FIELD_LOCATION);
262  P(clover_location, QUDA_INVALID_FIELD_LOCATION);
263 #endif
264 
265 #if defined INIT_PARAM
266  P(cuda_prec_precondition, QUDA_INVALID_PRECISION);
267 #else
270 #endif
271 
272  P(gamma_basis, QUDA_INVALID_GAMMA_BASIS);
273  P(dirac_order, QUDA_INVALID_DIRAC_ORDER);
274  P(sp_pad, INVALID_INT);
275 
277 
278 #if defined INIT_PARAM
279  P(Nsteps, INVALID_INT);
280 #else
282  P(Nsteps, INVALID_INT);
283  }
284 #endif
285 
286 #if defined INIT_PARAM
287  P(gcrNkrylov, INVALID_INT);
288 #else
289  if (param->inv_type == QUDA_GCR_INVERTER) {
290  P(gcrNkrylov, INVALID_INT);
291  }
292 #endif
293 
294  // domain decomposition parameters
295  //P(inv_type_sloppy, QUDA_INVALID_INVERTER); // disable since invalid means no preconditioner
296 #if defined INIT_PARAM
297  P(inv_type_precondition, QUDA_INVALID_INVERTER);
298  P(tol_precondition, INVALID_DOUBLE);
299  P(maxiter_precondition, INVALID_INT);
300  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
301  P(schwarz_type, QUDA_ADDITIVE_SCHWARZ); // defaults match previous interface behaviour
302  P(precondition_cycle, 1); // defaults match previous interface behaviour
303 #else
307  P(tol_precondition, INVALID_DOUBLE);
308  P(maxiter_precondition, INVALID_INT);
309  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
310  P(schwarz_type, QUDA_INVALID_SCHWARZ);
311  P(precondition_cycle, 0);
312  }
313 #endif
314 
315 
316 
317 
318 #ifdef INIT_PARAM
319  P(use_init_guess, QUDA_USE_INIT_GUESS_NO); //set the default to no
320  P(omega, 1.0); // set default to no relaxation
321 #else
322  P(use_init_guess, QUDA_USE_INIT_GUESS_INVALID);
323  P(omega, INVALID_DOUBLE);
324 #endif
325 
326 #ifndef INIT_PARAM
327  if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH) {
328 #endif
329  P(clover_cpu_prec, QUDA_INVALID_PRECISION);
330  P(clover_cuda_prec, QUDA_INVALID_PRECISION);
331  P(clover_cuda_prec_sloppy, QUDA_INVALID_PRECISION);
332 #if defined INIT_PARAM
333  P(clover_cuda_prec_precondition, QUDA_INVALID_PRECISION);
334  P(compute_clover_trlog, 0);
335 #else
338 #endif
339  P(clover_order, QUDA_INVALID_CLOVER_ORDER);
340  P(cl_pad, INVALID_INT);
341 #ifndef INIT_PARAM
342  }
343 #endif
344 
345  P(verbosity, QUDA_INVALID_VERBOSITY);
346 
347 #ifdef INIT_PARAM
348  P(iter, 0);
349  P(spinorGiB, 0.0);
351  P(cloverGiB, 0.0);
352  P(gflops, 0.0);
353  P(secs, 0.0);
354 #elif defined(PRINT_PARAM)
355  P(iter, INVALID_INT);
356  P(spinorGiB, INVALID_DOUBLE);
358  P(cloverGiB, INVALID_DOUBLE);
359  P(gflops, INVALID_DOUBLE);
360  P(secs, INVALID_DOUBLE);
361 #endif
362 
363 
364 #ifdef INIT_PARAM
365  //p(ghostDim[0],0);
366  //p(ghostDim[1],0);
367  //p(ghostDim[2],0);
368  //p(ghostDim[3],0);
369 #endif
370 
371 
372 #if defined INIT_PARAM
373  P(cuda_prec_ritz, QUDA_INVALID_PRECISION);
374  P(nev, 0);
375  P(max_search_dim, 0);
376  P(rhs_idx, 0);
377  P(deflation_grid, 0);
378 #else
379  //P(cuda_prec_ritz, QUDA_INVALID_PRECISION);
380  P(nev, INVALID_INT);
381  P(max_search_dim, INVALID_INT);
382  P(rhs_idx, INVALID_INT);
383  P(deflation_grid, INVALID_INT);
384 #endif
385 
386 
387 
388 #ifdef INIT_PARAM
389  return ret;
390 #endif
391 }
392 
393 
394 // clean up
395 
396 #undef INVALID_INT
397 #undef INVALID_DOUBLE
398 #undef P
QudaDslashType dslash_type
Definition: test_util.cpp:1560
QudaReconstructType reconstruct_sloppy
Definition: quda.h:46
QudaInverterType inv_type_precondition
Definition: quda.h:203
QudaLinkType type
Definition: quda.h:35
#define INVALID_INT
Definition: check_params.h:14
#define INVALID_DOUBLE
Definition: check_params.h:15
QudaDslashType dslash_type
Definition: quda.h:85
QudaReconstructType reconstruct_precondition
Definition: quda.h:49
QudaInverterType inv_type
Definition: quda.h:86
__global__ void const RealA *const const RealA *const const RealA *const const RealB *const const RealB *const int int mu
#define m5
void printQudaInvertParam(QudaInvertParam *param)
Definition: check_params.h:162
void printQudaGaugeParam(QudaGaugeParam *param)
Definition: check_params.h:40
QudaPrecision cpu_prec
Definition: dslash_test.cpp:34
QudaPrecision clover_cuda_prec_sloppy
Definition: quda.h:163
QudaDagType dagger
Definition: test_util.cpp:1558
void printQudaEigParam(QudaEigParam *param)
Definition: check_params.h:126
int Ls
Definition: test_util.cpp:40
QudaGaugeParam param
Definition: pack_test.cpp:17
QudaPrecision clover_cuda_prec_precondition
Definition: quda.h:164
const QudaFieldLocation location
Definition: pack_test.cpp:46
VOLATILE spinorFloat kappa
QudaPrecision cuda_prec_sloppy
Definition: quda.h:153
QudaInvertParam newQudaInvertParam(void)
QudaPrecision cuda_prec_precondition
Definition: quda.h:48
__constant__ double anisotropy
QudaPrecision cuda_prec_sloppy
Definition: quda.h:45
QudaTwistFlavorType twist_flavor
Definition: test_util.cpp:1570
QudaPrecision cuda_prec
Definition: dslash_test.cpp:35
bool tune
Definition: blas_test.cu:28
QudaInverterType inv_type
Definition: test_util.cpp:1565
QudaPrecision cuda_prec_precondition
Definition: quda.h:154
QudaGaugeFieldOrder gauge_order
#define printfQuda(...)
Definition: util_quda.h:67
QudaMatPCType matpc_type
Definition: test_util.cpp:1573
QudaResidualType residual_type
Definition: quda.h:235
__constant__ double t_boundary
int num_offset
Definition: quda.h:123
double mass
Definition: test_util.cpp:1569
QudaEigParam newQudaEigParam(void)
QudaGaugeParam newQudaGaugeParam(void)