QUDA  v1.1.0
A library for QCD on GPUs
gauge_observable.cpp
Go to the documentation of this file.
1 #include <gauge_field.h>
2 #include <gauge_tools.h>
3 
4 namespace quda
5 {
6 
8  {
9  profile.TPSTART(QUDA_PROFILE_COMPUTE);
10  if (param.su_project) {
11  int *num_failures_h = static_cast<int *>(pool_pinned_malloc(sizeof(int)));
12  int *num_failures_d = static_cast<int *>(get_mapped_device_pointer(num_failures_h));
13  *num_failures_h = 0;
15  projectSU3(u, tol, num_failures_d);
16  if (*num_failures_h > 0) errorQuda("Error in the SU(3) unitarization: %d failures\n", *num_failures_h);
17  pool_pinned_free(num_failures_h);
18  }
19 
20  if (param.compute_plaquette) {
21  double3 plaq = plaquette(u);
22  param.plaquette[0] = plaq.x;
23  param.plaquette[1] = plaq.y;
24  param.plaquette[2] = plaq.z;
25  }
26  profile.TPSTOP(QUDA_PROFILE_COMPUTE);
27 
28  // no point constructing Fmunu unless we are going to use it
29  if (!param.compute_qcharge && !param.compute_qcharge_density) return;
30 
31  // create the Fmunu field
32  profile.TPSTART(QUDA_PROFILE_INIT);
33  // u is an extended field we need to shrink for the Fmunu field
34  int x[4];
35  for (int i = 0; i < 4; i++) x[i] = u.X()[i] - 2 * u.R()[i];
37  tensorParam.siteSubset = QUDA_FULL_SITE_SUBSET;
38  tensorParam.order = QUDA_FLOAT2_GAUGE_ORDER;
40  cudaGaugeField gaugeFmunu(tensorParam);
41  profile.TPSTOP(QUDA_PROFILE_INIT);
42 
43  profile.TPSTART(QUDA_PROFILE_COMPUTE);
44  computeFmunu(gaugeFmunu, u);
45  profile.TPSTOP(QUDA_PROFILE_COMPUTE);
46  profile.TPSTOP(QUDA_PROFILE_TOTAL);
47 
48  if (param.compute_qcharge || param.compute_qcharge_density) {
49  profile.TPSTART(QUDA_PROFILE_TOTAL);
50  profile.TPSTART(QUDA_PROFILE_INIT);
51  if (param.compute_qcharge_density && !param.qcharge_density)
52  errorQuda("Charge density requested, but destination field not defined");
53  size_t size = gaugeFmunu.Volume() * gaugeFmunu.Precision();
54  void *d_qDensity = param.compute_qcharge_density ? pool_device_malloc(size) : nullptr;
55  profile.TPSTOP(QUDA_PROFILE_INIT);
56 
57  profile.TPSTART(QUDA_PROFILE_COMPUTE);
58 
59  if (param.compute_qcharge_density)
60  computeQChargeDensity(param.energy, param.qcharge, d_qDensity, gaugeFmunu);
61  else
62  computeQCharge(param.energy, param.qcharge, gaugeFmunu);
63 
64  profile.TPSTOP(QUDA_PROFILE_COMPUTE);
65 
66  if (param.compute_qcharge_density) {
67  profile.TPSTART(QUDA_PROFILE_D2H);
68  qudaMemcpy(param.qcharge_density, d_qDensity, size, cudaMemcpyDeviceToHost);
69  profile.TPSTOP(QUDA_PROFILE_D2H);
70 
71  profile.TPSTART(QUDA_PROFILE_FREE);
72  pool_device_free(d_qDensity);
73  profile.TPSTOP(QUDA_PROFILE_FREE);
74  }
75  }
76  }
77 
78 } // namespace quda
size_t Volume() const
QudaPrecision Precision() const
const int * R() const
const int * X() const
double tol
@ QUDA_FULL_SITE_SUBSET
Definition: enum_quda.h:333
@ QUDA_RECONSTRUCT_NO
Definition: enum_quda.h:70
@ QUDA_TENSOR_GEOMETRY
Definition: enum_quda.h:502
@ QUDA_GHOST_EXCHANGE_NO
Definition: enum_quda.h:508
@ QUDA_DOUBLE_PRECISION
Definition: enum_quda.h:65
@ QUDA_SINGLE_PRECISION
Definition: enum_quda.h:64
@ QUDA_FLOAT2_GAUGE_ORDER
Definition: enum_quda.h:40
#define pool_pinned_malloc(size)
Definition: malloc_quda.h:172
#define pool_device_malloc(size)
Definition: malloc_quda.h:170
#define pool_pinned_free(ptr)
Definition: malloc_quda.h:173
#define pool_device_free(ptr)
Definition: malloc_quda.h:171
#define get_mapped_device_pointer(ptr)
Definition: malloc_quda.h:116
void gaugeObservables(GaugeField &u, QudaGaugeObservableParam &param, TimeProfile &profile)
Calculates a variety of gauge-field observables.
double3 plaquette(const GaugeField &U)
Compute the plaquette of the gauge field.
void computeQCharge(double energy[3], double &qcharge, const GaugeField &Fmunu)
Compute the topological charge and field energy.
@ QUDA_PROFILE_INIT
Definition: timer.h:106
@ QUDA_PROFILE_COMPUTE
Definition: timer.h:108
@ QUDA_PROFILE_TOTAL
Definition: timer.h:149
@ QUDA_PROFILE_FREE
Definition: timer.h:111
@ QUDA_PROFILE_D2H
Definition: timer.h:105
void computeFmunu(GaugeField &Fmunu, const GaugeField &gauge)
Compute the Fmunu tensor.
void projectSU3(GaugeField &U, double tol, int *fails)
Project the input gauge field onto the SU(3) group. This is a destructive operation....
void computeQChargeDensity(double energy[3], double &qcharge, void *qdensity, const GaugeField &Fmunu)
Compute the topological charge, field energy and the topological charge density per lattice site.
QudaGaugeParam param
Definition: pack_test.cpp:18
#define qudaMemcpy(dst, src, count, kind)
Definition: quda_api.h:204
QudaGaugeFieldOrder order
Definition: gauge_field.h:51
QudaGhostExchange ghostExchange
Definition: lattice_field.h:77
QudaSiteSubset siteSubset
Definition: lattice_field.h:72
#define errorQuda(...)
Definition: util_quda.h:120