QUDA v0.4.0
A library for QCD on GPUs
|
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 #if defined INIT_PARAM 00069 P(cuda_prec_precondition, QUDA_INVALID_PRECISION); 00070 P(reconstruct_precondition, QUDA_RECONSTRUCT_INVALID); 00071 #else 00072 if (param->cuda_prec_precondition == QUDA_INVALID_PRECISION) 00073 param->cuda_prec_precondition = param->cuda_prec_sloppy; 00074 if (param->reconstruct_precondition == QUDA_RECONSTRUCT_INVALID) 00075 param->reconstruct_precondition = param->reconstruct_sloppy; 00076 #endif 00077 00078 P(gauge_fix, QUDA_GAUGE_FIXED_INVALID); 00079 P(ga_pad, INVALID_INT); 00080 00081 #if defined INIT_PARAM 00082 P(packed_size, 0); 00083 P(gaugeGiB, 0.0); 00084 #else 00085 P(packed_size, INVALID_INT); 00086 P(gaugeGiB, INVALID_DOUBLE); 00087 #endif 00088 00089 #if defined INIT_PARAM 00090 P(preserve_gauge, 0); 00091 #else 00092 P(preserve_gauge, INVALID_INT); 00093 #endif 00094 00095 #ifdef INIT_PARAM 00096 return ret; 00097 #endif 00098 } 00099 00100 00101 // define the appropriate function for InvertParam 00102 00103 #if defined INIT_PARAM 00104 QudaInvertParam newQudaInvertParam(void) { 00105 QudaInvertParam ret; 00106 #elif defined CHECK_PARAM 00107 static void checkInvertParam(QudaInvertParam *param) { 00108 #else 00109 void printQudaInvertParam(QudaInvertParam *param) { 00110 printfQuda("QUDA Inverter Parameters:\n"); 00111 #endif 00112 00113 P(dslash_type, QUDA_INVALID_DSLASH); 00114 P(inv_type, QUDA_INVALID_INVERTER); 00115 00116 #if defined INIT_PARAM 00117 P(mass, INVALID_DOUBLE); 00118 P(kappa, INVALID_DOUBLE); 00119 P(m5, INVALID_DOUBLE); 00120 P(Ls, INVALID_INT); 00121 P(mu, INVALID_DOUBLE); 00122 P(twist_flavor, QUDA_TWIST_INVALID); 00123 #else 00124 // asqtad and domain wall use mass parameterization 00125 if (param->dslash_type == QUDA_ASQTAD_DSLASH || param->dslash_type == QUDA_DOMAIN_WALL_DSLASH) { 00126 P(mass, INVALID_DOUBLE); 00127 } else { // Wilson and clover use kappa parameterization 00128 P(kappa, INVALID_DOUBLE); 00129 } 00130 if (param->dslash_type == QUDA_DOMAIN_WALL_DSLASH) { 00131 P(m5, INVALID_DOUBLE); 00132 P(Ls, INVALID_INT); 00133 } 00134 if (param->dslash_type == QUDA_TWISTED_MASS_DSLASH) { 00135 P(mu, INVALID_DOUBLE); 00136 P(twist_flavor, QUDA_TWIST_INVALID); 00137 } 00138 #endif 00139 00140 P(tol, INVALID_DOUBLE); 00141 P(maxiter, INVALID_INT); 00142 P(reliable_delta, INVALID_DOUBLE); 00143 P(solution_type, QUDA_INVALID_SOLUTION); 00144 P(solve_type, QUDA_INVALID_SOLVE); 00145 P(matpc_type, QUDA_MATPC_INVALID); 00146 P(dagger, QUDA_DAG_INVALID); 00147 P(mass_normalization, QUDA_INVALID_NORMALIZATION); 00148 P(preserve_source, QUDA_PRESERVE_SOURCE_INVALID); 00149 P(cpu_prec, QUDA_INVALID_PRECISION); 00150 P(cuda_prec, QUDA_INVALID_PRECISION); 00151 P(cuda_prec_sloppy, QUDA_INVALID_PRECISION); 00152 00153 #if defined INIT_PARAM 00154 P(cuda_prec_precondition, QUDA_INVALID_PRECISION); 00155 #else 00156 if (param->cuda_prec_precondition == QUDA_INVALID_PRECISION) 00157 param->cuda_prec_precondition = param->cuda_prec_sloppy; 00158 #endif 00159 00160 P(gamma_basis, QUDA_INVALID_GAMMA_BASIS); 00161 P(dirac_order, QUDA_INVALID_DIRAC_ORDER); 00162 P(sp_pad, INVALID_INT); 00163 00164 P(tune, QUDA_TUNE_INVALID); 00165 00166 #if defined INIT_PARAM 00167 P(gcrNkrylov, INVALID_INT); 00168 #else 00169 if (param->inv_type == QUDA_GCR_INVERTER) { 00170 P(gcrNkrylov, INVALID_INT); 00171 } 00172 #endif 00173 00174 // domain decomposition parameters 00175 //P(inv_type_sloppy, QUDA_INVALID_INVERTER); // disable since invalid means no preconditioner 00176 #if defined INIT_PARAM 00177 P(inv_type_precondition, QUDA_INVALID_INVERTER); 00178 P(tol_precondition, INVALID_DOUBLE); 00179 P(maxiter_precondition, INVALID_INT); 00180 P(verbosity_precondition, QUDA_INVALID_VERBOSITY); 00181 P(prec_precondition, QUDA_INVALID_PRECISION); 00182 #else 00183 if (param->inv_type_precondition == QUDA_BICGSTAB_INVERTER || 00184 param->inv_type_precondition == QUDA_CG_INVERTER || 00185 param->inv_type_precondition == QUDA_MR_INVERTER) { 00186 P(tol_precondition, INVALID_DOUBLE); 00187 P(maxiter_precondition, INVALID_INT); 00188 P(verbosity_precondition, QUDA_INVALID_VERBOSITY); 00189 P(prec_precondition, QUDA_INVALID_PRECISION); 00190 } 00191 #endif 00192 00193 00194 00195 00196 #ifdef INIT_PARAM 00197 P(use_init_guess, QUDA_USE_INIT_GUESS_NO); //set the default to no 00198 P(omega, 1.0); // set default to no relaxation 00199 #else 00200 P(use_init_guess, QUDA_USE_INIT_GUESS_INVALID); 00201 P(omega, INVALID_DOUBLE); 00202 #endif 00203 00204 #ifndef INIT_PARAM 00205 if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH) { 00206 #endif 00207 P(clover_cpu_prec, QUDA_INVALID_PRECISION); 00208 P(clover_cuda_prec, QUDA_INVALID_PRECISION); 00209 P(clover_cuda_prec_sloppy, QUDA_INVALID_PRECISION); 00210 #if defined INIT_PARAM 00211 P(clover_cuda_prec_precondition, QUDA_INVALID_PRECISION); 00212 #else 00213 if (param->clover_cuda_prec_precondition == QUDA_INVALID_PRECISION) 00214 param->cuda_prec_precondition = param->clover_cuda_prec_sloppy; 00215 #endif 00216 P(clover_order, QUDA_INVALID_CLOVER_ORDER); 00217 P(cl_pad, INVALID_INT); 00218 #ifndef INIT_PARAM 00219 } 00220 #endif 00221 00222 P(verbosity, QUDA_INVALID_VERBOSITY); 00223 00224 #ifdef PRINT_PARAM 00225 P(iter, INVALID_INT); 00226 P(spinorGiB, INVALID_DOUBLE); 00227 if (param->dslash_type == QUDA_CLOVER_WILSON_DSLASH) 00228 P(cloverGiB, INVALID_DOUBLE); 00229 P(gflops, INVALID_DOUBLE); 00230 P(secs, INVALID_DOUBLE); 00231 #endif 00232 00233 00234 #ifdef INIT_PARAM 00235 //p(ghostDim[0],0); 00236 //p(ghostDim[1],0); 00237 //p(ghostDim[2],0); 00238 //p(ghostDim[3],0); 00239 #endif 00240 00241 #ifdef INIT_PARAM 00242 return ret; 00243 #endif 00244 } 00245 00246 00247 // clean up 00248 00249 #undef INVALID_INT 00250 #undef INVALID_DOUBLE 00251 #undef P