7#include "plumbing/lattice.h"
13const static int prime[NPRIMES] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
19void lattice_struct::setup_layout() {
20 int nfactors[NPRIMES];
34 hila::out0 <<
"Lattice must be even to all directions (odd size:TODO)\n";
43 for (
int n = 0; n < NPRIMES; n++) {
45 while (i % prime[n] == 0) {
51 hila::out0 <<
"Cannot factorize " << nn <<
" nodes with primes up to " << prime[NPRIMES - 1]
56 int64_t remainder = l_volume % nn;
66 int64_t cosize = l_volume / size(d);
68 while ((n * cosize) % nn != 0)
71 ghosts[d] = (n - size(d)) * cosize;
76 bool secondtime =
false;
80 foralldir(j)
if (ghosts[mdir] > ghosts[j]) mdir = j;
86 nodesiz[i] = (i == mdir) ? nsize[i] : size(i);
87 nodes.n_divisions[i] = 1;
90 for (
int n = NPRIMES - 1; n >= 0; n--)
91 for (
int i = 0; i < nfactors[n]; i++) {
98 for (dir = 0; dir < NDIM; dir++)
99 if (nodesiz[dir] > msize && nodesiz[dir] % prime[n] == 0)
100 msize = nodesiz[dir];
111 for (dir = NDIM - 1; dir >= 0; dir--)
112 if (nodesiz[dir] == msize && nodes.n_divisions[dir] > 1 &&
113 nodesiz[dir] % prime[n] == 0)
118 for (dir = NDIM - 1; dir >= 0; dir--)
119 if (nodesiz[dir] == msize && nodesiz[dir] % prime[n] == 0)
124 hila::out0 <<
"CANNOT HAPPEN! in setup_layout_generic.c\n";
129 nodesiz[dir] /= prime[n];
130 nodes.n_divisions[dir] *= prime[n];
135 foralldir(dir)
if (nodesiz[dir] < 2) fail =
true;
136 if (fail && !secondtime) {
141 hila::out0 <<
"Could not successfully lay out the lattice with "
146 }
while (secondtime);
151 nodes.divisors[dir].resize(nodes.n_divisions[dir] + 1);
157 for (
int i = 0; i <= size(dir); i++)
158 if ((i * nodes.n_divisions[dir]) / size(dir) != n) {
160 nodes.divisors[dir][n] = i;
168 int ghost_slices = nsize[mdir] - size(mdir);
169 if (ghost_slices > 0) {
170 hila::out0 <<
"\nUsing uneven node division to direction " << mdir <<
":\n";
171 hila::out0 <<
"Lengths: " << nodes.n_divisions[mdir] - ghost_slices <<
" * ("
172 << nodesiz[mdir] <<
" sites) + " << ghost_slices <<
" * (" << nodesiz[mdir] - 1
175 for (
int i = 0; i < nodes.n_divisions[mdir]; i++) {
178 hila::out0 << nodes.divisors[mdir][i + 1] - nodes.divisors[mdir][i];
180 hila::out0 <<
"\nFilling efficiency: " << (100.0 * size(mdir)) / nsize[mdir] <<
"%\n";
182 if (ghost_slices > nodes.n_divisions[mdir] / 2)
183 hila::out0 <<
"NOTE: number of smaller nodes > large nodes \n";
192 if (dir == mdir && ghost_slices > 0)
193 hila::out0 <<
'(' << nodesiz[dir] - 1 <<
'-' << nodesiz[dir] <<
')';
199 if (ghost_slices > 0) {
200 int ns2 = ns * (nodesiz[mdir] - 1) / nodesiz[mdir];
201 hila::out0 <<
" = " << ns2 <<
" - " << ns <<
'\n';
#define foralldir(d)
Macro to loop over (all) Direction(s)
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...