QUDA  v1.1.0
A library for QCD on GPUs
dslash_twisted_mass.cu
Go to the documentation of this file.
1 #include <gauge_field.h>
2 #include <color_spinor_field.h>
3 #include <dslash.h>
4 #include <worker.h>
5 
6 #include <dslash_policy.cuh>
7 #include <kernels/dslash_twisted_mass.cuh>
8 
9 /**
10  This is the basic gauged twisted-mass operator
11 */
12 
13 namespace quda
14 {
15 
16  template <typename Arg> class TwistedMass : public Dslash<twistedMass, Arg>
17  {
18  using Dslash = Dslash<twistedMass, Arg>;
19  using Dslash::arg;
20  using Dslash::in;
21 
22  public:
23  TwistedMass(Arg &arg, const ColorSpinorField &out, const ColorSpinorField &in) : Dslash(arg, out, in) {}
24 
25  void apply(const qudaStream_t &stream)
26  {
27  TuneParam tp = tuneLaunch(*this, getTuning(), getVerbosity());
28  Dslash::setParam(tp);
29  if (arg.xpay)
30  Dslash::template instantiate<packShmem, true>(tp, stream);
31  else
32  errorQuda("Twisted-mass operator only defined for xpay=true");
33  }
34 
35  long long flops() const
36  {
37  long long flops = Dslash::flops();
38  switch (arg.kernel_type) {
39  case INTERIOR_KERNEL:
40  case UBER_KERNEL:
41  case KERNEL_POLICY:
42  flops += 2 * in.Ncolor() * 4 * 2 * in.Volume(); // complex * Nc * Ns * fma * vol
43  break;
44  default: break; // twisted-mass flops are in the interior kernel
45  }
46  return flops;
47  }
48  };
49 
50  template <typename Float, int nColor, QudaReconstructType recon> struct TwistedMassApply {
51 
52  inline TwistedMassApply(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, double a, double b,
53  const ColorSpinorField &x, int parity, bool dagger, const int *comm_override,
54  TimeProfile &profile)
55  {
56  constexpr int nDim = 4;
57  TwistedMassArg<Float, nColor, nDim, recon> arg(out, in, U, a, b, x, parity, dagger, comm_override);
58  TwistedMass<decltype(arg)> twisted(arg, out, in);
59 
60  dslash::DslashPolicyTune<decltype(twisted)> policy(
61  twisted, const_cast<cudaColorSpinorField *>(static_cast<const cudaColorSpinorField *>(&in)), in.VolumeCB(),
62  in.GhostFaceCB(), profile);
63  policy.apply(0);
64  }
65  };
66 
67  // Apply the twisted-mass Dslash operator
68  // out(x) = M*in = (1 + i*b*gamma_5)*in(x) + a*\sum_mu U_{-\mu}(x)in(x+mu) + U^\dagger_mu(x-mu)in(x-mu)
69  // Uses the kappa normalization for the Wilson operator, with a = -kappa.
70  void ApplyTwistedMass(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, double a, double b,
71  const ColorSpinorField &x, int parity, bool dagger, const int *comm_override,
72  TimeProfile &profile)
73  {
74 #ifdef GPU_TWISTED_MASS_DIRAC
75  instantiate<TwistedMassApply>(out, in, U, a, b, x, parity, dagger, comm_override, profile);
76 #else
77  errorQuda("Twisted-mass dslash has not been built");
78 #endif // GPU_TWISTED_MASS_DIRAC
79  }
80 
81 } // namespace quda