16#include "plumbing/lattice.h"
18#if defined(NODE_LAYOUT_TRIVIAL)
25 hila::out0 <<
"Node remapping: NODE_LAYOUT_TRIVIAL (no reordering)\n";
26 lattice.nodes.map_array =
nullptr;
27 lattice.nodes.map_inverse =
nullptr;
34unsigned lattice_struct::allnodes::inverse_remap(
unsigned i)
const {
39#elif defined(NODE_LAYOUT_BLOCK)
66 while (found && nblocks > 1) {
72 for (div = 2; div <= 5; div++)
73 if (nblocks % div == 0 && blockdivs[d] % div == 0)
84 hila::out0 <<
"Node block size " << blocksize <<
" block division " << blockdivs <<
'\n';
89 lattice.nodes.map_array =
90 (
unsigned *)memalloc(lattice.nodes.number *
sizeof(
unsigned));
94 lattice.nodes.map_inverse =
nullptr;
98 nblocks *= blocksize[d];
102 for (
int i = 0; i < lattice.nodes.number; i++) {
108 lcoord[d] = idiv % lattice.nodes.n_divisions[d];
109 idiv /= lattice.nodes.n_divisions[d];
111 bcoord[d] = lcoord[d] / blocksize[d];
112 icoord[d] = lcoord[d] % blocksize[d];
121 ii += icoord[d] * im;
124 bi += bcoord[d] * bm;
131 lattice.nodes.map_array[i] = bi * nblocks + ii;
138 return lattice.nodes.map_array[i];
141unsigned lattice_struct::allnodes::inverse_remap(
unsigned idx)
const {
142 for (
int i = 0; i < lattice.nodes.number; i++)
143 if (lattice.nodes.map_array[i] == idx)
const auto & fill(const S rhs)
Matrix fill.
#define foralldir(d)
Macro to loop over (all) Direction(s)
This file defines all includes for HILA.
std::ostream out0
This writes output only from main process (node 0)
#define NODE_LAYOUT_BLOCK
unsigned remap(unsigned i) const
And the call interface for remapping.