15#include "plumbing/timing.h"
19#if defined(CUDA) || defined(HIP)
22#define VECTOR_SIZE (256 / 8)
26constexpr unsigned number_of_subnodes = VECTOR_SIZE /
sizeof(float);
31enum class bc { PERIODIC, ANTIPERIODIC, DIRICHLET };
35 if (
bc == hila::bc::DIRICHLET) {
44void test_std_gathers();
45void report_too_large_node();
50 unsigned evensites, oddsites;
74 size_t sites, evensites, oddsites;
75 size_t field_alloc_size;
80#ifdef EVEN_SITES_FIRST
81 std::vector<CoordinateVector> coordinates;
92 struct subnode_struct {
94 size_t sites, evensites, oddsites;
101 unsigned volume()
const {
107 return (is_up_dir(d) && min[d] + size[d] == parent->size(d)) ||
108 (!is_up_dir(d) && min[-d] == 0);
119 std::vector<unsigned> divisors[NDIM];
122 std::vector<node_info> nodelist;
128 unsigned remap(
unsigned i)
const;
129 unsigned inverse_remap(
unsigned i)
const;
136 size_t sites, evensites, oddsites;
141 const unsigned *
RESTRICT get_sitelist(
Parity par,
int &size)
const {
145 }
else if (par ==
EVEN) {
150 return sitelist + evensites;
155 unsigned n_sites(
Parity par)
const {
158 }
else if (par ==
EVEN) {
166 unsigned site_index(
unsigned site,
Parity par)
const {
168 return sitelist[evensites + site];
170 return sitelist[site];
175 unsigned offset(
Parity par)
const {
177 return buffer + evensites;
188 unsigned receive_buf_size;
194 std::vector<comm_node_struct> from_node;
195 std::vector<comm_node_struct> to_node;
196 size_t receive_buf_size;
208#ifdef SPECIAL_BOUNDARY_CONDITIONS
212 struct special_boundary_struct {
213 unsigned *neighbours;
214 unsigned *move_index;
215 size_t offset, n_even, n_odd, n_total;
219 special_boundary_struct special_boundaries[
NDIRS];
233 return l_volume != 0;
239 int64_t volume()
const {
247 int size(
int d)
const {
254 int node_rank()
const {
257 int n_nodes()
const {
268 unsigned field_alloc_size()
const {
269 return mynode.field_alloc_size;
274 std::vector<comm_node_struct> create_comm_node_vector(
CoordinateVector offset,
unsigned *index,
281#ifdef SPECIAL_BOUNDARY_CONDITIONS
282 void init_special_boundaries();
283 void setup_special_boundary_array(
Direction d);
292 unsigned remap_node(
const unsigned i);
294#ifdef EVEN_SITES_FIRST
295 unsigned loop_begin(
Parity P)
const {
297 return mynode.evensites;
302 unsigned loop_end(
Parity P)
const {
304 return mynode.evensites;
311 return mynode.coordinates[idx];
314 inline int coordinate(
unsigned idx,
Direction d)
const {
315 return mynode.coordinates[idx][d];
318 inline Parity site_parity(
unsigned idx)
const {
319 if (idx < mynode.evensites)
327 unsigned loop_begin(
Parity P)
const {
328 assert(P ==
ALL &&
"Only parity ALL when EVEN_SITES_FIRST is off");
331 unsigned loop_end(
Parity P)
const {
345 for (
int d = 0; d < NDIM - 1; ++d) {
346 ndiv = vdiv / mynode.size[d];
347 c[d] = vdiv - ndiv * mynode.size[d] + mynode.min[d];
350 c[NDIM - 1] = vdiv + mynode.min[NDIM - 1];
355 inline int coordinate(
unsigned idx,
Direction d)
const {
356 return (idx / mynode.size_factor[d]) % mynode.size[d] + mynode.min[d];
359 inline Parity site_parity(
unsigned idx)
const {
360 return coordinates(idx).parity();
366 return coordinates(idx) - mynode.min;
374 void initialize_wait_arrays();
377 MPI_Comm mpi_comm_lat;
380 int64_t n_gather_done = 0, n_gather_avoided = 0;
391 site[dir] = index % size(dir);
406extern std::vector<lattice_struct *> lattices;
411#include "plumbing/backend_cpu/lattice.h"
412#elif defined(CUDA) || defined(HIP)
413#include "plumbing/backend_gpu/lattice.h"
414#elif defined(VECTORIZED)
415#include "plumbing/backend_vector/lattice_vector.h"
428#define forallcoordinates(cv) \
429for (cv[3] = 0; cv[3] < lattice.size(3); cv[3]++) \
430for (cv[2] = 0; cv[2] < lattice.size(2); cv[2]++) \
431for (cv[1] = 0; cv[1] < lattice.size(1); cv[1]++) \
432for (cv[0] = 0; cv[0] < lattice.size(0); cv[0]++)
434#define forcoordinaterange(cv,cmin,cmax) \
435for (cv[3] = cmin[3]; cv[3] <= cmax[3]; cv[3]++) \
436for (cv[2] = cmin[2]; cv[2] <= cmax[2]; cv[2]++) \
437for (cv[1] = cmin[1]; cv[1] <= cmax[1]; cv[1]++) \
438for (cv[0] = cmin[0]; cv[0] <= cmax[0]; cv[0]++)
442#define forallcoordinates(cv) \
443for (cv[2] = 0; cv[2] < lattice.size(2); cv[2]++) \
444for (cv[1] = 0; cv[1] < lattice.size(1); cv[1]++) \
445for (cv[0] = 0; cv[0] < lattice.size(0); cv[0]++)
447#define forcoordinaterange(cv,cmin,cmax) \
448for (cv[2] = cmin[2]; cv[2] <= cmax[2]; cv[2]++) \
449for (cv[1] = cmin[1]; cv[1] <= cmax[1]; cv[1]++) \
450for (cv[0] = cmin[0]; cv[0] <= cmax[0]; cv[0]++)
454#define forallcoordinates(cv) \
455for (cv[1] = 0; cv[1] < lattice.size(1); cv[1]++) \
456for (cv[0] = 0; cv[0] < lattice.size(0); cv[0]++)
458#define forcoordinaterange(cv,cmin,cmax) \
459for (cv[1] = cmin[1]; cv[1] <= cmax[1]; cv[1]++) \
460for (cv[0] = cmin[0]; cv[0] <= cmax[0]; cv[0]++)
464#define forallcoordinates(cv) \
465for (cv[0] = 0; cv[0] < lattice.size(0); cv[0]++)
467#define forcoordinaterange(cv,cmin,cmax) \
468for (cv[0] = cmin[0]; cv[0] <= cmax[0]; cv[0]++)
Matrix class which defines matrix operations.
dir_mask_t *__restrict__ wait_arr_
implement waiting using mask_t - unsigned char is good for up to 4 dim.
void setup_nodes()
invert the mynode index -> location (only on this node)
void setup(const CoordinateVector &siz)
General lattice setup.
bool is_on_mynode(const CoordinateVector &c) const
Is the coordinate on THIS node.
CoordinateVector global_coordinates(size_t index) const
bool is_initialized() const
is the lattice initialized
unsigned *__restrict__ neighb[NDIRS]
Main neighbour index array.
void create_std_gathers()
std::array< nn_comminfo_struct, NDIRS > nn_comminfo
nearest neighbour comminfo struct
unsigned site_index(const CoordinateVector &c) const
This header file defines:
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...
constexpr Parity EVEN
bit pattern: 001
#define foralldir(d)
Macro to loop over (all) Direction(s)
constexpr unsigned NDIRS
Number of directions.
constexpr Parity ODD
bit pattern: 010
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
constexpr Parity ALL
bit pattern: 011
This file defines all includes for HILA.
Implement hila::swap for gauge fields.
bc
list of field boundary conditions - used only if SPECIAL_BOUNDARY_CONDITIONS defined
bool bc_need_communication(hila::bc bc)
False if we have b.c. which does not require communication.
Helper class for loading the vectorized lattice.
information about all nodes
unsigned remap(unsigned i) const
And the call interface for remapping.
Information necessary to communicate with a node.
nn-communication has only 1 node to talk to
Information about the node stored on this process.
void setup(node_info &ni, lattice_struct &lattice)
Fill in mynode fields – node_rank() must be set up OK.
bool is_on_edge(Direction d) const
true if this node is on the edge of the lattice to dir d
useful information about a node