QUDA  v1.1.0
A library for QCD on GPUs
extract_gauge_ghost_mg.cu
Go to the documentation of this file.
1 // trove cannot deal with the large matrices that MG uses so we need
2 // to disable it (regardless we're using fine-grained access)
3 #define DISABLE_TROVE
4 #define FINE_GRAINED_ACCESS
5 
6 #include <gauge_field_order.h>
7 #include <extract_gauge_ghost_helper.cuh>
8 #include <instantiate.h>
9 
10 namespace quda {
11 
12  using namespace gauge;
13 
14  /** This is the template driver for extractGhost */
15  template <typename storeFloat, int Nc>
16  void extractGhostMG(const GaugeField &u, storeFloat **Ghost, bool extract, int offset)
17  {
18  typedef typename mapper<storeFloat>::type Float;
19  constexpr int length = 2*Nc*Nc;
20 
21  if (u.isNative()) {
22  if (u.Reconstruct() == QUDA_RECONSTRUCT_NO) {
23 #ifdef FINE_GRAINED_ACCESS
24  typedef typename gauge::FieldOrder<Float,Nc,1,QUDA_FLOAT2_GAUGE_ORDER,false,storeFloat> G;
25  extractGhost<Float,length>(G(const_cast<GaugeField&>(u), 0, (void**)Ghost), u, extract, offset);
26 #else
27  typedef typename gauge_mapper<Float,QUDA_RECONSTRUCT_NO,length>::type G;
28  extractGhost<Float,length>(G(u, 0, Ghost), u, extract, offset);
29 #endif
30  }
31  } else if (u.Order() == QUDA_QDP_GAUGE_ORDER) {
32 
33 #ifdef BUILD_QDP_INTERFACE
34 #ifdef FINE_GRAINED_ACCESS
35  typedef typename gauge::FieldOrder<Float,Nc,1,QUDA_QDP_GAUGE_ORDER,true,storeFloat> G;
36  extractGhost<Float,length>(G(const_cast<GaugeField&>(u), 0, (void**)Ghost), u, extract, offset);
37 #else
38  extractGhost<Float,length>(QDPOrder<Float,length>(u, 0, Ghost), u, extract, offset);
39 #endif
40 #else
41  errorQuda("QDP interface has not been built\n");
42 #endif
43 
44  } else if (u.Order() == QUDA_MILC_GAUGE_ORDER) {
45  if (u.Reconstruct() == QUDA_RECONSTRUCT_NO) {
46 #ifdef FINE_GRAINED_ACCESS
47  typedef typename gauge::FieldOrder<Float, Nc, 1, QUDA_MILC_GAUGE_ORDER, true, storeFloat> G;
48  extractGhost<Float, length>(G(const_cast<GaugeField &>(u), 0, (void **)Ghost), u, extract, offset);
49 #else
50  typedef typename gauge_mapper<Float, QUDA_RECONSTRUCT_NO, length>::type G;
51  extractGhost<Float, length>(MILCOrder<Float, length>(u, 0, Ghost), u, extract, offset);
52 #endif
53  }
54 
55  } else {
56  errorQuda("Gauge field %d order not supported", u.Order());
57  }
58  }
59 
60  /** This is the template driver for extractGhost */
61  template <typename Float> struct GhostExtractMG {
62  GhostExtractMG(const GaugeField &u, void **Ghost_, bool extract, int offset)
63  {
64  Float **Ghost = reinterpret_cast<Float**>(Ghost_);
65 
66  if (u.Reconstruct() != QUDA_RECONSTRUCT_NO)
67  errorQuda("Reconstruct %d not supported", u.Reconstruct());
68 
69  if (u.LinkType() != QUDA_COARSE_LINKS)
70  errorQuda("Link type %d not supported", u.LinkType());
71 
72  if (u.Ncolor() == 48) {
73  extractGhostMG<Float, 48>(u, Ghost, extract, offset);
74 #ifdef NSPIN4
75  } else if (u.Ncolor() == 12) { // free field Wilson
76  extractGhostMG<Float, 12>(u, Ghost, extract, offset);
77  } else if (u.Ncolor() == 64) {
78  extractGhostMG<Float, 64>(u, Ghost, extract, offset);
79 #endif // NSPIN4
80 #ifdef NSPIN1
81  } else if (u.Ncolor() == 128) {
82  extractGhostMG<Float, 128>(u, Ghost, extract, offset);
83  } else if (u.Ncolor() == 192) {
84  extractGhostMG<Float, 192>(u, Ghost, extract, offset);
85 #endif // NSPIN1
86  } else {
87  errorQuda("Ncolor = %d not supported", u.Ncolor());
88  }
89  }
90  };
91 
92  void extractGaugeGhostMG(const GaugeField &u, void **ghost, bool extract, int offset)
93  {
94 #ifdef GPU_MULTIGRID
95 #ifndef FINE_GRAINED_ACCESS
96  if (u.Precision() < QUDA_SINGLE_PRECISION) errorQuda("Precision format not supported");
97 #endif
98  instantiatePrecisionMG<GhostExtractMG>(u, ghost, extract, offset);
99 #else
100  errorQuda("Multigrid has not been enabled");
101 #endif
102  }
103 
104 } // namespace quda