QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
7  enum norm_type_ {
8  NORM1,
9  NORM2,
10  ABS_MAX,
11  ABS_MIN
12  };
13 
14  template<typename real, int Nc, QudaGaugeFieldOrder order>
15  double norm(const GaugeField &u, int d, norm_type_ type) {
16  typedef typename mapper<real>::type reg_type;
17  double norm_ = 0.0;
18  switch(type) {
19  case NORM1: norm_ = FieldOrder<reg_type,Nc,1,order,true,real>(const_cast<GaugeField &>(u)).norm1(d); break;
20  case NORM2: norm_ = FieldOrder<reg_type,Nc,1,order,true,real>(const_cast<GaugeField &>(u)).norm2(d); break;
21  case ABS_MAX: norm_ = FieldOrder<reg_type,Nc,1,order,true,real>(const_cast<GaugeField &>(u)).abs_max(d); break;
22  case ABS_MIN: norm_ = FieldOrder<reg_type,Nc,1,order,true,real>(const_cast<GaugeField &>(u)).abs_min(d); break;
23  }
24  return norm_;
25  }
26 
27  template<typename real, int Nc>
28  double norm(const GaugeField &u, int d, norm_type_ type) {
29  double norm_ = 0.0;
30  switch (u.FieldOrder()) {
31  case QUDA_FLOAT2_GAUGE_ORDER: norm_ = norm<real,Nc,QUDA_FLOAT2_GAUGE_ORDER>(u, d, type); break;
32  case QUDA_QDP_GAUGE_ORDER: norm_ = norm<real,Nc, QUDA_QDP_GAUGE_ORDER>(u, d, type); break;
33  case QUDA_MILC_GAUGE_ORDER: norm_ = norm<real,Nc, QUDA_MILC_GAUGE_ORDER>(u, d, type); break;
34  default: errorQuda("Gauge field %d order not supported", u.Order());
35  }
36  return norm_;
37  }
38 
39  template<typename real>
40  double norm(const GaugeField &u, int d, norm_type_ type) {
41  double norm_ = 0.0;
42  switch(u.Ncolor()) {
43  case 3: norm_ = norm<real, 3>(u, d, type); break;
44  case 8: norm_ = norm<real, 8>(u, d, type); break;
45  case 12: norm_ = norm<real,12>(u, d, type); break;
46  case 16: norm_ = norm<real,16>(u, d, type); break;
47  case 24: norm_ = norm<real,24>(u, d, type); break;
48  case 32: norm_ = norm<real,32>(u, d, type); break;
49  case 40: norm_ = norm<real,40>(u, d, type); break;
50  case 48: norm_ = norm<real,48>(u, d, type); break;
51  case 56: norm_ = norm<real,56>(u, d, type); break;
52  case 64: norm_ = norm<real,64>(u, d, type); break;
53  default: errorQuda("Unsupported color %d", u.Ncolor());
54  }
55  return norm_;
56  }
57 
58  double GaugeField::norm1(int d) const {
59  if (reconstruct != QUDA_RECONSTRUCT_NO) errorQuda("Unsupported reconstruct=%d", reconstruct);
60  double nrm1 = 0.0;
61  switch(precision) {
62  case QUDA_DOUBLE_PRECISION: nrm1 = norm<double>(*this, d, NORM1); break;
63  case QUDA_SINGLE_PRECISION: nrm1 = norm<float>(*this, d, NORM1); break;
64  case QUDA_HALF_PRECISION: nrm1 = norm<short>(*this, d, NORM1); break;
65  case QUDA_QUARTER_PRECISION: nrm1 = norm<char>(*this, d, NORM1); break;
66  default: errorQuda("Unsupported precision %d", precision);
67  }
68  return nrm1;
69  }
70 
71  double GaugeField::norm2(int d) const {
72  if (reconstruct != QUDA_RECONSTRUCT_NO) errorQuda("Unsupported reconstruct=%d", reconstruct);
73  double nrm2 = 0.0;
74  switch(precision) {
75  case QUDA_DOUBLE_PRECISION: nrm2 = norm<double>(*this, d, NORM2); break;
76  case QUDA_SINGLE_PRECISION: nrm2 = norm<float>(*this, d, NORM2); break;
77  case QUDA_HALF_PRECISION: nrm2 = norm<short>(*this, d, NORM2); break;
78  case QUDA_QUARTER_PRECISION: nrm2 = norm<char>(*this, d, NORM2); break;
79  default: errorQuda("Unsupported precision %d", precision);
80  }
81  return nrm2;
82  }
83 
84  double GaugeField::abs_max(int d) const {
85  if (reconstruct != QUDA_RECONSTRUCT_NO) errorQuda("Unsupported reconstruct=%d", reconstruct);
86  double max = 0.0;
87  switch(precision) {
88  case QUDA_DOUBLE_PRECISION: max = norm<double>(*this, d, ABS_MAX); break;
89  case QUDA_SINGLE_PRECISION: max = norm<float>(*this, d, ABS_MAX); break;
90  case QUDA_HALF_PRECISION: max = norm<short>(*this, d, ABS_MAX); break;
91  case QUDA_QUARTER_PRECISION: max = norm<char>(*this, d, ABS_MAX); break;
92  default: errorQuda("Unsupported precision %d", precision);
93  }
94  return max;
95  }
96 
97  double GaugeField::abs_min(int d) const {
98  if (reconstruct != QUDA_RECONSTRUCT_NO) errorQuda("Unsupported reconstruct=%d", reconstruct);
99  double min = 0.0;
100  switch(precision) {
101  case QUDA_DOUBLE_PRECISION: min = norm<double>(*this, d, ABS_MIN); break;
102  case QUDA_SINGLE_PRECISION: min = norm<float>(*this, d, ABS_MIN); break;
103  case QUDA_HALF_PRECISION: min = norm<short>(*this, d, ABS_MIN); break;
104  case QUDA_QUARTER_PRECISION: min = norm<char>(*this, d, ABS_MIN); break;
105  default: errorQuda("Unsupported precision %d", precision);
106  }
107  return min;
108  }
109 
110 } // namespace quda
norm_type_
Definition: max_clover.cu:7
QudaGaugeFieldOrder FieldOrder() const
Definition: gauge_field.h:257
__host__ __device__ ValueType norm(const complex< ValueType > &z)
Returns the magnitude of z squared.
#define errorQuda(...)
Definition: util_quda.h:121
double abs_max(int dim=-1) const
Compute the absolute maximum of the field (Linfinity norm)
Definition: max_gauge.cu:84
int Ncolor() const
Definition: gauge_field.h:249
__host__ double abs_max(int dim=-1, bool global=true) const
Returns the Linfinity norm of the field.
Main header file for host and device accessors to GaugeFields.
double norm2(int dim=-1) const
Compute the L2 norm squared of the field.
Definition: max_gauge.cu:71
__host__ double norm2(int dim=-1, bool global=true) const
Returns the L2 norm suared of the field.
double norm1(int dim=-1) const
Compute the L1 norm of the field.
Definition: max_gauge.cu:58
__host__ double norm1(int dim=-1, bool global=true) const
Returns the L1 norm of the field.
double abs_min(int dim=-1) const
Compute the absolute minimum of the field.
Definition: max_gauge.cu:97
__host__ double abs_min(int dim=-1, bool global=true) const
Returns the minimum absolute value of the field.