QUDA  v1.1.0
A library for QCD on GPUs
copy_gauge_offset.cu
Go to the documentation of this file.
1 #include <gauge_field.h>
2 #include <gauge_field_order.h>
3 
4 #include <kernels/copy_field_offset.cuh>
5 #include <instantiate.h>
6 
7 namespace quda
8 {
9 
10  template <class Field, class Element, class G> void copy_gauge_offset(Field &out, const Field &in, CommKey offset)
11  {
12  G out_accessor(out);
13  G in_accessor(in);
14  CopyFieldOffsetArg<Field, Element, G> arg(out_accessor, out, in_accessor, in, offset);
15  CopyFieldOffset<decltype(arg)> copier(arg, in);
16  }
17 
18  template <typename Float, int nColor> struct CopyGaugeOffset {
19  CopyGaugeOffset(GaugeField &out, const GaugeField &in, CommKey offset)
20  {
21  using Field = GaugeField;
22  using real = typename mapper<Float>::type;
23  using Element = Matrix<complex<real>, nColor>;
24 
25  if (in.isNative()) {
26  if (in.Reconstruct() == QUDA_RECONSTRUCT_NO) {
27  using G = typename gauge_mapper<Float, QUDA_RECONSTRUCT_NO>::type;
28  copy_gauge_offset<Field, Element, G>(out, in, offset);
29  } else if (in.Reconstruct() == QUDA_RECONSTRUCT_12) {
30 #if QUDA_RECONSTRUCT & 2
31  using G = typename gauge_mapper<Float, QUDA_RECONSTRUCT_12>::type;
32  copy_gauge_offset<Field, Element, G>(out, in, offset);
33 #else
34  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-12", QUDA_RECONSTRUCT);
35 #endif
36  } else if (in.Reconstruct() == QUDA_RECONSTRUCT_8) {
37 #if QUDA_RECONSTRUCT & 1
38  using G = typename gauge_mapper<Float, QUDA_RECONSTRUCT_8>::type;
39  copy_gauge_offset<Field, Element, G>(out, in, offset);
40 #else
41  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-8", QUDA_RECONSTRUCT);
42 #endif
43 #ifdef GPU_STAGGERED_DIRAC
44  } else if (in.Reconstruct() == QUDA_RECONSTRUCT_13) {
45 #if QUDA_RECONSTRUCT & 2
46  using G = typename gauge_mapper<Float, QUDA_RECONSTRUCT_13>::type;
47  copy_gauge_offset<Field, Element, G>(out, in, offset);
48 #else
49  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-13", QUDA_RECONSTRUCT);
50 #endif
51  } else if (in.Reconstruct() == QUDA_RECONSTRUCT_9) {
52 #if QUDA_RECONSTRUCT & 1
53  using G = typename gauge_mapper<Float, QUDA_RECONSTRUCT_9>::type;
54  copy_gauge_offset<Field, Element, G>(out, in, offset);
55 #else
56  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-9", QUDA_RECONSTRUCT);
57 #endif
58 #endif // GPU_STAGGERED_DIRAC
59  } else {
60  errorQuda("Reconstruction %d and order %d not supported", in.Reconstruct(), in.Order());
61  }
62  } else if (in.Order() == QUDA_QDP_GAUGE_ORDER) {
63 #ifdef BUILD_QDP_INTERFACE
64  using G = typename gauge_order_mapper<Float, QUDA_QDP_GAUGE_ORDER, nColor>::type;
65  copy_gauge_offset<Field, Element, G>(out, in, offset);
66 #else
67  errorQuda("QDP interface has not been built\n");
68 #endif
69  } else if (in.Order() == QUDA_QDPJIT_GAUGE_ORDER) {
70 #ifdef BUILD_QDPJIT_INTERFACE
71  using G = typename gauge_order_mapper<Float, QUDA_QDPJIT_GAUGE_ORDER, nColor>::type;
72  copy_gauge_offset<Field, Element, G>(out, in, offset);
73 #else
74  errorQuda("QDP interface has not been built\n");
75 #endif
76 
77  } else if (in.Order() == QUDA_MILC_GAUGE_ORDER) {
78 #ifdef BUILD_MILC_INTERFACE
79  using G = typename gauge_order_mapper<Float, QUDA_MILC_GAUGE_ORDER, nColor>::type;
80  copy_gauge_offset<Field, Element, G>(out, in, offset);
81 #else
82  errorQuda("MILC interface has not been built\n");
83 #endif
84  } else if (in.Order() == QUDA_CPS_WILSON_GAUGE_ORDER) {
85 #ifdef BUILD_CPS_INTERFACE
86  using G = typename gauge_order_mapper<Float, QUDA_CPS_WILSON_GAUGE_ORDER, nColor>::type;
87  copy_gauge_offset<Field, Element, G>(out, in, offset);
88 #else
89  errorQuda("CPS interface has not been built\n");
90 #endif
91  } else if (in.Order() == QUDA_BQCD_GAUGE_ORDER) {
92 #ifdef BUILD_BQCD_INTERFACE
93  using G = typename gauge_order_mapper<Float, QUDA_BQCD_GAUGE_ORDER, nColor>::type;
94  copy_gauge_offset<Field, Element, G>(out, in, offset);
95 #else
96  errorQuda("BQCD interface has not been built\n");
97 #endif
98  } else if (in.Order() == QUDA_TIFR_GAUGE_ORDER) {
99 #ifdef BUILD_TIFR_INTERFACE
100  using G = typename gauge_order_mapper<Float, QUDA_TIFR_GAUGE_ORDER, nColor>::type;
101  copy_gauge_offset<Field, Element, G>(out, in, offset);
102 #else
103  errorQuda("TIFR interface has not been built\n");
104 #endif
105  } else {
106  errorQuda("Gauge field %d order not supported", in.Order());
107  }
108  }
109  };
110 
111  void copyFieldOffset(GaugeField &out, const GaugeField &in, CommKey offset, QudaPCType pc_type)
112  {
113  checkPrecision(out, in);
114  checkLocation(out, in); // check all locations match
115  checkReconstruct(out, in);
116 
117  if (pc_type != QUDA_4D_PC) { errorQuda("Gauge field copy must use 4d even-odd preconditioning."); }
118 
119  if (out.Geometry() != in.Geometry()) {
120  errorQuda("Field geometries %d %d do not match", out.Geometry(), in.Geometry());
121  }
122 
123  instantiate<CopyGaugeOffset>(out, in, offset);
124  }
125 
126 } // namespace quda