QUDA: quda/lib/gauge_observable.cpp Source File

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 
7   void gaugeObservables(GaugeField &u, QudaGaugeObservableParam &param, TimeProfile &profile)
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;
14  auto tol = u.Precision() == QUDA_DOUBLE_PRECISION ? 1e-14 : QUDA_SINGLE_PRECISION;
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];
36  GaugeFieldParam tensorParam(x, u.Precision(), QUDA_RECONSTRUCT_NO, 0, QUDA_TENSOR_GEOMETRY);
37  tensorParam.siteSubset = QUDA_FULL_SITE_SUBSET;
38  tensorParam.order = QUDA_FLOAT2_GAUGE_ORDER;
39  tensorParam.ghostExchange = QUDA_GHOST_EXCHANGE_NO;
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
quda::LatticeField::Volume
size_t Volume() const
Definition: lattice_field.h:515
quda::LatticeField::Precision
QudaPrecision Precision() const
Definition: lattice_field.h:567
quda::LatticeField::R
const int * R() const
Definition: lattice_field.h:557
quda::LatticeField::X
const int * X() const
Definition: lattice_field.h:505
tol
double tol
Definition: command_line_params.cpp:86
QUDA_FULL_SITE_SUBSET
@ QUDA_FULL_SITE_SUBSET
Definition: enum_quda.h:333
QUDA_RECONSTRUCT_NO
@ QUDA_RECONSTRUCT_NO
Definition: enum_quda.h:70
QUDA_TENSOR_GEOMETRY
@ QUDA_TENSOR_GEOMETRY
Definition: enum_quda.h:502
QUDA_GHOST_EXCHANGE_NO
@ QUDA_GHOST_EXCHANGE_NO
Definition: enum_quda.h:508
QUDA_DOUBLE_PRECISION
@ QUDA_DOUBLE_PRECISION
Definition: enum_quda.h:65
QUDA_SINGLE_PRECISION
@ QUDA_SINGLE_PRECISION
Definition: enum_quda.h:64
QUDA_FLOAT2_GAUGE_ORDER
@ QUDA_FLOAT2_GAUGE_ORDER
Definition: enum_quda.h:40
pool_pinned_malloc
#define pool_pinned_malloc(size)
Definition: malloc_quda.h:172
pool_device_malloc
#define pool_device_malloc(size)
Definition: malloc_quda.h:170
pool_pinned_free
#define pool_pinned_free(ptr)
Definition: malloc_quda.h:173
pool_device_free
#define pool_device_free(ptr)
Definition: malloc_quda.h:171
get_mapped_device_pointer
#define get_mapped_device_pointer(ptr)
Definition: malloc_quda.h:116
quda
Definition: blas_lapack.h:24
quda::gaugeObservables
void gaugeObservables(GaugeField &u, QudaGaugeObservableParam &param, TimeProfile &profile)
Calculates a variety of gauge-field observables.
Definition: gauge_observable.cpp:7
quda::plaquette
double3 plaquette(const GaugeField &U)
Compute the plaquette of the gauge field.
quda::computeQCharge
void computeQCharge(double energy[3], double &qcharge, const GaugeField &Fmunu)
Compute the topological charge and field energy.
quda::QUDA_PROFILE_INIT
@ QUDA_PROFILE_INIT
Definition: timer.h:106
quda::QUDA_PROFILE_COMPUTE
@ QUDA_PROFILE_COMPUTE
Definition: timer.h:108
quda::QUDA_PROFILE_TOTAL
@ QUDA_PROFILE_TOTAL
Definition: timer.h:149
quda::QUDA_PROFILE_FREE
@ QUDA_PROFILE_FREE
Definition: timer.h:111
quda::QUDA_PROFILE_D2H
@ QUDA_PROFILE_D2H
Definition: timer.h:105
quda::computeFmunu
void computeFmunu(GaugeField &Fmunu, const GaugeField &gauge)
Compute the Fmunu tensor.
quda::projectSU3
void projectSU3(GaugeField &U, double tol, int *fails)
Project the input gauge field onto the SU(3) group. This is a destructive operation....
quda::computeQChargeDensity
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.
param
QudaGaugeParam param
Definition: pack_test.cpp:18
qudaMemcpy
#define qudaMemcpy(dst, src, count, kind)
Definition: quda_api.h:204
quda::GaugeFieldParam::order
QudaGaugeFieldOrder order
Definition: gauge_field.h:51
quda::LatticeFieldParam::ghostExchange
QudaGhostExchange ghostExchange
Definition: lattice_field.h:77
quda::LatticeFieldParam::siteSubset
QudaSiteSubset siteSubset
Definition: lattice_field.h:72
errorQuda
#define errorQuda(...)
Definition: util_quda.h:120

Generated on Thu Oct 28 2021 16:10:27 for QUDA by doxygen 1.9.1

AltStyle によって変換されたページ (->オリジナル) /