QUDA  v1.1.0
A library for QCD on GPUs
misc.cpp
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "quda.h"
4 #include <string.h>
5 #include "invert_quda.h"
6 #include "misc.h"
7 #include <assert.h>
8 #include "util_quda.h"
9 #include <host_utils.h>
10 
12 {
13  const char *ret;
14 
15  switch (type) {
16  case QUDA_SILENT: ret = "silent"; break;
17  case QUDA_SUMMARIZE: ret = "summarize"; break;
18  case QUDA_VERBOSE: ret = "verbose"; break;
19  case QUDA_DEBUG_VERBOSE: ret = "debug"; break;
20  default: fprintf(stderr, "Error: invalid verbosity type %d\n", type); exit(1);
21  }
22 
23  return ret;
24 }
25 
27 {
28  const char *ret;
29 
30  switch (prec) {
31  case QUDA_DOUBLE_PRECISION: ret = "double"; break;
32  case QUDA_SINGLE_PRECISION: ret = "single"; break;
33  case QUDA_HALF_PRECISION: ret = "half"; break;
34  case QUDA_QUARTER_PRECISION: ret = "quarter"; break;
35  default: ret = "unknown"; break;
36  }
37 
38  return ret;
39 }
40 
41 const char *get_unitarization_str(bool svd_only)
42 {
43  const char *ret;
44 
45  if (svd_only) {
46  ret = "SVD";
47  } else {
48  ret = "Cayley-Hamilton/SVD";
49  }
50 
51  return ret;
52 }
53 
55 {
56  const char *ret;
57 
58  switch (order) {
59  case QUDA_QDP_GAUGE_ORDER: ret = "qdp"; break;
60  case QUDA_MILC_GAUGE_ORDER: ret = "milc"; break;
61  case QUDA_CPS_WILSON_GAUGE_ORDER: ret = "cps_wilson"; break;
62  default: ret = "unknown"; break;
63  }
64 
65  return ret;
66 }
67 
69 {
70  const char *ret;
71 
72  switch (recon) {
73  case QUDA_RECONSTRUCT_13: ret = "13"; break;
74  case QUDA_RECONSTRUCT_12: ret = "12"; break;
75  case QUDA_RECONSTRUCT_9: ret = "9"; break;
76  case QUDA_RECONSTRUCT_8: ret = "8"; break;
77  case QUDA_RECONSTRUCT_NO: ret = "18"; break;
78  default: ret = "unknown"; break;
79  }
80 
81  return ret;
82 }
83 
84 const char *get_test_type(int t)
85 {
86  const char *ret;
87 
88  switch (t) {
89  case 0: ret = "even"; break;
90  case 1: ret = "odd"; break;
91  case 2: ret = "full"; break;
92  case 3: ret = "mcg_even"; break;
93  case 4: ret = "mcg_odd"; break;
94  case 5: ret = "mcg_full"; break;
95  default: ret = "unknown"; break;
96  }
97 
98  return ret;
99 }
100 
101 const char *get_staggered_test_type(int t)
102 {
103  const char *ret;
104  switch (t) {
105  case 0: ret = "full"; break;
106  case 1: ret = "full_ee_prec"; break;
107  case 2: ret = "full_oo_prec"; break;
108  case 3: ret = "even"; break;
109  case 4: ret = "odd"; break;
110  case 5: ret = "mcg_even"; break;
111  case 6: ret = "mcg_odd"; break;
112  default: ret = "unknown"; break;
113  }
114 
115  return ret;
116 }
117 
119 {
120  const char *ret;
121 
122  switch (type) {
123  case QUDA_WILSON_DSLASH: ret = "wilson"; break;
124  case QUDA_CLOVER_WILSON_DSLASH: ret = "clover"; break;
125  case QUDA_CLOVER_HASENBUSCH_TWIST_DSLASH: ret = "clover-hasenbusch-twist"; break;
126  case QUDA_TWISTED_MASS_DSLASH: ret = "twisted-mass"; break;
127  case QUDA_TWISTED_CLOVER_DSLASH: ret = "twisted-clover"; break;
128  case QUDA_STAGGERED_DSLASH: ret = "staggered"; break;
129  case QUDA_ASQTAD_DSLASH: ret = "asqtad"; break;
130  case QUDA_DOMAIN_WALL_DSLASH: ret = "domain-wall"; break;
131  case QUDA_DOMAIN_WALL_4D_DSLASH: ret = "domain_wall_4d"; break;
132  case QUDA_MOBIUS_DWF_DSLASH: ret = "mobius"; break;
133  case QUDA_MOBIUS_DWF_EOFA_DSLASH: ret = "mobius-eofa"; break;
134  case QUDA_LAPLACE_DSLASH: ret = "laplace"; break;
135  default: ret = "unknown"; break;
136  }
137 
138  return ret;
139 }
140 
142 {
143  const char *ret;
144 
145  switch (type) {
146  case QUDA_CONTRACT_TYPE_OPEN: ret = "open"; break;
147  case QUDA_CONTRACT_TYPE_DR: ret = "Degrand-Rossi"; break;
148  default: ret = "unknown"; break;
149  }
150 
151  return ret;
152 }
153 
155 {
156  const char *ret;
157 
158  switch (type) {
159  case QUDA_SPECTRUM_SR_EIG: ret = "SR"; break;
160  case QUDA_SPECTRUM_LR_EIG: ret = "LR"; break;
161  case QUDA_SPECTRUM_SM_EIG: ret = "SM"; break;
162  case QUDA_SPECTRUM_LM_EIG: ret = "LM"; break;
163  case QUDA_SPECTRUM_SI_EIG: ret = "SI"; break;
164  case QUDA_SPECTRUM_LI_EIG: ret = "LI"; break;
165  default: ret = "unknown eigenspectrum"; break;
166  }
167 
168  return ret;
169 }
170 
171 const char *get_eig_type_str(QudaEigType type)
172 {
173  const char *ret;
174 
175  switch (type) {
176  case QUDA_EIG_TR_LANCZOS: ret = "trlm"; break;
177  case QUDA_EIG_BLK_TR_LANCZOS: ret = "blktrlm"; break;
178  case QUDA_EIG_IR_ARNOLDI: ret = "iram"; break;
179  case QUDA_EIG_BLK_IR_ARNOLDI: ret = "blkiram"; break;
180  default: ret = "unknown eigensolver"; break;
181  }
182 
183  return ret;
184 }
185 
187 {
188  const char *s;
189 
190  switch (type) {
191  case QUDA_KAPPA_NORMALIZATION: s = "kappa"; break;
192  case QUDA_MASS_NORMALIZATION: s = "mass"; break;
193  case QUDA_ASYMMETRIC_MASS_NORMALIZATION: s = "asym-mass"; break;
194  default: fprintf(stderr, "Error: invalid mass normalization\n"); exit(1);
195  }
196 
197  return s;
198 }
199 
200 const char *get_matpc_str(QudaMatPCType type)
201 {
202  const char *ret;
203 
204  switch (type) {
205  case QUDA_MATPC_EVEN_EVEN: ret = "even-even"; break;
206  case QUDA_MATPC_ODD_ODD: ret = "odd-odd"; break;
207  case QUDA_MATPC_EVEN_EVEN_ASYMMETRIC: ret = "even-even-asym"; break;
208  case QUDA_MATPC_ODD_ODD_ASYMMETRIC: ret = "odd-odd-asym"; break;
209  default: fprintf(stderr, "Error: invalid matpc type %d\n", type); exit(1);
210  }
211 
212  return ret;
213 }
214 
216 {
217  const char *ret;
218 
219  switch (type) {
220  case QUDA_MAT_SOLUTION: ret = "mat"; break;
221  case QUDA_MATDAG_MAT_SOLUTION: ret = "mat-dag-mat"; break;
222  case QUDA_MATPC_SOLUTION: ret = "mat-pc"; break;
223  case QUDA_MATPCDAG_MATPC_SOLUTION: ret = "mat-pc-dag-mat-pc"; break;
224  case QUDA_MATPCDAG_MATPC_SHIFT_SOLUTION: ret = "mat-pc-dag-mat-pc-shift"; break;
225  default: fprintf(stderr, "Error: invalid solution type %d\n", type); exit(1);
226  }
227 
228  return ret;
229 }
230 
231 const char *get_solve_str(QudaSolveType type)
232 {
233  const char *ret;
234 
235  switch (type) {
236  case QUDA_DIRECT_SOLVE: ret = "direct"; break;
237  case QUDA_DIRECT_PC_SOLVE: ret = "direct-pc"; break;
238  case QUDA_NORMOP_SOLVE: ret = "normop"; break;
239  case QUDA_NORMOP_PC_SOLVE: ret = "normop-pc"; break;
240  case QUDA_NORMERR_SOLVE: ret = "normerr"; break;
241  case QUDA_NORMERR_PC_SOLVE: ret = "normerr-pc"; break;
242  default: fprintf(stderr, "Error: invalid solve type %d\n", type); exit(1);
243  }
244 
245  return ret;
246 }
247 
249 {
250  const char *ret;
251 
252  switch (type) {
253  case QUDA_TWIST_SINGLET: ret = "singlet"; break;
254  case QUDA_TWIST_DEG_DOUBLET: ret = "deg-doublet"; break;
255  case QUDA_TWIST_NONDEG_DOUBLET: ret = "nondeg-doublet"; break;
256  case QUDA_TWIST_NO: ret = "no"; break;
257  default: ret = "unknown"; break;
258  }
259 
260  return ret;
261 }
262 
264 {
265  const char *ret;
266 
267  switch (type) {
268  case QUDA_CG_INVERTER: ret = "cg"; break;
269  case QUDA_BICGSTAB_INVERTER: ret = "bicgstab"; break;
270  case QUDA_GCR_INVERTER: ret = "gcr"; break;
271  case QUDA_PCG_INVERTER: ret = "pcg"; break;
272  case QUDA_MPCG_INVERTER: ret = "mpcg"; break;
273  case QUDA_MPBICGSTAB_INVERTER: ret = "mpbicgstab"; break;
274  case QUDA_MR_INVERTER: ret = "mr"; break;
275  case QUDA_SD_INVERTER: ret = "sd"; break;
276  case QUDA_EIGCG_INVERTER: ret = "eigcg"; break;
277  case QUDA_INC_EIGCG_INVERTER: ret = "inc-eigcg"; break;
278  case QUDA_GMRESDR_INVERTER: ret = "gmresdr"; break;
279  case QUDA_GMRESDR_PROJ_INVERTER: ret = "gmresdr-proj"; break;
280  case QUDA_GMRESDR_SH_INVERTER: ret = "gmresdr-sh"; break;
281  case QUDA_FGMRESDR_INVERTER: ret = "fgmresdr"; break;
282  case QUDA_MG_INVERTER: ret = "mg"; break;
283  case QUDA_BICGSTABL_INVERTER: ret = "bicgstab-l"; break;
284  case QUDA_CGNE_INVERTER: ret = "cgne"; break;
285  case QUDA_CGNR_INVERTER: ret = "cgnr"; break;
286  case QUDA_CG3_INVERTER: ret = "cg3"; break;
287  case QUDA_CG3NE_INVERTER: ret = "cg3ne"; break;
288  case QUDA_CG3NR_INVERTER: ret = "cg3nr"; break;
289  case QUDA_CA_CG_INVERTER: ret = "ca-cg"; break;
290  case QUDA_CA_CGNE_INVERTER: ret = "ca-cgne"; break;
291  case QUDA_CA_CGNR_INVERTER: ret = "ca-cgnr"; break;
292  case QUDA_CA_GCR_INVERTER: ret = "ca-gcr"; break;
293  default:
294  ret = "unknown";
295  errorQuda("Error: invalid solver type %d\n", type);
296  break;
297  }
298 
299  return ret;
300 }
301 
302 const char *get_quda_ver_str()
303 {
304  static char vstr[32];
305  int major_num = QUDA_VERSION_MAJOR;
306  int minor_num = QUDA_VERSION_MINOR;
307  int ext_num = QUDA_VERSION_SUBMINOR;
308  sprintf(vstr, "%1d.%1d.%1d", major_num, minor_num, ext_num);
309  return vstr;
310 }
311 
313 {
314  const char *s;
315 
316  switch (type) {
317  case QUDA_CPU_FIELD_LOCATION: s = "cpu"; break;
318  case QUDA_CUDA_FIELD_LOCATION: s = "cuda"; break;
319  default: fprintf(stderr, "Error: invalid location\n"); exit(1);
320  }
321 
322  return s;
323 }
324 
326 {
327  const char *s;
328 
329  switch (type) {
330  case QUDA_MEMORY_DEVICE: s = "device"; break;
331  case QUDA_MEMORY_PINNED: s = "pinned"; break;
332  case QUDA_MEMORY_MAPPED: s = "mapped"; break;
333  default: fprintf(stderr, "Error: invalid memory type\n"); exit(1);
334  }
335 
336  return s;
337 }
QudaPrecision prec
enum QudaSolveType_s QudaSolveType
enum QudaPrecision_s QudaPrecision
@ QUDA_WILSON_DSLASH
Definition: enum_quda.h:90
@ QUDA_TWISTED_CLOVER_DSLASH
Definition: enum_quda.h:100
@ QUDA_STAGGERED_DSLASH
Definition: enum_quda.h:97
@ QUDA_MOBIUS_DWF_DSLASH
Definition: enum_quda.h:95
@ QUDA_CLOVER_WILSON_DSLASH
Definition: enum_quda.h:91
@ QUDA_TWISTED_MASS_DSLASH
Definition: enum_quda.h:99
@ QUDA_DOMAIN_WALL_DSLASH
Definition: enum_quda.h:93
@ QUDA_ASQTAD_DSLASH
Definition: enum_quda.h:98
@ QUDA_MOBIUS_DWF_EOFA_DSLASH
Definition: enum_quda.h:96
@ QUDA_LAPLACE_DSLASH
Definition: enum_quda.h:101
@ QUDA_CLOVER_HASENBUSCH_TWIST_DSLASH
Definition: enum_quda.h:92
@ QUDA_DOMAIN_WALL_4D_DSLASH
Definition: enum_quda.h:94
@ QUDA_CUDA_FIELD_LOCATION
Definition: enum_quda.h:326
@ QUDA_CPU_FIELD_LOCATION
Definition: enum_quda.h:325
enum QudaTwistFlavorType_s QudaTwistFlavorType
@ QUDA_KAPPA_NORMALIZATION
Definition: enum_quda.h:226
@ QUDA_ASYMMETRIC_MASS_NORMALIZATION
Definition: enum_quda.h:228
@ QUDA_MASS_NORMALIZATION
Definition: enum_quda.h:227
@ QUDA_SILENT
Definition: enum_quda.h:265
@ QUDA_DEBUG_VERBOSE
Definition: enum_quda.h:268
@ QUDA_SUMMARIZE
Definition: enum_quda.h:266
@ QUDA_VERBOSE
Definition: enum_quda.h:267
enum QudaGaugeFieldOrder_s QudaGaugeFieldOrder
@ QUDA_RECONSTRUCT_NO
Definition: enum_quda.h:70
@ QUDA_RECONSTRUCT_12
Definition: enum_quda.h:71
@ QUDA_RECONSTRUCT_13
Definition: enum_quda.h:74
@ QUDA_RECONSTRUCT_8
Definition: enum_quda.h:72
@ QUDA_RECONSTRUCT_9
Definition: enum_quda.h:73
@ QUDA_MEMORY_MAPPED
Definition: enum_quda.h:15
@ QUDA_MEMORY_PINNED
Definition: enum_quda.h:14
@ QUDA_MEMORY_DEVICE
Definition: enum_quda.h:13
enum QudaDslashType_s QudaDslashType
enum QudaSolutionType_s QudaSolutionType
enum QudaEigSpectrumType_s QudaEigSpectrumType
enum QudaInverterType_s QudaInverterType
@ QUDA_EIG_BLK_IR_ARNOLDI
Definition: enum_quda.h:140
@ QUDA_EIG_IR_ARNOLDI
Definition: enum_quda.h:139
@ QUDA_EIG_BLK_TR_LANCZOS
Definition: enum_quda.h:138
@ QUDA_EIG_TR_LANCZOS
Definition: enum_quda.h:137
enum QudaFieldLocation_s QudaFieldLocation
enum QudaMassNormalization_s QudaMassNormalization
enum QudaEigType_s QudaEigType
@ QUDA_MATPC_ODD_ODD_ASYMMETRIC
Definition: enum_quda.h:219
@ QUDA_MATPC_EVEN_EVEN_ASYMMETRIC
Definition: enum_quda.h:218
@ QUDA_MATPC_ODD_ODD
Definition: enum_quda.h:217
@ QUDA_MATPC_EVEN_EVEN
Definition: enum_quda.h:216
enum QudaMatPCType_s QudaMatPCType
@ QUDA_CA_CGNE_INVERTER
Definition: enum_quda.h:130
@ QUDA_GCR_INVERTER
Definition: enum_quda.h:109
@ QUDA_CGNE_INVERTER
Definition: enum_quda.h:124
@ QUDA_GMRESDR_PROJ_INVERTER
Definition: enum_quda.h:119
@ QUDA_INC_EIGCG_INVERTER
Definition: enum_quda.h:117
@ QUDA_FGMRESDR_INVERTER
Definition: enum_quda.h:121
@ QUDA_MR_INVERTER
Definition: enum_quda.h:110
@ QUDA_CA_CG_INVERTER
Definition: enum_quda.h:129
@ QUDA_MPCG_INVERTER
Definition: enum_quda.h:115
@ QUDA_CG3NE_INVERTER
Definition: enum_quda.h:127
@ QUDA_BICGSTABL_INVERTER
Definition: enum_quda.h:123
@ QUDA_CGNR_INVERTER
Definition: enum_quda.h:125
@ QUDA_GMRESDR_SH_INVERTER
Definition: enum_quda.h:120
@ QUDA_CG3NR_INVERTER
Definition: enum_quda.h:128
@ QUDA_PCG_INVERTER
Definition: enum_quda.h:114
@ QUDA_CA_GCR_INVERTER
Definition: enum_quda.h:132
@ QUDA_SD_INVERTER
Definition: enum_quda.h:112
@ QUDA_MPBICGSTAB_INVERTER
Definition: enum_quda.h:111
@ QUDA_CG_INVERTER
Definition: enum_quda.h:107
@ QUDA_CA_CGNR_INVERTER
Definition: enum_quda.h:131
@ QUDA_CG3_INVERTER
Definition: enum_quda.h:126
@ QUDA_EIGCG_INVERTER
Definition: enum_quda.h:116
@ QUDA_MG_INVERTER
Definition: enum_quda.h:122
@ QUDA_BICGSTAB_INVERTER
Definition: enum_quda.h:108
@ QUDA_GMRESDR_INVERTER
Definition: enum_quda.h:118
enum QudaMemoryType_s QudaMemoryType
enum QudaReconstructType_s QudaReconstructType
@ QUDA_MATPCDAG_MATPC_SHIFT_SOLUTION
Definition: enum_quda.h:162
@ QUDA_MATPC_SOLUTION
Definition: enum_quda.h:159
@ QUDA_MATDAG_MAT_SOLUTION
Definition: enum_quda.h:158
@ QUDA_MATPCDAG_MATPC_SOLUTION
Definition: enum_quda.h:161
@ QUDA_MAT_SOLUTION
Definition: enum_quda.h:157
@ QUDA_DOUBLE_PRECISION
Definition: enum_quda.h:65
@ QUDA_SINGLE_PRECISION
Definition: enum_quda.h:64
@ QUDA_QUARTER_PRECISION
Definition: enum_quda.h:62
@ QUDA_HALF_PRECISION
Definition: enum_quda.h:63
@ QUDA_QDP_GAUGE_ORDER
Definition: enum_quda.h:44
@ QUDA_CPS_WILSON_GAUGE_ORDER
Definition: enum_quda.h:46
@ QUDA_MILC_GAUGE_ORDER
Definition: enum_quda.h:47
enum QudaContractType_s QudaContractType
@ QUDA_SPECTRUM_LM_EIG
Definition: enum_quda.h:147
@ QUDA_SPECTRUM_SM_EIG
Definition: enum_quda.h:148
@ QUDA_SPECTRUM_LR_EIG
Definition: enum_quda.h:149
@ QUDA_SPECTRUM_SR_EIG
Definition: enum_quda.h:150
@ QUDA_SPECTRUM_SI_EIG
Definition: enum_quda.h:152
@ QUDA_SPECTRUM_LI_EIG
Definition: enum_quda.h:151
enum QudaVerbosity_s QudaVerbosity
@ QUDA_TWIST_SINGLET
Definition: enum_quda.h:400
@ QUDA_TWIST_NO
Definition: enum_quda.h:403
@ QUDA_TWIST_NONDEG_DOUBLET
Definition: enum_quda.h:401
@ QUDA_TWIST_DEG_DOUBLET
Definition: enum_quda.h:402
@ QUDA_DIRECT_SOLVE
Definition: enum_quda.h:167
@ QUDA_NORMERR_SOLVE
Definition: enum_quda.h:171
@ QUDA_NORMERR_PC_SOLVE
Definition: enum_quda.h:172
@ QUDA_NORMOP_PC_SOLVE
Definition: enum_quda.h:170
@ QUDA_DIRECT_PC_SOLVE
Definition: enum_quda.h:169
@ QUDA_NORMOP_SOLVE
Definition: enum_quda.h:168
@ QUDA_CONTRACT_TYPE_OPEN
Definition: enum_quda.h:523
@ QUDA_CONTRACT_TYPE_DR
Definition: enum_quda.h:524
const char * get_quda_ver_str()
Definition: misc.cpp:302
const char * get_ritz_location_str(QudaFieldLocation type)
Definition: misc.cpp:312
const char * get_test_type(int t)
Definition: misc.cpp:84
const char * get_matpc_str(QudaMatPCType type)
Definition: misc.cpp:200
const char * get_prec_str(QudaPrecision prec)
Definition: misc.cpp:26
const char * get_solve_str(QudaSolveType type)
Definition: misc.cpp:231
const char * get_solution_str(QudaSolutionType type)
Definition: misc.cpp:215
const char * get_flavor_str(QudaTwistFlavorType type)
Definition: misc.cpp:248
const char * get_eig_spectrum_str(QudaEigSpectrumType type)
Definition: misc.cpp:154
const char * get_dslash_str(QudaDslashType type)
Definition: misc.cpp:118
const char * get_gauge_order_str(QudaGaugeFieldOrder order)
Definition: misc.cpp:54
const char * get_contract_str(QudaContractType type)
Definition: misc.cpp:141
const char * get_solver_str(QudaInverterType type)
Definition: misc.cpp:263
const char * get_eig_type_str(QudaEigType type)
Definition: misc.cpp:171
const char * get_memory_type_str(QudaMemoryType type)
Definition: misc.cpp:325
const char * get_verbosity_str(QudaVerbosity type)
Definition: misc.cpp:11
const char * get_mass_normalization_str(QudaMassNormalization type)
Definition: misc.cpp:186
const char * get_staggered_test_type(int t)
Definition: misc.cpp:101
const char * get_unitarization_str(bool svd_only)
Definition: misc.cpp:41
const char * get_recon_str(QudaReconstructType recon)
Definition: misc.cpp:68
Main header file for the QUDA library.
#define QUDA_VERSION_SUBMINOR
Definition: quda_constants.h:3
#define QUDA_VERSION_MAJOR
Definition: quda_constants.h:1
#define QUDA_VERSION_MINOR
Definition: quda_constants.h:2
#define errorQuda(...)
Definition: util_quda.h:120