QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
gauge_qcharge.cuh
Go to the documentation of this file.
1 #include <gauge_field_order.h>
2 #include <index_helper.cuh>
3 #include <cub_helper.cuh>
4 
5 #ifndef Pi2
6 #define Pi2 6.2831853071795864769252867665590
7 #endif
8 
9 namespace quda
10 {
11 
12  template <typename Float, typename Gauge, bool density_ = false> struct QChargeArg : public ReduceArg<double> {
13  static constexpr bool density = density_;
14  int threads; // number of active threads required
15  Gauge data;
16  Float *qDensity;
17 
18  QChargeArg(const Gauge &data, const GaugeField &Fmunu, Float *qDensity = nullptr) :
19  ReduceArg<double>(),
20  data(data),
21  threads(Fmunu.VolumeCB()),
22  qDensity(qDensity)
23  {
24  }
25  };
26 
27  // Core routine for computing the topological charge from the field strength
28  template <int blockSize, typename Float, typename Arg> __global__ void qChargeComputeKernel(Arg arg)
29  {
30  int x_cb = threadIdx.x + blockIdx.x * blockDim.x;
31  int parity = threadIdx.y;
32 
33  double Q = 0.0;
34 
35  while (x_cb < arg.threads) {
36  // Load the field-strength tensor from global memory
37  Matrix<complex<Float>, 3> F[] = {arg.data(0, x_cb, parity), arg.data(1, x_cb, parity), arg.data(2, x_cb, parity),
38  arg.data(3, x_cb, parity), arg.data(4, x_cb, parity), arg.data(5, x_cb, parity)};
39 
40  double Q1 = getTrace(F[0] * F[5]).real();
41  double Q2 = getTrace(F[1] * F[4]).real();
42  double Q3 = getTrace(F[3] * F[2]).real();
43  double Q_idx = (Q1 + Q3 - Q2);
44  Q += Q_idx;
45 
46  if (Arg::density) {
47  int idx = x_cb + parity * arg.threads;
48  arg.qDensity[idx] = Q_idx / (Pi2 * Pi2);
49  }
50  x_cb += blockDim.x * gridDim.x;
51  }
52  Q /= (Pi2 * Pi2);
53 
54  reduce2d<blockSize, 2>(arg, Q);
55  }
56 
57 } // namespace quda
QChargeArg(const Gauge &data, const GaugeField &Fmunu, Float *qDensity=nullptr)
static constexpr bool density
#define Pi2
__global__ void qChargeComputeKernel(Arg arg)
Main header file for host and device accessors to GaugeFields.
__device__ __host__ T getTrace(const Matrix< T, 3 > &a)
Definition: quda_matrix.h:415
__host__ __device__ ValueType arg(const complex< ValueType > &z)
Returns the phase angle of z.
QudaParity parity
Definition: covdev_test.cpp:54