QUDA  v1.1.0
A library for QCD on GPUs
gauge_plaq.cu
Go to the documentation of this file.
1 #include <tune_quda.h>
2 #include <gauge_field.h>
3 #include <jitify_helper.cuh>
4 #include <kernels/gauge_plaq.cuh>
5 #include <instantiate.h>
6 
7 namespace quda {
8 
9  template<typename Float, int nColor, QudaReconstructType recon>
10  class GaugePlaq : TunableLocalParityReduction {
11  const GaugeField &u;
12  double2 &plq;
13 
14  public:
15  GaugePlaq(const GaugeField &u, double2 &plq) :
16  u(u),
17  plq(plq)
18  {
19 #ifdef JITIFY
20  create_jitify_program("kernels/gauge_plaq.cuh");
21 #endif
22  strcpy(aux, compile_type_str(u));
23  apply(0);
24  }
25 
26  void apply(const qudaStream_t &stream){
27  if (u.Location() == QUDA_CUDA_FIELD_LOCATION) {
28  TuneParam tp = tuneLaunch(*this, getTuning(), getVerbosity());
29  GaugePlaqArg<Float, nColor, recon> arg(u);
30 #ifdef JITIFY
31  using namespace jitify::reflection;
32  jitify_error = program->kernel("quda::computePlaq")
33  .instantiate((int)tp.block.x,type_of(arg))
34  .configure(tp.grid,tp.block,tp.shared_bytes,stream).launch(arg);
35  arg.launch_error = jitify_error == CUDA_SUCCESS ? QUDA_SUCCESS : QUDA_ERROR;
36 #else
37  LAUNCH_KERNEL_LOCAL_PARITY(computePlaq, (*this), tp, stream, arg, decltype(arg));
38 #endif
39  arg.complete(plq);
40  if (!activeTuning()) {
41  comm_allreduce_array((double*)&plq, 2);
42  for (int i = 0; i < 2; i++) ((double*)&plq)[i] /= 9.*2*arg.threads*comm_size();
43  }
44  } else {
45  errorQuda("CPU not supported yet\n");
46  }
47  }
48 
49  TuneKey tuneKey() const { return TuneKey(u.VolString(), typeid(*this).name(), aux); }
50  long long flops() const
51  {
52  auto Nc = u.Ncolor();
53  return 6ll*u.Volume()*(3 * (8 * Nc * Nc * Nc - 2 * Nc * Nc) + Nc);
54  }
55  long long bytes() const { return u.Bytes(); }
56  };
57 
58  double3 plaquette(const GaugeField &U)
59  {
60  double2 plq;
61  instantiate<GaugePlaq>(U, plq);
62  double3 plaq = make_double3(0.5*(plq.x + plq.y), plq.x, plq.y);
63  return plaq;
64  }
65 
66 } // namespace quda