QDP++
qdp_scalarvecsite_specific.cc
Go to the documentation of this file.
1
8
9
10#include "qdp.h"
11#include "qdp_util.h"
12
13namespace QDP {
14
15//-----------------------------------------------------------------------------
16namespace Layout
17{
19 /* Assumes no inner grid */
21 {
23
24 if (mu < 0 || mu >= Nd)
25 QDP_error_exit("dimension out of bounds");
26
27 const int nodeSites = Layout::sitesOnNode();
28
29 for(int i=0; i < nodeSites; ++i)
30 {
32 int iouter = i >> INNER_LOG;
33 int iinner = i & ((1 <<INNER_LOG)-1);
34 copy_site(d.elem(iouter), iinner, cc.elem());
35 }
36
37 return d;
38 }
39}
40
41
42//-----------------------------------------------------------------------------
43// IO routine solely for debugging. Only defined here
44template<class T>
45std::ostream& operator<<(std::ostream& s, const multi1d<T>& s1)
46{
47 for(int i=0; i < s1.size(); ++i)
48 s << " " << s1[i];
49
50 return s;
51}
52
53
54//-----------------------------------------------------------------------------
56void Set::make(const SetFunc& func)
57{
58 int nsubset_indices = func.numSubsets();
59 const int nodeSites = Layout::sitesOnNode();
60
61#if QDP_DEBUG >= 2
62 QDP_info("Set a subset: nsubset = %d",nsubset_indices);
63#endif
64
65 // This actually allocates the subsets
66 sub.resize(nsubset_indices);
67
68 // Create the space of the colorings of the lattice
69 lat_color.resize(nodeSites);
70
71 // Create the array holding the array of sitetable info
72 sitetables.resize(nsubset_indices);
73
74 // Loop over linear sites determining their color
75 for(int linear=0; linear < nodeSites; ++linear)
76 {
77 multi1d<int> coord = Layout::siteCoords(Layout::nodeNumber(), linear);
78
79 int node = Layout::nodeNumber(coord);
80 int lin = Layout::linearSiteIndex(coord);
81 int icolor = func(coord);
82
83#if QDP_DEBUG >= 3
84 cout << " coord="<<coord<<" node="<<node<<" linear="<<linear<<" col="<<icolor << std::endl;
85#endif
86
87 // Sanity checks
88 if (node != Layout::nodeNumber())
89 QDP_error_exit("Set: found site with node outside current node!");
90
91 if (lin != linear)
92 QDP_error_exit("Set: inconsistent linear sites");
93
94 if (icolor < 0 || icolor >= nsubset_indices)
95 QDP_error_exit("Set: coloring is outside legal range: color[%d]=%d",linear,icolor);
96
97 // The coloring of this linear site
98 lat_color[linear] = icolor;
99 }
100
101
102 /*
103 * Loop over the lexicographic sites.
104 * This implementation of the Set will always use a
105 * sitetable.
106 */
107 for(int cb=0; cb < nsubset_indices; ++cb)
108 {
109 // Always construct the sitetables.
110
111 // First loop and see how many sites are needed
112 int num_sitetable = 0;
113 for(int linear=0; linear < nodeSites; ++linear)
114 if (lat_color[linear] == cb)
115 ++num_sitetable;
116
117 // Now take the inverse of the lattice coloring to produce
118 // the site list
119 multi1d<int>& sitetable = sitetables[cb];
120 sitetable.resize(num_sitetable);
121
122
123 // Site ordering stuff for later
124 bool ordRep;
125 int start, end;
126
127 // Handle the case that there are no sites
128 if (num_sitetable > 0)
129 {
130 // For later sanity, initialize this to something
131 for(int i=0; i < num_sitetable; ++i)
132 sitetable[i] = -1;
133
134
135 for(int linear=0, j=0; linear < nodeSites; ++linear)
136 if (lat_color[linear] == cb)
137 sitetable[j++] = linear;
138
139
140 // Check *if* this coloring is contiguous and find the start
141 // and ending sites
142 ordRep = true;
143 start = sitetable[0]; // this is the beginning
144 end = sitetable[sitetable.size()-1]; // the absolute last site
145
146 // Now look for a hole
147 for(int prev=sitetable[0], i=0; i < sitetable.size(); ++i)
148 if (sitetable[i] != prev++)
149 {
150#if QDP_DEBUG >= 2
151 QDP_info("Set(%d): sitetable[%d]=%d",cb,i,sitetable[i]);
152#endif
153
154 // Found a hole. The rep is not ordered.
155 ordRep = false;
156 start = end = -1;
157 break;
158 }
159 }
160 else // num_sitetable == 0
161 {
162 ordRep = false;
163 start = end = -1;
164 }
165
166 sub[cb].make(ordRep, start, end, &(sitetables[cb]), cb, this);
167
168#if QDP_DEBUG >= 2
169 QDP_info("Subset(%d): num_sitetable=%d start=%d end=%d",cb,num_sitetable,start,end);
170#endif
171 }
172}
173
174
175
176
177} // namespace QDP;
SetMap.
Definition qdp_subset.h:24
multi1d< int > lat_color
Index or color array of lattice.
Definition qdp_subset.h:124
void make(const SetFunc &fn)
Constructor from a function object.
multi1d< multi1d< int > > sitetables
Array of sitetable arrays.
Definition qdp_subset.h:127
multi1d< Subset > sub
A set is composed of an array of subsets.
Definition qdp_subset.h:121
Container for a multi-dimensional 1D array.
Definition qdp_multi.h:25
OScalar< PScalar< PScalar< RScalar< INTEGER32 > > > > Integer
#define INNER_LOG
OLattice< PScalar< PScalar< RScalar< INTEGER32 > > > > LatticeInteger
TextWriter & operator<<(TextWriter &txt, const std::string &output)
Definition qdp_io.cc:283
void copy_site(IScalar< T > &d, int isite, const IScalar< T1 > &s1)
dest [some type] = source [some type]
Definition qdp_inner.h:1682
const int Nd
Definition qdp_params.h:24
Layout namespace holding info on problem size and machine info.
Definition qdp_layout.cc:16
int nodeNumber()
Returns the node number of this node.
int linearSiteIndex(int site)
The linearized site index for the corresponding lexicographic site.
int sitesOnNode()
Subgrid lattice volume.
multi1d< int > siteCoords(int node, int index) QDP_CONST
Reconstruct the lattice coordinate from the node and site number.
LatticeInteger latticeCoordinate(int mu)
coord[mu] <- mu : fill with lattice coord in mu direction
StandardOutputStream cout
Definition qdp_stdio.cc:21
Yet another random number generator.
void QDP_error_exit(const char *format,...)
Simple error display and abort routine.
Definition qdp_util.cc:93
int QDP_info(const char *format,...)
Simple information display routine.
Definition qdp_util.cc:43
Primary include file for QDP.