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)
4 #define FINE_GRAINED_ACCESS
6 #include <gauge_field_order.h>
7 #include <extract_gauge_ghost_helper.cuh>
8 #include <instantiate.h>
12 using namespace gauge;
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)
18 typedef typename mapper<storeFloat>::type Float;
19 constexpr int length = 2*Nc*Nc;
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);
27 typedef typename gauge_mapper<Float,QUDA_RECONSTRUCT_NO,length>::type G;
28 extractGhost<Float,length>(G(u, 0, Ghost), u, extract, offset);
31 } else if (u.Order() == QUDA_QDP_GAUGE_ORDER) {
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);
38 extractGhost<Float,length>(QDPOrder<Float,length>(u, 0, Ghost), u, extract, offset);
41 errorQuda("QDP interface has not been built\n");
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);
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);
56 errorQuda("Gauge field %d order not supported", u.Order());
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)
64 Float **Ghost = reinterpret_cast<Float**>(Ghost_);
66 if (u.Reconstruct() != QUDA_RECONSTRUCT_NO)
67 errorQuda("Reconstruct %d not supported", u.Reconstruct());
69 if (u.LinkType() != QUDA_COARSE_LINKS)
70 errorQuda("Link type %d not supported", u.LinkType());
72 if (u.Ncolor() == 48) {
73 extractGhostMG<Float, 48>(u, Ghost, extract, offset);
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);
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);
87 errorQuda("Ncolor = %d not supported", u.Ncolor());
92 void extractGaugeGhostMG(const GaugeField &u, void **ghost, bool extract, int offset)
95 #ifndef FINE_GRAINED_ACCESS
96 if (u.Precision() < QUDA_SINGLE_PRECISION) errorQuda("Precision format not supported");
98 instantiatePrecisionMG<GhostExtractMG>(u, ghost, extract, offset);
100 errorQuda("Multigrid has not been enabled");