7#include "plumbing/lattice.h"
13const static int prime[NPRIMES] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
18void lattice_struct::setup_layout() {
19 int nfactors[NPRIMES];
23 hila::out0 <<
"LAYOUT: subnode lattice, with " << VECTOR_SIZE /
sizeof(float)
25 <<
"Enabling vector length " << VECTOR_SIZE * 8
26 <<
" bits = " << VECTOR_SIZE /
sizeof(
double) <<
" doubles or "
27 << VECTOR_SIZE /
sizeof(float) <<
" floats/ints\n";
36 hila::out0 <<
"Layout using vector of " << number_of_subnodes <<
" elements\n";
39 if (size(d) % 2 != 0) {
40 hila::out0 <<
"Lattice must be even to all directions (odd size:TODO)\n";
56 for (
int n = 0; n < NPRIMES; n++) {
58 while (i % prime[n] == 0) {
65 <<
" nodes with primes up to " << prime[NPRIMES - 1] <<
'\n';
76 int64_t cosize = l_volume / size(d);
78 while ((n * cosize) % nn != 0)
81 ghosts[d] = (n - size(d)) * cosize;
85 int64_t ghost_volume = 1;
87 ghost_volume *= nsize[d];
97 bool secondtime =
false;
101 if (ghost_volume > l_volume) {
104 if (ghosts[gdir] > ghosts[j])
115 (i == gdir) ? nsize[i] : size(i);
119 for (
int n = NPRIMES - 1; n >= 0; n--)
120 for (i = 0; i < nfactors[n]; i++) {
131 for (dir = 0; dir < NDIM; dir++) {
132 if (nodesiz[dir] > msize &&
133 ((dir == gdir && nodesiz[dir] % prime[n] == 0) ||
134 (dir != gdir && nodesiz[dir] % (2 * prime[n]) == 0)) &&
135 nodesiz[dir] / prime[n] > 3) {
136 msize = nodesiz[dir];
143 for (dir = 0; dir < NDIM; dir++) {
144 if (nodesiz[dir] > msize && dir != gdir &&
145 nodesiz[dir] % (prime[n]) == 0) {
146 msize = nodesiz[dir];
154 hila::out0 <<
"CANNOT HAPPEN! in setup_layout_vector.c\n";
159 nodesiz[mdir] /= prime[n];
160 divisions[mdir] *= prime[n];
170 if (nodesiz[dir] < 3)
188 int sd = subdiv[dir] * 2;
189 if (dir != gdir && nodesiz[dir] % 2 == 0 &&
190 divisions[dir] % sd == 0 && n_subn < number_of_subnodes) {
194 mynode.subnodes.merged_subnodes_dir = dir;
197 }
while (div_done && n_subn < number_of_subnodes);
199 if (n_subn != number_of_subnodes)
203 if (fail && !secondtime && gdir >= 0) {
209 hila::out0 <<
"Could not successfully lay out the lattice with "
218 <<
" nodes with vector layout can be done\n";
219 hila::out0 <<
" if the lattice can be divided into ";
221 <<
" virtual nodes so that the virtual node size is\n";
222 hila::out0 <<
" even to directions where the extra divisions are done, "
223 "and the node size is > 2.\n";
228 }
while (secondtime);
233 nodesiz[dir] *= subdiv[dir];
234 nodes.n_divisions[dir] = divisions[dir] / subdiv[dir];
235 nodes.divisors[dir].resize(nodes.n_divisions[dir] + 1);
241 for (
int i = 0; i <= size(dir); i++)
242 if ((i * nodes.n_divisions[dir]) / size(dir) != n) {
244 nodes.divisors[dir][n] = i;
250 mynode.subnodes.divisions[d] = subdiv[d];
255 int ghost_slices = 0;
257 ghost_slices = nsize[gdir] - size(gdir);
259 hila::out0 <<
"\nUsing uneven node division to direction " << gdir <<
":\n";
260 hila::out0 <<
"Lengths: " << nodes.n_divisions[gdir] - ghost_slices <<
" * ("
261 << nodesiz[gdir] <<
" sites) + " << ghost_slices <<
" * ("
262 << nodesiz[gdir] - 1 <<
" sites)\n";
264 for (
int i = 0; i < nodes.n_divisions[gdir]; i++) {
267 hila::out0 << nodes.divisors[gdir][i + 1] - nodes.divisors[gdir][i];
269 hila::out0 <<
"\nFilling efficiency: " << (100.0 * size(gdir)) / nsize[gdir]
272 if (ghost_slices > nodes.n_divisions[gdir] / 2)
273 hila::out0 <<
"NOTE: number of smaller nodes > large nodes \n";
283 hila::out0 <<
'(' << nodesiz[dir] - 1 <<
'-' << nodesiz[dir] <<
')';
290 if (ghost_slices > 0) {
291 int64_t ns2 = ns * (nodesiz[gdir] - 1) / nodesiz[gdir];
292 hila::out0 <<
" = " << ns2 <<
" - " << ns <<
'\n';
307 hila::out0 <<
"Node subdivision to 32bit elems: ";
313 hila::out0 <<
" = " << number_of_subnodes <<
" subnodes\n";
320 hila::out0 <<
'(' << nodesiz[dir] - 1 <<
'-' << nodesiz[dir] <<
')';
326 Direction dmerge = mynode.subnodes.merged_subnodes_dir;
328 hila::out0 <<
"Node subdivision to 64bit elems: ";
332 hila::out0 << ((dir == dmerge) ? subdiv[dir] / 2 : subdiv[dir]);
334 hila::out0 <<
" = " << number_of_subnodes / 2 <<
" subnodes\n";
341 hila::out0 <<
'(' << nodesiz[dir] - 1 <<
'-' << nodesiz[dir] <<
')';
343 hila::out0 << ((dir == dmerge) ? 2 * nodesiz[dir] / subdiv[dir]
344 : nodesiz[dir] / subdiv[dir]);
const auto & fill(const S rhs)
Matrix fill.
#define foralldir(d)
Macro to loop over (all) Direction(s)
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
This file defines all includes for HILA.
int number_of_nodes()
how many nodes there are
std::ostream out0
This writes output only from main process (node 0)
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...