QUDA  v0.7.0
A library for QCD on GPUs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gauge_field.cpp
Go to the documentation of this file.
1 #include <gauge_field.h>
2 #include <typeinfo>
3 
4 namespace quda {
5 
7  LatticeField(param), bytes(0), phase_offset(0), phase_bytes(0), nColor(param.nColor), nFace(param.nFace),
8  geometry(param.geometry), reconstruct(param.reconstruct), order(param.order),
9  fixed(param.fixed), link_type(param.link_type), t_boundary(param.t_boundary),
10  anisotropy(param.anisotropy), tadpole(param.tadpole), fat_link_max(0.0), scale(param.scale),
11  create(param.create), ghostExchange(param.ghostExchange),
12  staggeredPhaseType(param.staggeredPhaseType), staggeredPhaseApplied(param.staggeredPhaseApplied)
13  {
14  if (nColor != 3) errorQuda("nColor must be 3, not %d\n", nColor);
15  if (nDim != 4) errorQuda("Number of dimensions must be 4 not %d", nDim);
16  if (link_type != QUDA_WILSON_LINKS && anisotropy != 1.0) errorQuda("Anisotropy only supported for Wilson links");
18  errorQuda("Temporal gauge fixing only supported for Wilson links");
19 
21  errorQuda("reconstruct %d only supported for staggered long links\n", reconstruct);
22 
24 
27  length = 2*stride*reconstruct; // two comes from being full lattice
28  } else if (geometry == QUDA_VECTOR_GEOMETRY) {
30  length = 2*nDim*stride*reconstruct; // two comes from being full lattice
31  } else if(geometry == QUDA_TENSOR_GEOMETRY){
33  length = 2*(nDim*(nDim-1)/2)*stride*reconstruct; // two comes from being full lattice
34  }
35 
37  for (int d=0; d<nDim; d++) r[d] = param.r[d];
38  } else {
39  for (int d=0; d<nDim; d++) r[d] = 0;
40  }
41 
42 
44  {
45  // Need to adjust the phase alignment as well.
46  int half_phase_bytes = (length/(2*reconstruct))*precision; // number of bytes needed to store phases for a single parity
47  int half_gauge_bytes = (length/2)*precision - half_phase_bytes; // number of bytes needed to store the gauge field for a single parity excluding the phases
48  // Adjust the alignments for the gauge and phase separately
49  half_phase_bytes = ((half_phase_bytes + (512-1))/512)*512;
50  half_gauge_bytes = ((half_gauge_bytes + (512-1))/512)*512;
51 
52  phase_offset = half_gauge_bytes;
53  phase_bytes = half_phase_bytes*2;
54  bytes = (half_gauge_bytes + half_phase_bytes)*2;
55  }else{
58  }
60  }
61 
63 
64  }
65 
67  if (staggeredPhaseApplied) errorQuda("Staggered phases already applied");
68  applyGaugePhase(*this);
70  if (typeid(*this)==typeid(cudaGaugeField)) {
71  static_cast<cudaGaugeField&>(*this).exchangeGhost();
72  } else {
73  static_cast<cpuGaugeField&>(*this).exchangeGhost();
74  }
75  }
76  staggeredPhaseApplied = true;
77  }
78 
80  if (!staggeredPhaseApplied) errorQuda("No staggered phases to remove");
81  applyGaugePhase(*this);
83  if (typeid(*this)==typeid(cudaGaugeField)) {
84  static_cast<cudaGaugeField&>(*this).exchangeGhost();
85  } else {
86  static_cast<cpuGaugeField&>(*this).exchangeGhost();
87  }
88  }
89  staggeredPhaseApplied = false;
90  }
91 
92  bool GaugeField::isNative() const {
94  if (order == QUDA_FLOAT2_GAUGE_ORDER) return true;
95  } else if (precision == QUDA_SINGLE_PRECISION ||
98  if (order == QUDA_FLOAT2_GAUGE_ORDER) return true;
100  if (order == QUDA_FLOAT4_GAUGE_ORDER) return true;
102  if (order == QUDA_FLOAT4_GAUGE_ORDER) return true;
103  } else if (reconstruct == QUDA_RECONSTRUCT_10) {
104  if (order == QUDA_FLOAT2_GAUGE_ORDER) return true;
105  }
106  }
107  return false;
108  }
109 
112  if (a.link_type != link_type) errorQuda("link_type does not match %d %d", link_type, a.link_type);
113  if (a.nColor != nColor) errorQuda("nColor does not match %d %d", nColor, a.nColor);
114  if (a.nFace != nFace) errorQuda("nFace does not match %d %d", nFace, a.nFace);
115  if (a.fixed != fixed) errorQuda("fixed does not match %d %d", fixed, a.fixed);
116  if (a.t_boundary != t_boundary) errorQuda("t_boundary does not match %d %d", t_boundary, a.t_boundary);
117  if (a.anisotropy != anisotropy) errorQuda("anisotropy does not match %e %e", anisotropy, a.anisotropy);
118  if (a.tadpole != tadpole) errorQuda("tadpole does not match %e %e", tadpole, a.tadpole);
119  //if (a.scale != scale) errorQuda("scale does not match %e %e", scale, a.scale);
120  }
121 
122  std::ostream& operator<<(std::ostream& output, const GaugeFieldParam& param) {
123  output << static_cast<const LatticeFieldParam &>(param);
124  output << "nColor = " << param.nColor << std::endl;
125  output << "nFace = " << param.nFace << std::endl;
126  output << "reconstruct = " << param.reconstruct << std::endl;
127  output << "order = " << param.order << std::endl;
128  output << "fixed = " << param.fixed << std::endl;
129  output << "link_type = " << param.link_type << std::endl;
130  output << "t_boundary = " << param.t_boundary << std::endl;
131  output << "anisotropy = " << param.anisotropy << std::endl;
132  output << "tadpole = " << param.tadpole << std::endl;
133  output << "scale = " << param.scale << std::endl;
134  output << "create = " << param.create << std::endl;
135  output << "geometry = " << param.geometry << std::endl;
136  output << "ghostExchange = " << param.ghostExchange << std::endl;
137  for (int i=0; i<param.nDim; i++) {
138  output << "r[" << i << "] = " << param.r[i] << std::endl;
139  }
140  output << "staggeredPhaseType = " << param.staggeredPhaseType << std::endl;
141  output << "staggeredPhaseApplied = " << param.staggeredPhaseApplied << std::endl;
142 
143  return output; // for multiple << operators.
144  }
145 
146 } // namespace quda
QudaTboundary t_boundary
Definition: gauge_field.h:18
virtual ~GaugeField()
Definition: gauge_field.cpp:62
#define errorQuda(...)
Definition: util_quda.h:73
QudaReconstructType reconstruct
Definition: gauge_field.h:130
bool staggeredPhaseApplied
Definition: gauge_field.h:154
void applyGaugePhase(GaugeField &u)
Definition: gauge_phase.cu:261
GaugeField(const GaugeFieldParam &param)
Definition: gauge_field.cpp:6
std::ostream & operator<<(std::ostream &output, const CloverFieldParam &param)
QudaFieldGeometry geometry
Definition: gauge_field.h:128
QudaGaugeParam param
Definition: pack_test.cpp:17
int r[QUDA_MAX_DIM]
Definition: gauge_field.h:145
QudaGaugeFixed fixed
Definition: gauge_field.h:16
#define ALIGNMENT_ADJUST(n)
Definition: quda_internal.h:33
void checkField(const LatticeField &)
QudaGaugeFieldOrder order
Definition: gauge_field.h:15
__constant__ double anisotropy
QudaStaggeredPhase staggeredPhaseType
Definition: gauge_field.h:43
QudaGhostExchange ghostExchange
Definition: gauge_field.h:40
void checkField(const GaugeField &)
QudaGhostExchange ghostExchange
Definition: gauge_field.h:147
QudaLinkType link_type
Definition: gauge_field.h:133
QudaTboundary t_boundary
Definition: gauge_field.h:134
QudaLinkType link_type
Definition: gauge_field.h:17
void applyStaggeredPhase()
Definition: gauge_field.cpp:66
bool isNative() const
Definition: gauge_field.cpp:92
QudaReconstructType reconstruct
Definition: gauge_field.h:14
QudaFieldCreate create
Definition: gauge_field.h:26
__constant__ double t_boundary
QudaFieldGeometry geometry
Definition: gauge_field.h:28
QudaGaugeFieldOrder order
Definition: gauge_field.h:131
QudaPrecision precision
Definition: lattice_field.h:84
QudaGaugeFixed fixed
Definition: gauge_field.h:132
float fat_link_max
int r[QUDA_MAX_DIM]
Definition: gauge_field.h:37
void removeStaggeredPhase()
Definition: gauge_field.cpp:79