QUDA  0.9.0
max_gauge.cu
Go to the documentation of this file.
1 #include <gauge_field_order.h>
2 
3 namespace quda {
4 
5  using namespace gauge;
6 
10  template <typename Float, int Nc, typename Order>
11  double maxGauge(const Order order, int volume, int nDim) {
12  typedef typename mapper<Float>::type RegType;
13  RegType max = 0.0;
14 
15  for (int parity=0; parity<2; parity++) {
16 
17  for (int d=0; d<nDim; d++) {
18  for (int x=0; x<volume/2; x++) {
19  RegType v[Nc*Nc*2];
20  order.load(v, x, d, parity);
21  for (int i=0; i<Nc*Nc*2; i++) if (abs(v[i]) > max) { max = abs(v[i]); }
22  }
23  }
24 
25  }
26 
27  return max;
28  }
29 
30  template <typename Float>
31  double maxGauge(const GaugeField &u) {
32 
33  if (typeid(u) != typeid(cpuGaugeField)) errorQuda("Field type not supported");
34 
35  if (u.Ncolor() != 3) errorQuda("Unsupported number of colors; Nc=%d", u.Ncolor());
36  const int Nc = 3;
37 
38  double max;
39  // max only supported on external fields currently
40  if (u.Order() == QUDA_QDP_GAUGE_ORDER) {
41  max = maxGauge<Float,Nc>(QDPOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
42  } else if (u.Order() == QUDA_CPS_WILSON_GAUGE_ORDER) {
43  max = maxGauge<Float,Nc>(CPSOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
44  } else if (u.Order() == QUDA_MILC_GAUGE_ORDER) {
45  max = maxGauge<Float,Nc>(MILCOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
46  } else if (u.Order() == QUDA_BQCD_GAUGE_ORDER) {
47  max = maxGauge<Float,Nc>(BQCDOrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
48  } else if (u.Order() == QUDA_TIFR_GAUGE_ORDER) {
49  max = maxGauge<Float,Nc>(TIFROrder<Float,2*Nc*Nc>(u, (Float*)u.Gauge_p()),u.Volume(),4);
50  } else {
51  errorQuda("Gauge field %d order not supported", u.Order());
52  }
53 
54  reduceMaxDouble(max);
55  return max;
56  }
57 
58  double maxGauge(const GaugeField &u) {
59  double max = 0;
60  if (u.Precision() == QUDA_DOUBLE_PRECISION) {
61  max = maxGauge<double>(u);
62  } else if (u.Precision() == QUDA_SINGLE_PRECISION) {
63  max = maxGauge<float>(u);
64  } else {
65  errorQuda("Precision %d undefined", u.Precision());
66  }
67  return max;
68  }
69 
70 } // namespace quda
double maxGauge(const GaugeField &u)
Definition: max_gauge.cu:31
#define errorQuda(...)
Definition: util_quda.h:90
int Ncolor() const
Definition: gauge_field.h:202
Main header file for host and device accessors to GaugeFields.
__host__ __device__ ValueType abs(ValueType x)
Definition: complex_quda.h:110
virtual void * Gauge_p()
Definition: gauge_field.h:246
QudaGaugeFieldOrder Order() const
Definition: gauge_field.h:204
static __inline__ size_t size_t d
QudaParity parity
Definition: covdev_test.cpp:53
void reduceMaxDouble(double &)