1 #include <gauge_field.h>
2 #include <gauge_field_order.h>
4 #include <kernels/copy_field_offset.cuh>
5 #include <instantiate.h>
10 template <class Field, class Element, class G> void copy_gauge_offset(Field &out, const Field &in, CommKey offset)
14 CopyFieldOffsetArg<Field, Element, G> arg(out_accessor, out, in_accessor, in, offset);
15 CopyFieldOffset<decltype(arg)> copier(arg, in);
18 template <typename Float, int nColor> struct CopyGaugeOffset {
19 CopyGaugeOffset(GaugeField &out, const GaugeField &in, CommKey offset)
21 using Field = GaugeField;
22 using real = typename mapper<Float>::type;
23 using Element = Matrix<complex<real>, nColor>;
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);
34 errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-12", QUDA_RECONSTRUCT);
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);
41 errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-8", QUDA_RECONSTRUCT);
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);
49 errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-13", QUDA_RECONSTRUCT);
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);
56 errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-9", QUDA_RECONSTRUCT);
58 #endif // GPU_STAGGERED_DIRAC
60 errorQuda("Reconstruction %d and order %d not supported", in.Reconstruct(), in.Order());
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);
67 errorQuda("QDP interface has not been built\n");
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);
74 errorQuda("QDP interface has not been built\n");
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);
82 errorQuda("MILC interface has not been built\n");
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);
89 errorQuda("CPS interface has not been built\n");
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);
96 errorQuda("BQCD interface has not been built\n");
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);
103 errorQuda("TIFR interface has not been built\n");
106 errorQuda("Gauge field %d order not supported", in.Order());
111 void copyFieldOffset(GaugeField &out, const GaugeField &in, CommKey offset, QudaPCType pc_type)
113 checkPrecision(out, in);
114 checkLocation(out, in); // check all locations match
115 checkReconstruct(out, in);
117 if (pc_type != QUDA_4D_PC) { errorQuda("Gauge field copy must use 4d even-odd preconditioning."); }
119 if (out.Geometry() != in.Geometry()) {
120 errorQuda("Field geometries %d %d do not match", out.Geometry(), in.Geometry());
123 instantiate<CopyGaugeOffset>(out, in, offset);