QUDA  v1.1.0
A library for QCD on GPUs
extract_gauge_ghost.cu
Go to the documentation of this file.
1 #include <gauge_field_order.h>
2 #include <extract_gauge_ghost_helper.cuh>
3 #include <instantiate.h>
4 
5 namespace quda {
6 
7  using namespace gauge;
8 
9  /** This is the template driver for extractGhost */
10  template <typename Float> struct GhostExtract {
11  GhostExtract(const GaugeField &u, void **Ghost_, bool extract, int offset)
12  {
13  Float **Ghost = reinterpret_cast<Float**>(Ghost_);
14  const int length = 18;
15 
16  if (u.isNative()) {
17  if (u.Reconstruct() == QUDA_RECONSTRUCT_NO) {
18  typedef typename gauge_mapper<Float, QUDA_RECONSTRUCT_NO>::type G;
19  extractGhost<Float, length>(G(u, 0, Ghost), u, extract, offset);
20  } else if (u.Reconstruct() == QUDA_RECONSTRUCT_12) {
21 #if QUDA_RECONSTRUCT & 2
22  typedef typename gauge_mapper<Float,QUDA_RECONSTRUCT_12>::type G;
23  extractGhost<Float,length>(G(u, 0, Ghost), u, extract, offset);
24 #else
25  errorQuda("QUDA_RECONSTRUCT = %d does not enable QUDA_RECONSTRUCT_12", QUDA_RECONSTRUCT);
26 #endif
27  } else if (u.Reconstruct() == QUDA_RECONSTRUCT_8) {
28 #if QUDA_RECONSTRUCT & 1
29  typedef typename gauge_mapper<Float,QUDA_RECONSTRUCT_8>::type G;
30  extractGhost<Float,length>(G(u, 0, Ghost), u, extract, offset);
31 #else
32  errorQuda("QUDA_RECONSTRUCT = %d does not enable QUDA_RECONSTRUCT_8", QUDA_RECONSTRUCT);
33 #endif
34  } else if (u.Reconstruct() == QUDA_RECONSTRUCT_13) {
35 #if QUDA_RECONSTRUCT & 2
36  typedef typename gauge_mapper<Float,QUDA_RECONSTRUCT_13>::type G;
37  extractGhost<Float,length>(G(u, 0, Ghost), u, extract, offset);
38 #else
39  errorQuda("QUDA_RECONSTRUCT = %d does not enable QUDA_RECONSTRUCT_13", QUDA_RECONSTRUCT);
40 #endif
41  } else if (u.Reconstruct() == QUDA_RECONSTRUCT_9) {
42 #if QUDA_RECONSTRUCT & 1
43  if (u.StaggeredPhase() == QUDA_STAGGERED_PHASE_MILC) {
44  typedef typename gauge_mapper<Float, QUDA_RECONSTRUCT_9, 18, QUDA_STAGGERED_PHASE_MILC>::type G;
45  extractGhost<Float, length>(G(u, 0, Ghost), u, extract, offset);
46  } else if (u.StaggeredPhase() == QUDA_STAGGERED_PHASE_NO) {
47  typedef typename gauge_mapper<Float, QUDA_RECONSTRUCT_9>::type G;
48  extractGhost<Float, length>(G(u, 0, Ghost), u, extract, offset);
49  } else {
50  errorQuda("Staggered phase type %d not supported", u.StaggeredPhase());
51  }
52 #else
53  errorQuda("QUDA_RECONSTRUCT = %d does not enable QUDA_RECONSTRUCT_9", QUDA_RECONSTRUCT);
54 #endif
55  }
56  } else if (u.Order() == QUDA_QDP_GAUGE_ORDER) {
57 
58 #ifdef BUILD_QDP_INTERFACE
59  extractGhost<Float,length>(QDPOrder<Float,length>(u, 0, Ghost), u, extract, offset);
60 #else
61  errorQuda("QDP interface has not been built\n");
62 #endif
63 
64  } else if (u.Order() == QUDA_QDPJIT_GAUGE_ORDER) {
65 
66 #ifdef BUILD_QDPJIT_INTERFACE
67  extractGhost<Float,length>(QDPJITOrder<Float,length>(u, 0, Ghost), u, extract, offset);
68 #else
69  errorQuda("QDPJIT interface has not been built\n");
70 #endif
71 
72  } else if (u.Order() == QUDA_CPS_WILSON_GAUGE_ORDER) {
73 
74 #ifdef BUILD_CPS_INTERFACE
75  extractGhost<Float,length>(CPSOrder<Float,length>(u, 0, Ghost), u, extract, offset);
76 #else
77  errorQuda("CPS interface has not been built\n");
78 #endif
79 
80  } else if (u.Order() == QUDA_MILC_GAUGE_ORDER) {
81 
82 #ifdef BUILD_MILC_INTERFACE
83  extractGhost<Float,length>(MILCOrder<Float,length>(u, 0, Ghost), u, extract, offset);
84 #else
85  errorQuda("MILC interface has not been built\n");
86 #endif
87 
88  } else if (u.Order() == QUDA_BQCD_GAUGE_ORDER) {
89 
90 #ifdef BUILD_BQCD_INTERFACE
91  extractGhost<Float,length>(BQCDOrder<Float,length>(u, 0, Ghost), u, extract, offset);
92 #else
93  errorQuda("BQCD interface has not been built\n");
94 #endif
95 
96  } else if (u.Order() == QUDA_TIFR_GAUGE_ORDER) {
97 
98 #ifdef BUILD_TIFR_INTERFACE
99  extractGhost<Float,length>(TIFROrder<Float,length>(u, 0, Ghost), u, extract, offset);
100 #else
101  errorQuda("TIFR interface has not been built\n");
102 #endif
103 
104  } else if (u.Order() == QUDA_TIFR_PADDED_GAUGE_ORDER) {
105 
106 #ifdef BUILD_TIFR_INTERFACE
107  extractGhost<Float,length>(TIFRPaddedOrder<Float,length>(u, 0, Ghost), u, extract, offset);
108 #else
109  errorQuda("TIFR interface has not been built\n");
110 #endif
111 
112  } else {
113  errorQuda("Gauge field %d order not supported", u.Order());
114  }
115 
116  }
117  };
118 
119  void extractGaugeGhostMG(const GaugeField &u, void **ghost, bool extract, int offset);
120 
121  void extractGaugeGhost(const GaugeField &u, void **ghost, bool extract, int offset) {
122 
123  // if number of colors doesn't equal three then we must have
124  // coarse-gauge field
125  if (u.Ncolor() != 3) {
126  extractGaugeGhostMG(u, ghost, extract, offset);
127  } else {
128  instantiatePrecision<GhostExtract>(u, ghost, extract, offset);
129  }
130  }
131 
132 } // namespace quda