-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathdirac_quda.h
More file actions
2638 lines (2214 loc) · 104 KB
/
dirac_quda.h
File metadata and controls
2638 lines (2214 loc) · 104 KB
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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include <quda_internal.h>
#include <timer.h>
#include <color_spinor_field.h>
#include <gauge_field.h>
#include <clover_field.h>
#include <blas_quda.h>
#include <typeinfo>
namespace quda {
// Forward declare: MG Transfer Class
class Transfer;
// Forward declare: Dirac Op Base Class
class Dirac;
// Params for Dirac operator
class DiracParam {
public:
QudaDiracType type;
double kappa;
double mass;
double m5; // used by domain wall only
int Ls; // used by domain wall and twisted mass
Complex b_5[QUDA_MAX_DWF_LS]; // used by mobius domain wall only
Complex c_5[QUDA_MAX_DWF_LS]; // used by mobius domain wall only
// The EOFA parameters. See the description in InvertParam
double eofa_shift;
int eofa_pm;
double mq1;
double mq2;
double mq3;
QudaMatPCType matpcType;
QudaDagType dagger;
cudaGaugeField *gauge;
cudaGaugeField *fatGauge; // used by staggered only
cudaGaugeField *longGauge; // used by staggered only
int laplace3D;
CloverField *clover;
GaugeField *xInvKD; // used for the Kahler-Dirac operator only
double mu; // used by twisted mass only
double mu_factor; // used by multigrid only
double epsilon; //2nd tm parameter (used by twisted mass only)
double tm_rho; // "rho"-type Hasenbusch mass used for twisted clover (like regular rho but
// applied like a twisted mass and ignored in the inverse)
ColorSpinorField *tmp1;
ColorSpinorField *tmp2; // used by Wilson-like kernels only
int commDim[QUDA_MAX_DIM]; // whether to do comms or not
QudaPrecision halo_precision; // only does something for DiracCoarse at present
// for multigrid only
Transfer *transfer;
Dirac *dirac;
bool need_bidirectional; // whether or not we need to force a bi-directional build
bool use_mma; // whether to use tensor cores where applicable
bool allow_truncation; /** whether or not we let MG coarsening drop improvements, for ex drop long links for small aggregate dimensions */
bool use_mobius_fused_kernel; // Whether or not use fused kernels for Mobius
// Default constructor
DiracParam() :
type(QUDA_INVALID_DIRAC),
kappa(0.0),
m5(0.0),
matpcType(QUDA_MATPC_INVALID),
dagger(QUDA_DAG_INVALID),
gauge(0),
clover(0),
mu(0.0),
mu_factor(0.0),
epsilon(0.0),
tm_rho(0.0),
tmp1(0),
tmp2(0),
halo_precision(QUDA_INVALID_PRECISION),
need_bidirectional(false),
#ifdef QUDA_MMA_AVAILABLE
use_mma(true),
#else
use_mma(false),
#endif
allow_truncation(false),
#ifdef NVSHMEM_COMMS
use_mobius_fused_kernel(false)
#else
use_mobius_fused_kernel(true)
#endif
{
for (int i=0; i<QUDA_MAX_DIM; i++) commDim[i] = 1;
}
// Pretty print the args struct
void print() {
printfQuda("Printing DslashParam\n");
printfQuda("type = %d\n", type);
printfQuda("kappa = %g\n", kappa);
printfQuda("mass = %g\n", mass);
printfQuda("laplace3D = %d\n", laplace3D);
printfQuda("m5 = %g\n", m5);
printfQuda("Ls = %d\n", Ls);
printfQuda("matpcType = %d\n", matpcType);
printfQuda("dagger = %d\n", dagger);
printfQuda("mu = %g\n", mu);
printfQuda("tm_rho = %g\n", tm_rho);
printfQuda("epsilon = %g\n", epsilon);
printfQuda("halo_precision = %d\n", halo_precision);
for (int i=0; i<QUDA_MAX_DIM; i++) printfQuda("commDim[%d] = %d\n", i, commDim[i]);
for (int i = 0; i < Ls; i++)
printfQuda(
"b_5[%d] = %e %e \t c_5[%d] = %e %e\n", i, b_5[i].real(), b_5[i].imag(), i, c_5[i].real(), c_5[i].imag());
printfQuda("use_mma = %d\n", use_mma);
printfQuda("allow_truncation = %d\n", allow_truncation);
printfQuda("use_mobius_fused_kernel = %s\n", use_mobius_fused_kernel ? "true" : "false");
}
};
// This is a free function:
// Dirac params structure
// inv_param structure
// pc -> preconditioned.
void setDiracParam(DiracParam &diracParam, QudaInvertParam *inv_param, bool pc);
// This is a free function.
void setDiracSloppyParam(DiracParam &diracParam, QudaInvertParam *inv_param, bool pc);
// forward declarations
class DiracMatrix; // What are the differences in these classes?
class DiracM;
class DiracMdagM;
class DiracMdagMLocal;
class DiracMMdag;
class DiracMdag;
class DiracG5M;
//Forward declaration of multigrid Transfer class
class Transfer;
// Abstract base class
class Dirac : public Object {
friend class DiracMatrix;
friend class DiracM;
friend class DiracMdagM;
friend class DiracMdagMLocal;
friend class DiracMMdag;
friend class DiracMdag;
friend class DiracG5M;
protected:
cudaGaugeField *gauge;
double kappa;
double mass;
int laplace3D;
QudaMatPCType matpcType;
mutable QudaDagType dagger; // mutable to simplify implementation of Mdag
mutable unsigned long long flops;
mutable ColorSpinorField *tmp1; // temporary hack
mutable ColorSpinorField *tmp2; // temporary hack
QudaDiracType type;
mutable QudaPrecision halo_precision; // only does something for DiracCoarse at present
bool newTmp(ColorSpinorField **, const ColorSpinorField &) const;
void deleteTmp(ColorSpinorField **, const bool &reset) const;
mutable int commDim[QUDA_MAX_DIM]; // whether do comms or not
bool use_mobius_fused_kernel; // Whether or not use fused kernels for Mobius
mutable TimeProfile profile;
public:
Dirac(const DiracParam ¶m); // construct from params
Dirac(const Dirac &dirac); // Copy construct
virtual ~Dirac(); // virtual destructor as this is a base class
Dirac &operator=(const Dirac &dirac); // assignment
/**
@brief Enable / disable communications for the Dirac operator
@param[in] commDim_ Array of booleans which determines whether
communications are enabled
*/
void setCommDim(const int commDim_[QUDA_MAX_DIM]) const {
for (int i=0; i<QUDA_MAX_DIM; i++) { commDim[i] = commDim_[i]; }
}
/**
@brief Whether the Dirac object is the DiracCoarse.
*/
virtual bool isCoarse() const { return false; }
/**
@brief Check parity spinors are usable (check geometry ?)
*/
virtual void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const;
/**
@brief check full spinors are compatible (check geometry ?)
*/
virtual void checkFullSpinor(const ColorSpinorField &, const ColorSpinorField &) const;
/**
@brief check spinors do not alias
*/
void checkSpinorAlias(const ColorSpinorField &, const ColorSpinorField &) const;
/**
@brief Whether or not the operator has a single-parity Dslash
*/
virtual bool hasDslash() const { return true; }
/**
@brief apply 'dslash' operator for the DiracOp. This may be e.g. AD
*/
virtual void Dslash(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity) const = 0;
/**
@brief Xpay version of Dslash
*/
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity, const ColorSpinorField &x,
const double &k) const = 0;
/**
@brief Apply M for the dirac op. E.g. the Schur Complement operator
*/
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const = 0;
/**
@brief Apply MdagM operator which may be optimized
*/
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const = 0;
/**
@brief Apply the local MdagM operator: equivalent to applying zero Dirichlet
boundary condition to MdagM on each rank. Depending on the number of
stencil steps of the fermion type, this may require additional effort
to include the terms that hop out of the boundary and then hop back.
*/
virtual void MdagMLocal(ColorSpinorField &, const ColorSpinorField &) const { errorQuda("Not implemented!\n"); }
/**
@brief Apply the local MdagM operator: equivalent to applying zero Dirichlet
boundary condition to MdagM on each rank. Depending on the number of
stencil steps of the fermion type, this may require additional effort
to include the terms that hop out of the boundary and then hop back.
*/
virtual void Dslash4(ColorSpinorField &, const ColorSpinorField &, const QudaParity) const
{
errorQuda("Not implemented!\n");
}
/**
@brief Apply Mdag (daggered operator of M
*/
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const;
/**
@brief Apply Normal Operator
*/
virtual void MMdag(ColorSpinorField &out, const ColorSpinorField &in) const;
// required methods to use e-o preconditioning for solving full system
virtual void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType solType) const = 0;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType solType) const = 0;
// special prepare/recon methods that go into PreconditionedSolve in MG
virtual void prepareSpecialMG(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x,
ColorSpinorField &b, const QudaSolutionType solType) const
{
prepare(src, sol, x, b, solType);
}
virtual void reconstructSpecialMG(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType solType) const
{
reconstruct(x, b, solType);
}
/**
@brief specifies whether or not there's a specialized prepare/reconstruct
used before/after transfering to/from the coarse level in MG
@return whether or not a specialized routine should be used
*/
virtual bool hasSpecialMG() const { return false; }
void setMass(double mass){ this->mass = mass;}
// Dirac operator factory
/**
@brief Creates a subclass from parameters
*/
static Dirac* create(const DiracParam ¶m);
/**
@brief accessor for Kappa (mass parameter)
*/
double Kappa() const { return kappa; }
/**
@brief accessor for Mass (in case of a factor of 2 for staggered)
*/
virtual double Mass() const { return mass; } // in case of factor of 2 convention for staggered
/**
@brief accessor for twist parameter -- overrride can return better value
*/
virtual double Mu() const { return 0.; }
/**
@brief accessor for mu factoo for MG/ -- override can return a better value
*/
virtual double MuFactor() const { return 0.; }
/**
@brief accessor for if we let MG coarsening drop we can drop improvements, for ex long links for small aggregation dimensions
*/
virtual bool AllowTruncation() const { return false; }
/**
@brief returns and then zeroes flopcount
*/
unsigned long long Flops() const
{
unsigned long long rtn = flops;
flops = 0;
return rtn;
}
/**
@brief returns preconditioning type
*/
QudaMatPCType getMatPCType() const { return matpcType; }
/**
@brief I have no idea what this does
*/
int getStencilSteps() const;
/**
@brief sets whether operator is daggered or not
*/
void Dagger(QudaDagType dag) const { dagger = dag; }
/**
@brief Flips value of daggered
*/
void flipDagger() const { dagger = (dagger == QUDA_DAG_YES) ? QUDA_DAG_NO : QUDA_DAG_YES; }
/**
@brief is operator hermitian
*/
virtual bool hermitian() const { return false; }
/** @brief returns the Dirac type
@return Dirac type
*/
virtual QudaDiracType getDiracType() const = 0;
/**
@brief Return the one-hop field for staggered operators for MG setup
@return Error for non-staggered operators
*/
virtual cudaGaugeField *getStaggeredShortLinkField() const
{
errorQuda("Invalid dirac type %d", getDiracType());
return nullptr;
}
/**
@brief return the long link field for staggered operators for MG setup, if it exists
@return Error for non-improved staggered operators
*/
virtual cudaGaugeField *getStaggeredLongLinkField() const
{
errorQuda("Invalid dirac type %d", getDiracType());
return nullptr;
}
/**
* @brief Update the internal gauge, fat gauge, long gauge, clover field pointer as appropriate.
* These are pointers as opposed to references to support passing in `nullptr`.
*
* @param gauge_in Updated gauge field
* @param fat_gauge_in Updated fat links
* @param long_gauge_in Updated long links
* @param clover_in Updated clover field
*/
virtual void updateFields(cudaGaugeField *gauge_in, cudaGaugeField *, cudaGaugeField *, CloverField *)
{
gauge = gauge_in;
}
/**
* @brief Create the coarse operator (virtual parent)
*
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param T[in] Transfer operator defining the coarse grid
* @param kappa Kappa parameter for the coarse operator
* @param mass Mass parameter for the coarse operator (gets explicitly built into clover, hard coded to zero for
* non-staggered ops)
* @param mu TM mu parameter for the coarse operator
* @param mu_factor multiplicative factor for the mu parameter
* @param allow_truncation [in] whether or not we let coarsening drop improvements, for ex dropping long links for
* small aggregate sizes
*/
virtual void createCoarseOp(GaugeField &, GaugeField &, const Transfer &, double, double, double, double, bool) const
{errorQuda("Not implemented");}
QudaPrecision HaloPrecision() const { return halo_precision; }
void setHaloPrecision(QudaPrecision halo_precision_) const { halo_precision = halo_precision_; }
/**
@brief If managed memory and prefetch is enabled, prefetch
the gauge field and temporary spinors to the CPU or GPU
as requested. Overloads may also grab a clover term
@param[in] mem_space Memory space we are prefetching to
@param[in] stream Which stream to run the prefetch in (default 0)
*/
virtual void prefetch(QudaFieldLocation mem_space, qudaStream_t stream = device::get_default_stream()) const;
};
// Full Wilson
class DiracWilson : public Dirac {
protected:
void initConstants();
public:
DiracWilson(const DiracParam ¶m);
DiracWilson(const DiracWilson &dirac);
DiracWilson(const DiracParam ¶m, const int nDims);//to correctly adjust face for DW and non-deg twisted mass
virtual ~DiracWilson();
DiracWilson& operator=(const DiracWilson &dirac);
virtual void Dslash(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity) const;
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity, const ColorSpinorField &x, const double &k) const;
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_WILSON_DIRAC; }
/**
* @brief Create the coarse Wilson operator.
*
* @details Takes the multigrid transfer class, which knows
* about the coarse grid blocking, as well as
* having prolongate and restrict member functions,
* and returns color matrices Y[0..2*dim-1] corresponding
* to the coarse grid hopping terms and X corresponding to
* the coarse grid "clover" term.
*
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param T[in] Transfer operator defining the coarse grid
* @param mass Mass parameter for the coarse operator (hard coded to 0 when CoarseOp is called)
* @param kappa Kappa parameter for the coarse operator
* @param allow_truncation [in] whether or not we let coarsening drop improvements, none available for Wilson operator
*/
virtual void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass = 0.,
double mu = 0., double mu_factor = 0., bool allow_truncation = false) const;
};
// Even-odd preconditioned Wilson
class DiracWilsonPC : public DiracWilson {
private:
public:
DiracWilsonPC(const DiracParam ¶m);
DiracWilsonPC(const DiracWilsonPC &dirac);
virtual ~DiracWilsonPC();
DiracWilsonPC& operator=(const DiracWilsonPC &dirac);
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_WILSONPC_DIRAC; }
};
// Full clover
class DiracClover : public DiracWilson {
protected:
CloverField *clover;
void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const;
void initConstants();
public:
DiracClover(const DiracParam ¶m);
DiracClover(const DiracClover &dirac);
virtual ~DiracClover();
DiracClover& operator=(const DiracClover &dirac);
// APply clover
void Clover(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &k) const;
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_CLOVER_DIRAC; }
/**
* @brief Update the internal gauge, fat gauge, long gauge, clover field pointer as appropriate.
* These are pointers as opposed to references to support passing in `nullptr`.
*
* @param gauge_in Updated gauge field
* @param fat_gauge_in Updated fat links
* @param long_gauge_in Updated long links
* @param clover_in Updated clover field
*/
virtual void updateFields(cudaGaugeField *gauge_in, cudaGaugeField *, cudaGaugeField *, CloverField *clover_in)
{
DiracWilson::updateFields(gauge_in, nullptr, nullptr, nullptr);
clover = clover_in;
}
/**
* @brief Create the coarse clover operator
*
* @details Takes the multigrid transfer class, which knows
* about the coarse grid blocking, as well as
* having prolongate and restrict member functions,
* and returns color matrices Y[0..2*dim-1] corresponding
* to the coarse grid hopping terms and X corresponding to
* the coarse grid "clover" term.
*
* @param T[in] Transfer operator defining the coarse grid
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param kappa Kappa parameter for the coarse operator
* @param mass Mass parameter for the coarse operator (hard coded to 0 when CoarseOp is called)
* @param allow_truncation [in] whether or not we let coarsening drop improvements, none available for clover operator
*/
void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass = 0., double mu = 0.,
double mu_factor = 0., bool allow_truncation = false) const;
/**
@brief If managed memory and prefetch is enabled, prefetch
all relevant memory fields (gauge, clover, temporary spinors)
to the CPU or GPU as requested
@param[in] mem_space Memory space we are prefetching to
@param[in] stream Which stream to run the prefetch in (default 0)
*/
virtual void prefetch(QudaFieldLocation mem_space, qudaStream_t stream = device::get_default_stream()) const;
};
// Even-odd preconditioned clover
class DiracCloverPC : public DiracClover {
public:
DiracCloverPC(const DiracParam ¶m);
DiracCloverPC(const DiracCloverPC &dirac);
virtual ~DiracCloverPC();
DiracCloverPC& operator=(const DiracCloverPC &dirac);
// Clover is inherited from parent
// Clover Inv is new
void CloverInv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
// Dslash is redefined as A_pp^{-1} D_p\bar{p}
void Dslash(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity) const;
// out = x + k A_pp^{-1} D_p\bar{p}
void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity, const ColorSpinorField &x, const double &k) const;
// Can implement: M as e.g. : i) tmp_e = A^{-1}_ee D_eo in_o (Dslash)
// ii) out_o = in_o + A_oo^{-1} D_oe tmp_e (AXPY)
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
// squared op
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_CLOVERPC_DIRAC; }
/**
* @brief Create the coarse even-odd preconditioned clover
* operator. Unlike the Wilson operator, the coarsening of the
* preconditioned clover operator differs from that of the
* unpreconditioned clover operator, so we need to specialize it.
*
* @param T[in] Transfer operator defining the coarse grid
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param kappa Kappa parameter for the coarse operator
* @param mass Mass parameter for the coarse operator (set to zero)
* @param allow_truncation [in] whether or not we let coarsening drop improvements, none available for clover operator
*/
void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass = 0., double mu = 0.,
double mu_factor = 0., bool allow_truncation = false) const;
/**
@brief If managed memory and prefetch is enabled, prefetch
all relevant memory fields (gauge, clover, temporary spinors).
Will only grab the inverse clover unless the clover field
is needed for asymmetric preconditioning
to the CPU or GPU as requested
@param[in] mem_space Memory space we are prefetching to
@param[in] stream Which stream to run the prefetch in (default 0)
*/
virtual void prefetch(QudaFieldLocation mem_space, qudaStream_t stream = device::get_default_stream()) const;
};
// Full clover with Hasenbusch Twist
//
// [ A_ee -k D_eo ]
// [ -k D_oe A_oo + i mu g_5 A_oo^2 ]
//
// A_oo + i mu g_5 A_oo^2 = A_oo( 1 + i mu g_5 A_oo)
class DiracCloverHasenbuschTwist : public DiracClover
{
// Inherit these so I will comment them out
/*
protected:
CloverField *clover;
void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const;
void initConstants();
*/
protected:
double mu;
public:
DiracCloverHasenbuschTwist(const DiracParam ¶m);
DiracCloverHasenbuschTwist(const DiracCloverHasenbuschTwist &dirac);
virtual ~DiracCloverHasenbuschTwist();
DiracCloverHasenbuschTwist &operator=(const DiracCloverHasenbuschTwist &dirac);
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual QudaDiracType getDiracType() const { return QUDA_CLOVER_HASENBUSCH_TWIST_DIRAC; }
/**
* @brief Create the coarse clover operator
*
* @param T[in] Transfer operator defining the coarse grid
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param kappa Kappa parameter for the coarse operator
* @param mass Mass parameter for the coarse operator (hard coded to 0 when CoarseOp is called)
* @param allow_truncation [in] whether or not we let coarsening drop improvements, none available for clover
*/
void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass = 0., double mu = 0.,
double mu_factor = 0., bool allow_truncation = false) const;
};
// Even-odd preconditioned clover
class DiracCloverHasenbuschTwistPC : public DiracCloverPC
{
protected:
double mu;
public:
DiracCloverHasenbuschTwistPC(const DiracParam ¶m);
DiracCloverHasenbuschTwistPC(const DiracCloverHasenbuschTwistPC &dirac);
virtual ~DiracCloverHasenbuschTwistPC();
DiracCloverHasenbuschTwistPC &operator=(const DiracCloverHasenbuschTwistPC &dirac);
// Clover is inherited from parent
// Clover Inv is inherited from parent
// Dslash is defined as A_pp^{-1} D_p\bar{p} and is inherited
// DslashXPay is inherited (for reconstructs and such)
// out = (1 +/- ig5 mu A)x + k A^{-1} D in
void DslashXpayTwistClovInv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &k, const double &b) const;
// out = ( 1+/- i g5 mu A) x - D in
void DslashXpayTwistNoClovInv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &k, const double &b) const;
// Can implement: M as e.g. : i) tmp_e = A^{-1}_ee D_eo in_o (Dslash)
// ii) out_o = in_o + A_oo^{-1} D_oe tmp_e (AXPY)
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
// squared op
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual QudaDiracType getDiracType() const { return QUDA_CLOVER_HASENBUSCH_TWISTPC_DIRAC; }
/**
* @brief Create the coarse even-odd preconditioned clover
* operator. Unlike the Wilson operator, the coarsening of the
* preconditioned clover operator differs from that of the
* unpreconditioned clover operator, so we need to specialize it.
*
* @param T[in] Transfer operator defining the coarse grid
* @param Y[out] Coarse link field
* @param X[out] Coarse clover field
* @param kappa Kappa parameter for the coarse operator
* @param mass Mass parameter for the coarse operator (set to zero)
* @param allow_truncation [in] whether or not we let coarsening drop improvements, none available for clover hasenbusch
*/
void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass = 0., double mu = 0.,
double mu_factor = 0., bool allow_truncation = false) const;
};
// Full domain wall
class DiracDomainWall : public DiracWilson {
protected:
double m5;
double kappa5;
int Ls; // length of the fifth dimension
/**
@brief Check whether the input and output are valid 5D fields.
*/
virtual void checkDWF(const ColorSpinorField &out, const ColorSpinorField &in) const;
public:
DiracDomainWall(const DiracParam ¶m);
DiracDomainWall(const DiracDomainWall &dirac);
virtual ~DiracDomainWall();
DiracDomainWall& operator=(const DiracDomainWall &dirac);
void Dslash(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity) const;
void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity, const ColorSpinorField &x, const double &k) const;
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_DOMAIN_WALL_DIRAC; }
};
// 5d Even-odd preconditioned domain wall
class DiracDomainWallPC : public DiracDomainWall {
private:
public:
DiracDomainWallPC(const DiracParam ¶m);
DiracDomainWallPC(const DiracDomainWallPC &dirac);
virtual ~DiracDomainWallPC();
DiracDomainWallPC& operator=(const DiracDomainWallPC &dirac);
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField* &src, ColorSpinorField* &sol,
ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_DOMAIN_WALLPC_DIRAC; }
};
// Full domain wall, but with 4-d parity ordered fields
class DiracDomainWall4D : public DiracDomainWall
{
public:
DiracDomainWall4D(const DiracParam ¶m);
DiracDomainWall4D(const DiracDomainWall4D &dirac);
virtual ~DiracDomainWall4D();
DiracDomainWall4D &operator=(const DiracDomainWall4D &dirac);
void Dslash4(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
void Dslash5(ColorSpinorField &out, const ColorSpinorField &in) const;
void Dslash4Xpay(ColorSpinorField &out, const ColorSpinorField &in,
const QudaParity parity, const ColorSpinorField &x, const double &k) const;
void Dslash5Xpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x, const double &k) const;
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_DOMAIN_WALL_4D_DIRAC; }
};
// 4d Even-odd preconditioned domain wall
class DiracDomainWall4DPC : public DiracDomainWall4D
{
public:
DiracDomainWall4DPC(const DiracParam ¶m);
DiracDomainWall4DPC(const DiracDomainWall4DPC &dirac);
virtual ~DiracDomainWall4DPC();
DiracDomainWall4DPC &operator=(const DiracDomainWall4DPC &dirac);
void M5inv(ColorSpinorField &out, const ColorSpinorField &in) const;
void M5invXpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x, const double &k) const;
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b,
const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_DOMAIN_WALL_4DPC_DIRAC; }
};
// Full Mobius
class DiracMobius : public DiracDomainWall {
protected:
//Mobius coefficients
Complex b_5[QUDA_MAX_DWF_LS];
Complex c_5[QUDA_MAX_DWF_LS];
/**
Whether we are using classical Mobius with constant real-valued
b and c coefficients, or zMobius with complex-valued variable
coefficients
*/
bool zMobius;
double mobius_kappa_b;
double mobius_kappa_c;
double mobius_kappa;
/**
@brief Check whether the input and output are valid 5D fields. If zMobius, we require that they
have the same 5th dimension as the one in record.
*/
virtual void checkDWF(const ColorSpinorField &out, const ColorSpinorField &in) const;
public:
DiracMobius(const DiracParam ¶m);
// DiracMobius(const DiracMobius &dirac);
// virtual ~DiracMobius();
// DiracMobius& operator=(const DiracMobius &dirac);
void Dslash4(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
void Dslash4pre(ColorSpinorField &out, const ColorSpinorField &in) const;
void Dslash5(ColorSpinorField &out, const ColorSpinorField &in) const;
void Dslash4Xpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &k) const;
void Dslash4preXpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x,
const double &k) const;
void Dslash5Xpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x,
const double &k) const;
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_MOBIUS_DOMAIN_WALL_DIRAC; }
};
// 4d even-odd preconditioned Mobius domain wall
class DiracMobiusPC : public DiracMobius {
protected:
mutable cudaGaugeField *extended_gauge;
private:
public:
DiracMobiusPC(const DiracParam ¶m);
DiracMobiusPC(const DiracMobiusPC &dirac);
virtual ~DiracMobiusPC();
DiracMobiusPC& operator=(const DiracMobiusPC &dirac);
void M5inv(ColorSpinorField &out, const ColorSpinorField &in) const;
void M5invXpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x, const double &k) const;
void Dslash4M5invM5pre(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
void Dslash4M5preM5inv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const;
void Dslash4M5invXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &a) const;
void Dslash4M5preXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &a) const;
void Dslash4XpayM5mob(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &a) const;
void Dslash4M5preXpayM5mob(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &a) const;
void Dslash4M5invXpayM5inv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity,
const ColorSpinorField &x, const double &a, ColorSpinorField &y) const;
void MdagMLocal(ColorSpinorField &out, const ColorSpinorField &in) const;
void M(ColorSpinorField &out, const ColorSpinorField &in) const;
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
// this needs to be specialized for Mobius since we have a fused MdagM kernel
void MMdag(ColorSpinorField &out, const ColorSpinorField &in) const;
void prepare(ColorSpinorField* &src, ColorSpinorField* &sol, ColorSpinorField &x,
ColorSpinorField &b, const QudaSolutionType) const;
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_MOBIUS_DOMAIN_WALLPC_DIRAC; }
};
// Full Mobius EOFA
class DiracMobiusEofa : public DiracMobius
{
protected:
// The EOFA parameters
double m5inv_fac = 0.;
double sherman_morrison_fac = 0.;
double eofa_shift;
int eofa_pm;
double mq1;
double mq2;
double mq3;
double eofa_u[QUDA_MAX_DWF_LS];
double eofa_x[QUDA_MAX_DWF_LS];
double eofa_y[QUDA_MAX_DWF_LS];
/**
@brief Check whether the input and output are valid 5D fields, and we require that they
have the same 5th dimension as the one in record.
*/
virtual void checkDWF(const ColorSpinorField &out, const ColorSpinorField &in) const;
public:
DiracMobiusEofa(const DiracParam ¶m);
void m5_eofa(ColorSpinorField &out, const ColorSpinorField &in) const;
void m5_eofa_xpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x, double a = -1.) const;
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const;
virtual void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b,
const QudaSolutionType) const;
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const;
virtual QudaDiracType getDiracType() const { return QUDA_MOBIUS_DOMAIN_WALL_EOFA_DIRAC; }
};
// 4d Even-odd preconditioned Mobius domain wall with EOFA
class DiracMobiusEofaPC : public DiracMobiusEofa
{
public:
DiracMobiusEofaPC(const DiracParam ¶m);
void m5inv_eofa(ColorSpinorField &out, const ColorSpinorField &in) const;
void m5inv_eofa_xpay(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x,
double a = -1.) const;