QUDA  v0.7.0
A library for QCD on GPUs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
max_gauge.cu
Go to the documentation of this file.
1 #include <gauge_field_order.h>
2 
3 namespace quda {
4 
8  template <typename Float, int Nc, typename Order>
9  double maxGauge(const Order order, int volume, int nDim) {
10  typedef typename mapper<Float>::type RegType;
11  RegType max = 0.0;
12 
13  for (int parity=0; parity<2; parity++) {
14 
15  for (int d=0; d<nDim; d++) {
16  for (int x=0; x<volume/2; x++) {
17  RegType v[Nc*Nc*2];
18  order.load(v, x, d, parity);
19  for (int i=0; i<Nc*Nc*2; i++) if (abs(v[i]) > max) { max = abs(v[i]); }
20  }
21  }
22 
23  }
24 
25  return max;
26  }
27 
28  template <typename Float>
29  double maxGauge(const GaugeField &u) {
30 
31  if (typeid(u) != typeid(cpuGaugeField)) errorQuda("Field type not supported");
32 
33  if (u.Ncolor() != 3) errorQuda("Unsupported number of colors; Nc=%d", u.Ncolor());
34  const int Nc = 3;
35 
36  double max;
37  // max only supported on external fields currently
38  if (u.Order() == QUDA_QDP_GAUGE_ORDER) {
39  max = maxGauge<Float,Nc>(QDPOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
40  } else if (u.Order() == QUDA_CPS_WILSON_GAUGE_ORDER) {
41  max = maxGauge<Float,Nc>(CPSOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
42  } else if (u.Order() == QUDA_MILC_GAUGE_ORDER) {
43  max = maxGauge<Float,Nc>(MILCOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
44  } else if (u.Order() == QUDA_BQCD_GAUGE_ORDER) {
45  max = maxGauge<Float,Nc>(BQCDOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
46  } else if (u.Order() == QUDA_TIFR_GAUGE_ORDER) {
47  max = maxGauge<Float,Nc>(TIFROrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
48  } else {
49  errorQuda("Gauge field %d order not supported", u.Order());
50  }
51 
52  reduceMaxDouble(max);
53  return max;
54  }
55 
56  double maxGauge(const GaugeField &u) {
57  double max = 0;
58  if (u.Precision() == QUDA_DOUBLE_PRECISION) {
59  max = maxGauge<double>(u);
60  } else if (u.Precision() == QUDA_SINGLE_PRECISION) {
61  max = maxGauge<float>(u);
62  } else {
63  errorQuda("Precision %d undefined", u.Precision());
64  }
65  return max;
66  }
67 
68 } // namespace quda
void reduceMaxDouble(double &)
double maxGauge(const GaugeField &u)
Definition: max_gauge.cu:29
int Ncolor() const
Definition: gauge_field.h:167
#define errorQuda(...)
Definition: util_quda.h:73
QudaGaugeFieldOrder Order() const
Definition: gauge_field.h:169
FloatingPoint< float > Float
Definition: gtest.h:7350
int x[4]
__host__ __device__ ValueType abs(ValueType x)
Definition: complex_quda.h:110
virtual void * Gauge_p()
Definition: gauge_field.h:201
const QudaParity parity
Definition: dslash_test.cpp:29