-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathstaggered_invert_test.cpp
593 lines (472 loc) · 19.1 KB
/
staggered_invert_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <test_util.h>
#include <dslash_util.h>
#include <blas_reference.h>
#include <staggered_dslash_reference.h>
#include <quda.h>
#include <string.h>
#include "misc.h"
#include <gauge_field.h>
#include <blas_quda.h>
#if defined(QMP_COMMS)
#include <qmp.h>
#elif defined(MPI_COMMS)
#include <mpi.h>
#endif
#define MAX(a,b) ((a)>(b)?(a):(b))
#define mySpinorSiteSize 6
extern void usage(char** argv);
void *qdp_fatlink[4];
void *qdp_longlink[4];
void *fatlink;
void *longlink;
#ifdef MULTI_GPU
void** ghost_fatlink, **ghost_longlink;
#endif
extern int device;
extern QudaReconstructType link_recon;
extern QudaPrecision prec;
QudaPrecision cpu_prec = QUDA_DOUBLE_PRECISION;
extern QudaReconstructType link_recon_sloppy;
extern QudaPrecision prec_sloppy;
cpuColorSpinorField* in;
cpuColorSpinorField* out;
cpuColorSpinorField* ref;
cpuColorSpinorField* tmp;
cpuGaugeField *cpuFat = NULL;
cpuGaugeField *cpuLong = NULL;
extern double tol; // tolerance for inverter
extern double tol_hq; // heavy-quark tolerance for inverter
extern int test_type;
extern int xdim;
extern int ydim;
extern int zdim;
extern int tdim;
extern int gridsize_from_cmdline[];
extern int Nsrc; // number of spinors to apply to simultaneously
extern int niter;
// Dirac operator type
extern QudaDslashType dslash_type;
extern QudaInverterType inv_type;
extern double mass; // the mass of the Dirac operator
extern int pipeline; // length of pipeline for fused operations in GCR or BiCGstab-l
extern int solution_accumulator_pipeline; // length of pipeline for fused solution update from the direction vectors
extern QudaSolveType solve_type;
static void end();
template<typename Float>
void constructSpinorField(Float *res) {
for(int src=0; src<Nsrc; src++) {
for(int i = 0; i < Vh; i++) {
for (int s = 0; s < 1; s++) {
for (int m = 0; m < 3; m++) {
res[(src*Vh + i)*(1*3*2) + s*(3*2) + m*(2) + 0] = rand() / (Float)RAND_MAX;
res[(src*Vh + i)*(1*3*2) + s*(3*2) + m*(2) + 1] = rand() / (Float)RAND_MAX;
}
}
}
}
}
static void
set_params(QudaGaugeParam* gaugeParam, QudaInvertParam* inv_param,
int X1, int X2, int X3, int X4,
QudaPrecision cpu_prec, QudaPrecision prec, QudaPrecision prec_sloppy,
QudaReconstructType link_recon, QudaReconstructType link_recon_sloppy,
double mass, double tol, double reliable_delta,
double tadpole_coeff
)
{
gaugeParam->X[0] = X1;
gaugeParam->X[1] = X2;
gaugeParam->X[2] = X3;
gaugeParam->X[3] = X4;
gaugeParam->cpu_prec = cpu_prec;
gaugeParam->cuda_prec = prec;
gaugeParam->reconstruct = link_recon;
gaugeParam->cuda_prec_sloppy = prec_sloppy;
gaugeParam->reconstruct_sloppy = link_recon_sloppy;
gaugeParam->gauge_fix = QUDA_GAUGE_FIXED_NO;
gaugeParam->anisotropy = 1.0;
gaugeParam->tadpole_coeff = tadpole_coeff;
if (dslash_type != QUDA_ASQTAD_DSLASH && dslash_type != QUDA_STAGGERED_DSLASH && dslash_type != QUDA_LAPLACE_DSLASH)
dslash_type = QUDA_ASQTAD_DSLASH;
gaugeParam->scale = dslash_type != QUDA_ASQTAD_DSLASH ? 1.0 : -1.0/(24.0*tadpole_coeff*tadpole_coeff);
gaugeParam->t_boundary = QUDA_ANTI_PERIODIC_T;
gaugeParam->gauge_order = QUDA_MILC_GAUGE_ORDER;
gaugeParam->ga_pad = X1*X2*X3/2;
inv_param->verbosity = QUDA_VERBOSE;
inv_param->mass = mass;
inv_param->kappa = 1.0/(8.0 + mass); // for Laplace operator
// outer solver parameters
inv_param->inv_type = inv_type;
inv_param->tol = tol;
inv_param->tol_restart = 1e-3; //now theoretical background for this parameter...
inv_param->maxiter = niter;
inv_param->reliable_delta = 1e-1;
inv_param->use_sloppy_partial_accumulator = false;
inv_param->solution_accumulator_pipeline = solution_accumulator_pipeline;
inv_param->pipeline = pipeline;
inv_param->Ls = Nsrc;
if(tol_hq == 0 && tol == 0){
errorQuda("qudaInvert: requesting zero residual\n");
exit(1);
}
// require both L2 relative and heavy quark residual to determine convergence
inv_param->residual_type = static_cast<QudaResidualType_s>(0);
inv_param->residual_type = (tol != 0) ? static_cast<QudaResidualType_s> ( inv_param->residual_type | QUDA_L2_RELATIVE_RESIDUAL) : inv_param->residual_type;
inv_param->residual_type = (tol_hq != 0) ? static_cast<QudaResidualType_s> (inv_param->residual_type | QUDA_HEAVY_QUARK_RESIDUAL) : inv_param->residual_type;
inv_param->tol_hq = tol_hq; // specify a tolerance for the residual for heavy quark residual
inv_param->Nsteps = 2;
//inv_param->inv_type = QUDA_GCR_INVERTER;
//inv_param->gcrNkrylov = 10;
// domain decomposition preconditioner parameters
inv_param->inv_type_precondition = QUDA_SD_INVERTER;
inv_param->tol_precondition = 1e-1;
inv_param->maxiter_precondition = 10;
inv_param->verbosity_precondition = QUDA_SILENT;
inv_param->cuda_prec_precondition = inv_param->cuda_prec_sloppy;
inv_param->solution_type = dslash_type == QUDA_LAPLACE_DSLASH ? QUDA_MAT_SOLUTION : QUDA_MATPCDAG_MATPC_SOLUTION;
inv_param->solve_type = dslash_type == QUDA_LAPLACE_DSLASH ? solve_type : QUDA_NORMOP_PC_SOLVE;
inv_param->matpc_type = QUDA_MATPC_EVEN_EVEN;
inv_param->dagger = QUDA_DAG_NO;
inv_param->mass_normalization = QUDA_MASS_NORMALIZATION;
inv_param->cpu_prec = cpu_prec;
inv_param->cuda_prec = prec;
inv_param->cuda_prec_sloppy = prec_sloppy;
inv_param->preserve_source = QUDA_PRESERVE_SOURCE_YES;
inv_param->gamma_basis = QUDA_DEGRAND_ROSSI_GAMMA_BASIS; // this is meaningless, but must be thus set
inv_param->dirac_order = QUDA_DIRAC_ORDER;
inv_param->dslash_type = dslash_type;
inv_param->sp_pad = X1*X2*X3/2;
inv_param->use_init_guess = QUDA_USE_INIT_GUESS_YES;
inv_param->input_location = QUDA_CPU_FIELD_LOCATION;
inv_param->output_location = QUDA_CPU_FIELD_LOCATION;
}
int
invert_test(void)
{
QudaGaugeParam gaugeParam = newQudaGaugeParam();
QudaInvertParam inv_param = newQudaInvertParam();
set_params(&gaugeParam, &inv_param,
xdim, ydim, zdim, tdim,
cpu_prec, prec, prec_sloppy,
link_recon, link_recon_sloppy, mass, tol, 1e-3, 0.8);
// this must be before the FaceBuffer is created (this is because it allocates pinned memory - FIXME)
initQuda(device);
setDims(gaugeParam.X);
dw_setDims(gaugeParam.X,Nsrc); // so we can use 5-d indexing from dwf
setSpinorSiteSize(6);
size_t gSize = (gaugeParam.cpu_prec == QUDA_DOUBLE_PRECISION) ? sizeof(double) : sizeof(float);
for (int dir = 0; dir < 4; dir++) {
qdp_fatlink[dir] = malloc(V*gaugeSiteSize*gSize);
qdp_longlink[dir] = malloc(V*gaugeSiteSize*gSize);
}
fatlink = malloc(4*V*gaugeSiteSize*gSize);
longlink = malloc(4*V*gaugeSiteSize*gSize);
if (dslash_type == QUDA_LAPLACE_DSLASH) {
construct_gauge_field(qdp_fatlink, 0, gaugeParam.cpu_prec, &gaugeParam);
} else {
construct_fat_long_gauge_field(qdp_fatlink, qdp_longlink, 1, gaugeParam.cpu_prec,
&gaugeParam, dslash_type);
}
for(int dir=0; dir<4; ++dir){
for(int i=0; i<V; ++i){
for(int j=0; j<gaugeSiteSize; ++j){
if(gaugeParam.cpu_prec == QUDA_DOUBLE_PRECISION){
((double*)fatlink)[(i*4 + dir)*gaugeSiteSize + j] = ((double*)qdp_fatlink[dir])[i*gaugeSiteSize + j];
((double*)longlink)[(i*4 + dir)*gaugeSiteSize + j] = ((double*)qdp_longlink[dir])[i*gaugeSiteSize + j];
}else{
((float*)fatlink)[(i*4 + dir)*gaugeSiteSize + j] = ((float*)qdp_fatlink[dir])[i*gaugeSiteSize + j];
((float*)longlink)[(i*4 + dir)*gaugeSiteSize + j] = ((float*)qdp_longlink[dir])[i*gaugeSiteSize + j];
}
}
}
}
ColorSpinorParam csParam;
csParam.nColor=3;
csParam.nSpin=1;
csParam.nDim=5;
for (int d = 0; d < 4; d++) csParam.x[d] = gaugeParam.X[d];
bool pc = (inv_param.solution_type == QUDA_MATPC_SOLUTION || inv_param.solution_type == QUDA_MATPCDAG_MATPC_SOLUTION);
if (pc) csParam.x[0] /= 2;
csParam.x[4] = Nsrc;
csParam.precision = inv_param.cpu_prec;
csParam.pad = 0;
csParam.siteSubset = pc ? QUDA_PARITY_SITE_SUBSET : QUDA_FULL_SITE_SUBSET;
csParam.siteOrder = QUDA_EVEN_ODD_SITE_ORDER;
csParam.fieldOrder = QUDA_SPACE_SPIN_COLOR_FIELD_ORDER;
csParam.gammaBasis = inv_param.gamma_basis;
csParam.create = QUDA_ZERO_FIELD_CREATE;
in = new cpuColorSpinorField(csParam);
out = new cpuColorSpinorField(csParam);
ref = new cpuColorSpinorField(csParam);
tmp = new cpuColorSpinorField(csParam);
if (inv_param.cpu_prec == QUDA_SINGLE_PRECISION){
constructSpinorField((float*)in->V());
}else{
constructSpinorField((double*)in->V());
}
#ifdef MULTI_GPU
int tmp_value = MAX(ydim*zdim*tdim/2, xdim*zdim*tdim/2);
tmp_value = MAX(tmp_value, xdim*ydim*tdim/2);
tmp_value = MAX(tmp_value, xdim*ydim*zdim/2);
int fat_pad = tmp_value;
int link_pad = 3*tmp_value;
// FIXME: currently assume staggered is SU(3)
gaugeParam.type = (dslash_type == QUDA_STAGGERED_DSLASH || dslash_type == QUDA_LAPLACE_DSLASH) ?
QUDA_SU3_LINKS : QUDA_ASQTAD_FAT_LINKS;
gaugeParam.reconstruct = QUDA_RECONSTRUCT_NO;
GaugeFieldParam cpuFatParam(fatlink, gaugeParam);
cpuFatParam.ghostExchange = QUDA_GHOST_EXCHANGE_PAD;
cpuFat = new cpuGaugeField(cpuFatParam);
ghost_fatlink = (void**)cpuFat->Ghost();
gaugeParam.type = QUDA_ASQTAD_LONG_LINKS;
GaugeFieldParam cpuLongParam(longlink, gaugeParam);
cpuLongParam.ghostExchange = QUDA_GHOST_EXCHANGE_PAD;
cpuLong = new cpuGaugeField(cpuLongParam);
ghost_longlink = (void**)cpuLong->Ghost();
#else
int fat_pad = 0;
int link_pad = 0;
#endif
gaugeParam.type = (dslash_type == QUDA_STAGGERED_DSLASH || dslash_type == QUDA_LAPLACE_DSLASH) ?
QUDA_SU3_LINKS : QUDA_ASQTAD_FAT_LINKS;
gaugeParam.ga_pad = fat_pad;
if (dslash_type == QUDA_STAGGERED_DSLASH || dslash_type == QUDA_LAPLACE_DSLASH) {
gaugeParam.reconstruct = link_recon;
gaugeParam.reconstruct_sloppy = link_recon_sloppy;
} else {
gaugeParam.reconstruct= gaugeParam.reconstruct_sloppy = QUDA_RECONSTRUCT_NO;
}
gaugeParam.cuda_prec_precondition = gaugeParam.cuda_prec_sloppy;
gaugeParam.reconstruct_precondition = gaugeParam.reconstruct_sloppy;
loadGaugeQuda(fatlink, &gaugeParam);
if (dslash_type == QUDA_ASQTAD_DSLASH) {
gaugeParam.type = QUDA_ASQTAD_LONG_LINKS;
gaugeParam.ga_pad = link_pad;
gaugeParam.reconstruct= link_recon;
gaugeParam.reconstruct_sloppy = link_recon_sloppy;
gaugeParam.cuda_prec_precondition = gaugeParam.cuda_prec_sloppy;
gaugeParam.reconstruct_precondition = gaugeParam.reconstruct_sloppy;
loadGaugeQuda(longlink, &gaugeParam);
}
double time0 = -((double)clock()); // Start the timer
double nrm2=0;
double src2=0;
int ret = 0;
int len = Vh*Nsrc;
switch(test_type){
case 0: //even
if(inv_type == QUDA_GCR_INVERTER){
inv_param.inv_type = QUDA_GCR_INVERTER;
inv_param.gcrNkrylov = 50;
}else if(inv_type == QUDA_PCG_INVERTER){
inv_param.inv_type = QUDA_PCG_INVERTER;
}
inv_param.matpc_type = QUDA_MATPC_EVEN_EVEN;
invertQuda(out->V(), in->V(), &inv_param);
time0 += clock();
time0 /= CLOCKS_PER_SEC;
#ifdef MULTI_GPU
matdagmat_mg4dir(ref, qdp_fatlink, qdp_longlink, ghost_fatlink, ghost_longlink,
out, mass, 0, inv_param.cpu_prec, gaugeParam.cpu_prec, tmp, QUDA_EVEN_PARITY);
#else
matdagmat(ref->V(), qdp_fatlink, qdp_longlink, out->V(), mass, 0, inv_param.cpu_prec, gaugeParam.cpu_prec, tmp->V(), QUDA_EVEN_PARITY);
#endif
mxpy(in->V(), ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
nrm2 = norm_2(ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
src2 = norm_2(in->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
break;
case 1: //odd
if(inv_type == QUDA_GCR_INVERTER){
inv_param.inv_type = QUDA_GCR_INVERTER;
inv_param.gcrNkrylov = 50;
}else if(inv_type == QUDA_PCG_INVERTER){
inv_param.inv_type = QUDA_PCG_INVERTER;
}
inv_param.matpc_type = QUDA_MATPC_ODD_ODD;
invertQuda(out->V(), in->V(), &inv_param);
time0 += clock(); // stop the timer
time0 /= CLOCKS_PER_SEC;
#ifdef MULTI_GPU
matdagmat_mg4dir(ref, qdp_fatlink, qdp_longlink, ghost_fatlink, ghost_longlink,
out, mass, 0, inv_param.cpu_prec, gaugeParam.cpu_prec, tmp, QUDA_ODD_PARITY);
#else
matdagmat(ref->V(), qdp_fatlink, qdp_longlink, out->V(), mass, 0, inv_param.cpu_prec, gaugeParam.cpu_prec, tmp->V(), QUDA_ODD_PARITY);
#endif
mxpy(in->V(), ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
nrm2 = norm_2(ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
src2 = norm_2(in->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
break;
case 2: //full spinor
errorQuda("full spinor not supported\n");
break;
case 3: //multi mass CG, even
case 4:
#define NUM_OFFSETS 12
{
double masses[NUM_OFFSETS] ={0.06, 0.061, 0.064, 0.070, 0.077, 0.081, 0.1, 0.11, 0.12, 0.13, 0.14, 0.205};
inv_param.num_offset = NUM_OFFSETS;
// these can be set independently
for (int i=0; i<inv_param.num_offset; i++) {
inv_param.tol_offset[i] = inv_param.tol;
inv_param.tol_hq_offset[i] = inv_param.tol_hq;
}
void* outArray[NUM_OFFSETS];
cpuColorSpinorField* spinorOutArray[NUM_OFFSETS];
spinorOutArray[0] = out;
for(int i=1;i < inv_param.num_offset; i++){
spinorOutArray[i] = new cpuColorSpinorField(csParam);
}
for(int i=0;i < inv_param.num_offset; i++){
outArray[i] = spinorOutArray[i]->V();
inv_param.offset[i] = 4*masses[i]*masses[i];
}
if (test_type == 3) {
inv_param.matpc_type = QUDA_MATPC_EVEN_EVEN;
} else {
inv_param.matpc_type = QUDA_MATPC_ODD_ODD;
}
invertMultiShiftQuda(outArray, in->V(), &inv_param);
cudaDeviceSynchronize();
time0 += clock(); // stop the timer
time0 /= CLOCKS_PER_SEC;
printfQuda("done: total time = %g secs, compute time = %g, %i iter / %g secs = %g gflops\n",
time0, inv_param.secs, inv_param.iter, inv_param.secs,
inv_param.gflops/inv_param.secs);
printfQuda("checking the solution\n");
QudaParity parity = QUDA_INVALID_PARITY;
if (inv_param.solve_type == QUDA_NORMOP_SOLVE){
//parity = QUDA_EVENODD_PARITY;
errorQuda("full parity not supported\n");
}else if (inv_param.matpc_type == QUDA_MATPC_EVEN_EVEN){
parity = QUDA_EVEN_PARITY;
}else if (inv_param.matpc_type == QUDA_MATPC_ODD_ODD){
parity = QUDA_ODD_PARITY;
}else{
errorQuda("ERROR: invalid spinor parity \n");
exit(1);
}
for(int i=0;i < inv_param.num_offset;i++){
printfQuda("%dth solution: mass=%f, ", i, masses[i]);
#ifdef MULTI_GPU
matdagmat_mg4dir(ref, qdp_fatlink, qdp_longlink, ghost_fatlink, ghost_longlink,
spinorOutArray[i], masses[i], 0, inv_param.cpu_prec,
gaugeParam.cpu_prec, tmp, parity);
#else
matdagmat(ref->V(), qdp_fatlink, qdp_longlink, outArray[i], masses[i], 0, inv_param.cpu_prec, gaugeParam.cpu_prec, tmp->V(), parity);
#endif
mxpy(in->V(), ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
double nrm2 = norm_2(ref->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
double src2 = norm_2(in->V(), len*mySpinorSiteSize, inv_param.cpu_prec);
double hqr = sqrt(blas::HeavyQuarkResidualNorm(*spinorOutArray[i], *ref).z);
double l2r = sqrt(nrm2/src2);
printfQuda("Shift %d residuals: (L2 relative) tol %g, QUDA = %g, host = %g; (heavy-quark) tol %g, QUDA = %g, host = %g\n",
i, inv_param.tol_offset[i], inv_param.true_res_offset[i], l2r,
inv_param.tol_hq_offset[i], inv_param.true_res_hq_offset[i], hqr);
//emperical, if the cpu residue is more than 1 order the target accuracy, the it fails to converge
if (sqrt(nrm2/src2) > 10*inv_param.tol_offset[i]){
ret |=1;
}
}
for(int i=1; i < inv_param.num_offset;i++) delete spinorOutArray[i];
}
break;
default:
errorQuda("Unsupported test type");
}//switch
if (test_type <=2){
double hqr = sqrt(blas::HeavyQuarkResidualNorm(*out, *ref).z);
double l2r = sqrt(nrm2/src2);
printfQuda("Residuals: (L2 relative) tol %g, QUDA = %g, host = %g; (heavy-quark) tol %g, QUDA = %g, host = %g\n",
inv_param.tol, inv_param.true_res, l2r, inv_param.tol_hq, inv_param.true_res_hq, hqr);
printfQuda("done: total time = %g secs, compute time = %g secs, %i iter / %g secs = %g gflops, \n",
time0, inv_param.secs, inv_param.iter, inv_param.secs,
inv_param.gflops/inv_param.secs);
}
end();
return ret;
}
static void
end(void)
{
for(int i=0;i < 4;i++){
free(qdp_fatlink[i]);
free(qdp_longlink[i]);
}
free(fatlink);
free(longlink);
delete in;
delete out;
delete ref;
delete tmp;
if (cpuFat) delete cpuFat;
if (cpuLong) delete cpuLong;
endQuda();
}
void
display_test_info()
{
printfQuda("running the following test:\n");
printfQuda("prec sloppy_prec link_recon sloppy_link_recon test_type S_dimension T_dimension\n");
printfQuda("%s %s %s %s %s %d/%d/%d %d \n",
get_prec_str(prec),get_prec_str(prec_sloppy),
get_recon_str(link_recon),
get_recon_str(link_recon_sloppy), get_test_type(test_type), xdim, ydim, zdim, tdim);
printfQuda("Grid partition info: X Y Z T\n");
printfQuda(" %d %d %d %d\n",
dimPartitioned(0),
dimPartitioned(1),
dimPartitioned(2),
dimPartitioned(3));
return ;
}
void
usage_extra(char** argv )
{
printfQuda("Extra options:\n");
printfQuda(" --test <0/1> # Test method\n");
printfQuda(" 0: Even even spinor CG inverter\n");
printfQuda(" 1: Odd odd spinor CG inverter\n");
printfQuda(" 3: Even even spinor multishift CG inverter\n");
printfQuda(" 4: Odd odd spinor multishift CG inverter\n");
printfQuda(" --cpu_prec <double/single/half> # Set CPU precision\n");
return ;
}
int main(int argc, char** argv)
{
for (int i = 1; i < argc; i++) {
if(process_command_line_option(argc, argv, &i) == 0){
continue;
}
if( strcmp(argv[i], "--cpu_prec") == 0){
if (i+1 >= argc){
usage(argv);
}
cpu_prec= get_prec(argv[i+1]);
i++;
continue;
}
printf("ERROR: Invalid option:%s\n", argv[i]);
usage(argv);
}
if (prec_sloppy == QUDA_INVALID_PRECISION){
prec_sloppy = prec;
}
if (link_recon_sloppy == QUDA_RECONSTRUCT_INVALID){
link_recon_sloppy = link_recon;
}
if(inv_type != QUDA_CG_INVERTER){
if(test_type != 0 && test_type != 1) errorQuda("Preconditioning is currently not supported in multi-shift solver solvers");
}
// initialize QMP/MPI, QUDA comms grid and RNG (test_util.cpp)
initComms(argc, argv, gridsize_from_cmdline);
display_test_info();
printfQuda("dslash_type = %d\n", dslash_type);
int ret = invert_test();
// finalize the communications layer
finalizeComms();
return ret;
}