QUDA  v1.1.0
A library for QCD on GPUs
max_clover.cu
Go to the documentation of this file.
1 #include <clover_field_order.h>
2 
3 namespace quda {
4 
5  using namespace clover;
6 
7  enum norm_type_ {
8  NORM1,
9  NORM2,
10  ABS_MAX,
11  ABS_MIN
12  };
13 
14  template<typename real, int Nc, QudaCloverFieldOrder order>
15  double norm(const CloverField &u, bool inverse, norm_type_ type) {
16  constexpr int Ns = 4;
17  typedef typename mapper<real>::type reg_type;
18  double norm_ = 0.0;
19  switch(type) {
20  case NORM1: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u), inverse).norm1(); break;
21  case NORM2: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u), inverse).norm2(); break;
22  case ABS_MAX: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u), inverse).abs_max(); break;
23  case ABS_MIN: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u), inverse).abs_min(); break;
24  }
25  return norm_;
26  }
27 
28  template<typename real, int Nc>
29  double norm(const CloverField &u, bool inverse, norm_type_ type) {
30  double norm_ = 0.0;
31  switch (u.Order()) {
32  case QUDA_FLOAT2_CLOVER_ORDER: norm_ = norm<real,Nc,QUDA_FLOAT2_CLOVER_ORDER>(u, inverse, type); break;
33  case QUDA_FLOAT4_CLOVER_ORDER: norm_ = norm<real,Nc,QUDA_FLOAT4_CLOVER_ORDER>(u, inverse, type); break;
34  default: errorQuda("Clover field %d order not supported", u.Order());
35  }
36  return norm_;
37  }
38 
39  template<typename real>
40  double _norm(const CloverField &u, bool inverse, norm_type_ type) {
41  double norm_ = 0.0;
42  switch(u.Ncolor()) {
43  case 3: norm_ = norm<real, 3>(u, inverse, type); break;
44  default: errorQuda("Unsupported color %d", u.Ncolor());
45  }
46  return norm_;
47  }
48 
49  double _norm(const CloverField &u, bool inverse, norm_type_ type)
50  {
51  double nrm = 0.0;
52 #ifdef GPU_CLOVER_DIRAC
53  switch(u.Precision()) {
54  case QUDA_DOUBLE_PRECISION: nrm = _norm<double>(u, inverse, type); break;
55  case QUDA_SINGLE_PRECISION: nrm = _norm< float>(u, inverse, type); break;
56  default: errorQuda("Unsupported precision %d", u.Precision());
57  }
58 #else
59  errorQuda("Clover dslash has not been built");
60 #endif
61  return nrm;
62  }
63 
64  double CloverField::norm1(bool inverse) const {
65  return _norm(*this, inverse, NORM1);
66  }
67 
68  double CloverField::norm2(bool inverse) const {
69  return _norm(*this, inverse, NORM2);
70  }
71 
72  double CloverField::abs_max(bool inverse) const {
73  return _norm(*this, inverse, ABS_MAX);
74  }
75 
76  double CloverField::abs_min(bool inverse) const {
77  return _norm(*this, inverse, ABS_MIN);
78  }
79 
80 } // namespace quda