QUDA v0.3.2
A library for QCD on GPUs

quda/lib/check_params.h

Go to the documentation of this file.
00001 // check_params.h
00002 
00003 // This file defines functions to either initialize, check, or print
00004 // the QUDA gauge and inverter parameters.  It gets included in
00005 // interface_quda.cpp, after either INIT_PARAM, CHECK_PARAM, or
00006 // PRINT_PARAM is defined.
00007 //
00008 // If you're reading this file because it was mentioned in a "QUDA
00009 // error" message, it probably means that you forgot to set one of the
00010 // gauge or inverter parameters in your application before calling
00011 // loadGaugeQuda() or invertQuda().
00012 
00013 #include <float.h>
00014 #define INVALID_INT QUDA_INVALID_ENUM
00015 #define INVALID_DOUBLE DBL_MIN
00016 
00017 // define macro to carry out the appropriate action for a given parameter
00018 
00019 #if defined INIT_PARAM
00020 #define P(x, val) ret.x = val
00021 #elif defined CHECK_PARAM
00022 #define P(x, val) if (param->x == val) errorQuda("Parameter " #x " undefined")
00023 #elif defined PRINT_PARAM
00024 #define P(x, val) \
00025   printfQuda((val == INVALID_DOUBLE) ? #x " = %g\n" : #x " = %d\n", param->x)
00026 #else
00027 #error INIT_PARAM, CHECK_PARAM, and PRINT_PARAM all undefined in check_params.h
00028 #endif
00029 
00030 
00031 // define the appropriate function for GaugeParam
00032 
00033 #if defined INIT_PARAM
00034 QudaGaugeParam newQudaGaugeParam(void) {
00035   QudaGaugeParam ret;
00036 #elif defined CHECK_PARAM
00037 static void checkGaugeParam(QudaGaugeParam *param) {
00038 #else
00039 void printQudaGaugeParam(QudaGaugeParam *param) {
00040   printfQuda("QUDA Gauge Parameters:\n");
00041 #endif
00042 
00043   P(X[0], INVALID_INT);
00044   P(X[1], INVALID_INT);
00045   P(X[2], INVALID_INT);
00046   P(X[3], INVALID_INT);
00047 
00048 #if defined INIT_PARAM
00049   P(anisotropy, INVALID_DOUBLE);
00050   P(tadpole_coeff, INVALID_DOUBLE);
00051 #else
00052   if (param->type == QUDA_WILSON_LINKS) {
00053     P(anisotropy, INVALID_DOUBLE);
00054   } else if (param->type == QUDA_ASQTAD_FAT_LINKS ||
00055              param->type == QUDA_ASQTAD_LONG_LINKS) {
00056     P(tadpole_coeff, INVALID_DOUBLE);
00057   }
00058 #endif
00059 
00060   P(type, QUDA_INVALID_LINKS);
00061   P(gauge_order, QUDA_INVALID_GAUGE_ORDER);
00062   P(t_boundary, QUDA_INVALID_T_BOUNDARY);
00063   P(cpu_prec, QUDA_INVALID_PRECISION);
00064   P(cuda_prec, QUDA_INVALID_PRECISION);
00065   P(reconstruct, QUDA_RECONSTRUCT_INVALID);
00066   P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
00067   P(reconstruct_sloppy, QUDA_RECONSTRUCT_INVALID);
00068   P(gauge_fix, QUDA_GAUGE_FIXED_INVALID);
00069   P(ga_pad, INVALID_INT);
00070 
00071 #if defined INIT_PARAM
00072   P(packed_size, 0);
00073   P(gaugeGiB, 0.0);
00074 #elif defined PRINT_PARAM
00075   P(packed_size, INVALID_INT);
00076   P(gaugeGiB, INVALID_DOUBLE);
00077 #endif
00078 
00079 #ifdef INIT_PARAM
00080   return ret;
00081 #endif
00082 }
00083 
00084 
00085 // define the appropriate function for InvertParam
00086 
00087 #if defined INIT_PARAM
00088 QudaInvertParam newQudaInvertParam(void) {
00089   QudaInvertParam ret;
00090 #elif defined CHECK_PARAM
00091 static void checkInvertParam(QudaInvertParam *param) {
00092 #else
00093 void printQudaInvertParam(QudaInvertParam *param) {
00094   printfQuda("QUDA Inverter Parameters:\n");
00095 #endif
00096 
00097   P(dslash_type, QUDA_INVALID_DSLASH);
00098   P(inv_type, QUDA_INVALID_INVERTER);
00099 
00100 #if defined INIT_PARAM
00101   P(mass, INVALID_DOUBLE);
00102   P(kappa, INVALID_DOUBLE);
00103   P(m5, INVALID_DOUBLE);
00104   P(Ls, INVALID_INT);
00105   P(mu, INVALID_DOUBLE);
00106   P(twist_flavor, QUDA_TWIST_INVALID);
00107 #else
00108   // asqtad and domain wall use mass parameterization
00109   if (param->dslash_type == QUDA_ASQTAD_DSLASH || param->dslash_type == QUDA_DOMAIN_WALL_DSLASH) {
00110     P(mass, INVALID_DOUBLE);
00111   } else { // Wilson and clover use kappa parameterization
00112     P(kappa, INVALID_DOUBLE);
00113   }
00114   if (param->dslash_type == QUDA_DOMAIN_WALL_DSLASH) {
00115     P(m5, INVALID_DOUBLE);
00116     P(Ls, INVALID_INT);
00117   }
00118   if (param->dslash_type == QUDA_TWISTED_MASS_DSLASH) {
00119     P(mu, INVALID_DOUBLE);
00120     P(twist_flavor, QUDA_TWIST_INVALID);
00121   }
00122 #endif
00123 
00124   P(tol, INVALID_DOUBLE);
00125   P(maxiter, INVALID_INT);
00126   P(reliable_delta, INVALID_DOUBLE);
00127   P(solution_type, QUDA_INVALID_SOLUTION);
00128   P(solve_type, QUDA_INVALID_SOLVE);
00129   P(matpc_type, QUDA_MATPC_INVALID);
00130   P(dagger, QUDA_DAG_INVALID);
00131   P(mass_normalization, QUDA_INVALID_NORMALIZATION);
00132   P(preserve_source, QUDA_PRESERVE_SOURCE_INVALID);
00133   P(cpu_prec, QUDA_INVALID_PRECISION);
00134   P(cuda_prec, QUDA_INVALID_PRECISION);
00135   P(cuda_prec_sloppy, QUDA_INVALID_PRECISION);
00136   P(dirac_order, QUDA_INVALID_DIRAC_ORDER);
00137   P(sp_pad, INVALID_INT);
00138 
00139 #ifndef INIT_PARAM
00140   if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH) {
00141 #endif
00142     P(clover_cpu_prec, QUDA_INVALID_PRECISION);
00143     P(clover_cuda_prec, QUDA_INVALID_PRECISION);
00144     P(clover_cuda_prec_sloppy, QUDA_INVALID_PRECISION);
00145     P(clover_order, QUDA_INVALID_CLOVER_ORDER);
00146     P(cl_pad, INVALID_INT);
00147 #ifndef INIT_PARAM
00148   }
00149 #endif
00150 
00151   P(verbosity, QUDA_INVALID_VERBOSITY);
00152 
00153 #ifdef PRINT_PARAM
00154   P(iter, INVALID_INT);
00155   P(spinorGiB, INVALID_DOUBLE);
00156   if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH)
00157     P(cloverGiB, INVALID_DOUBLE);
00158   P(gflops, INVALID_DOUBLE);
00159   P(secs, INVALID_DOUBLE);
00160 #endif
00161 
00162 #ifdef INIT_PARAM
00163   return ret;
00164 #endif
00165 }
00166 
00167 
00168 // clean up
00169 
00170 #undef INVALID_INT
00171 #undef INVALID_DOUBLE
00172 #undef P
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines