QUDA  v0.5.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  for (int i=0; i<4; i++) P(X[i], INVALID_INT);
45 
46 #if defined INIT_PARAM
48  P(tadpole_coeff, INVALID_DOUBLE);
49 #else
50  if (param->type == QUDA_WILSON_LINKS) {
52  } else if (param->type == QUDA_ASQTAD_FAT_LINKS ||
53  param->type == QUDA_ASQTAD_LONG_LINKS) {
54  P(tadpole_coeff, INVALID_DOUBLE);
55  }
56 #endif
57 
58  P(type, QUDA_INVALID_LINKS);
63  P(reconstruct, QUDA_RECONSTRUCT_INVALID);
64  P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
65  P(reconstruct_sloppy, QUDA_RECONSTRUCT_INVALID);
66 #if defined INIT_PARAM
67  P(cuda_prec_precondition, QUDA_INVALID_PRECISION);
68  P(reconstruct_precondition, QUDA_RECONSTRUCT_INVALID);
69 #else
74 #endif
75 
76  P(gauge_fix, QUDA_GAUGE_FIXED_INVALID);
77  P(ga_pad, INVALID_INT);
78 
79 #if defined INIT_PARAM
80  P(gaugeGiB, 0.0);
81 #else
82  P(gaugeGiB, INVALID_DOUBLE);
83 #endif
84 
85 #if defined INIT_PARAM
86  P(preserve_gauge, 0);
87 #else
88  P(preserve_gauge, INVALID_INT);
89 #endif
90 
91 #ifdef INIT_PARAM
92  return ret;
93 #endif
94 }
95 
96 
97 // define the appropriate function for InvertParam
98 
99 #if defined INIT_PARAM
101  QudaInvertParam ret;
102  QudaInvertParam *param=&ret;
103 #elif defined CHECK_PARAM
104 static void checkInvertParam(QudaInvertParam *param) {
105 #else
107  printfQuda("QUDA Inverter Parameters:\n");
108 #endif
109 
111  P(inv_type, QUDA_INVALID_INVERTER);
112 
113 #if defined INIT_PARAM
114  P(mass, INVALID_DOUBLE);
115  P(kappa, INVALID_DOUBLE);
116  P(m5, INVALID_DOUBLE);
117  P(Ls, INVALID_INT);
118  P(mu, INVALID_DOUBLE);
119  P(twist_flavor, QUDA_TWIST_INVALID);
120 #else
121  // asqtad and domain wall use mass parameterization
123  P(mass, INVALID_DOUBLE);
124  } else { // Wilson and clover use kappa parameterization
125  P(kappa, INVALID_DOUBLE);
126  }
127  if (param->dslash_type == QUDA_DOMAIN_WALL_DSLASH) {
128  P(m5, INVALID_DOUBLE);
129  P(Ls, INVALID_INT);
130  }
131  if (param->dslash_type == QUDA_TWISTED_MASS_DSLASH) {
132  P(mu, INVALID_DOUBLE);
133  P(twist_flavor, QUDA_TWIST_INVALID);
134  }
135 #endif
136 
137  P(tol, INVALID_DOUBLE);
138 
140  P(tol_hq, INVALID_DOUBLE);
141  }
142 
143  P(maxiter, INVALID_INT);
144  P(reliable_delta, INVALID_DOUBLE);
145 
146 #ifndef CHECK_PARAM
147  P(num_offset, 0);
148 #endif
149 
150  if (param->num_offset > 0) {
151  for (int i=0; i<param->num_offset; i++) {
152  P(offset[i], INVALID_DOUBLE);
153  P(tol_offset[i], INVALID_DOUBLE);
155  P(tol_hq_offset[i], INVALID_DOUBLE);
156 #ifndef CHECK_PARAM
157  P(true_res_offset[i], INVALID_DOUBLE);
158 #endif
159  }
160  }
161 
162  P(solution_type, QUDA_INVALID_SOLUTION);
163  P(solve_type, QUDA_INVALID_SOLVE);
164  P(matpc_type, QUDA_MATPC_INVALID);
166  P(mass_normalization, QUDA_INVALID_NORMALIZATION);
167  P(preserve_source, QUDA_PRESERVE_SOURCE_INVALID);
170  P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
171 
172  // leave the default behviour to cpu pointers
173 #if defined INIT_PARAM
174  P(input_location, QUDA_CPU_FIELD_LOCATION);
175  P(output_location, QUDA_CPU_FIELD_LOCATION);
176 #else
177  P(input_location, QUDA_INVALID_FIELD_LOCATION);
178  P(output_location, QUDA_INVALID_FIELD_LOCATION);
179 #endif
180 
181 #if defined INIT_PARAM
182  P(cuda_prec_precondition, QUDA_INVALID_PRECISION);
183 #else
186 #endif
187 
188  P(gamma_basis, QUDA_INVALID_GAMMA_BASIS);
189  P(dirac_order, QUDA_INVALID_DIRAC_ORDER);
190  P(sp_pad, INVALID_INT);
191 
193 
194 #if defined INIT_PARAM
195  P(gcrNkrylov, INVALID_INT);
196 #else
197  if (param->inv_type == QUDA_GCR_INVERTER) {
198  P(gcrNkrylov, INVALID_INT);
199  }
200 #endif
201 
202  // domain decomposition parameters
203  //P(inv_type_sloppy, QUDA_INVALID_INVERTER); // disable since invalid means no preconditioner
204 #if defined INIT_PARAM
205  P(inv_type_precondition, QUDA_INVALID_INVERTER);
206  P(tol_precondition, INVALID_DOUBLE);
207  P(maxiter_precondition, INVALID_INT);
208  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
209  P(schwarz_type, QUDA_ADDITIVE_SCHWARZ); // defaults match previous interface behaviour
210  P(precondition_cycle, 1); // defaults match previous interface behaviour
211 #else
215  P(tol_precondition, INVALID_DOUBLE);
216  P(maxiter_precondition, INVALID_INT);
217  P(verbosity_precondition, QUDA_INVALID_VERBOSITY);
218  P(schwarz_type, QUDA_INVALID_SCHWARZ);
219  P(precondition_cycle, 0);
220  }
221 #endif
222 
223 
224 
225 
226 #ifdef INIT_PARAM
227  P(use_init_guess, QUDA_USE_INIT_GUESS_NO); //set the default to no
228  P(omega, 1.0); // set default to no relaxation
229 #else
230  P(use_init_guess, QUDA_USE_INIT_GUESS_INVALID);
231  P(omega, INVALID_DOUBLE);
232 #endif
233 
234 #ifndef INIT_PARAM
235  if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH) {
236 #endif
237  P(clover_cpu_prec, QUDA_INVALID_PRECISION);
238  P(clover_cuda_prec, QUDA_INVALID_PRECISION);
239  P(clover_cuda_prec_sloppy, QUDA_INVALID_PRECISION);
240 #if defined INIT_PARAM
241  P(clover_cuda_prec_precondition, QUDA_INVALID_PRECISION);
242 #else
245 #endif
246  P(clover_order, QUDA_INVALID_CLOVER_ORDER);
247  P(cl_pad, INVALID_INT);
248 #ifndef INIT_PARAM
249  }
250 #endif
251 
252  P(verbosity, QUDA_INVALID_VERBOSITY);
253 
254 #ifdef INIT_PARAM
255  P(iter, 0);
256  P(spinorGiB, 0.0);
258  P(cloverGiB, 0.0);
259  P(gflops, 0.0);
260  P(secs, 0.0);
261 #elif defined(PRINT_PARAM)
262  P(iter, INVALID_INT);
263  P(spinorGiB, INVALID_DOUBLE);
265  P(cloverGiB, INVALID_DOUBLE);
266  P(gflops, INVALID_DOUBLE);
267  P(secs, INVALID_DOUBLE);
268 #endif
269 
270 
271 #ifdef INIT_PARAM
272  //p(ghostDim[0],0);
273  //p(ghostDim[1],0);
274  //p(ghostDim[2],0);
275  //p(ghostDim[3],0);
276 #endif
277 
278 #ifdef INIT_PARAM
279  P(residual_type, QUDA_L2_RELATIVE_RESIDUAL);
280 #else
281  P(residual_type, QUDA_INVALID_RESIDUAL);
282 #endif
283 
284 #ifdef INIT_PARAM
285  return ret;
286 #endif
287 }
288 
289 
290 // clean up
291 
292 #undef INVALID_INT
293 #undef INVALID_DOUBLE
294 #undef P