5#include "../field_storage.h"
17 const unsigned field_alloc_size) {
23 fieldbuf = (T *)memalloc(
sizeof(T) * lattice.field_alloc_size());
24 if (fieldbuf ==
nullptr) {
25 std::cout <<
"Failure in Field memory allocation\n";
28#pragma acc enter data create(fieldbuf)
33#pragma acc exit data delete (fieldbuf)
34 if (fieldbuf !=
nullptr)
45#pragma omp parallel for
46 for (
unsigned j = 0; j < n; j++) {
47 unsigned index = index_list[j];
48 buffer[j] = get(index, lattice.field_alloc_size());
55 const unsigned *
RESTRICT index_list,
int n,
58#pragma omp parallel for
59 for (
unsigned j = 0; j < n; j++) {
60 unsigned index = index_list[j];
61 buffer[j] = -get(index, lattice.field_alloc_size());
66 assert(
sizeof(T) < 1 &&
"Antiperiodic boundary conditions require that unary - "
67 "-operator is defined!");
74#pragma omp parallel for
75 for (
unsigned j = 0; j < n; j++) {
76 set(buffer[j], index_list[j], lattice.field_alloc_size());
86#ifdef SPECIAL_BOUNDARY_CONDITIONS
89 unsigned n, start = 0;
91 n = lattice.special_boundaries[dir].n_odd;
92 start = lattice.special_boundaries[dir].n_even;
95 n = lattice.special_boundaries[dir].n_even;
97 n = lattice.special_boundaries[dir].n_total;
99 unsigned offset = lattice.special_boundaries[dir].offset + start;
100 gather_elements_negated(fieldbuf + offset,
101 lattice.special_boundaries[dir].move_index + start, n, lattice);
105 assert(!antiperiodic &&
"antiperiodic BC possible only if SPECIAL_BOUNDARY_CONDITIONS defined");
113 bool antiperiodic)
const {
115 const unsigned *index_list = to_node.get_sitelist(par, n);
118 gather_elements_negated(buffer, index_list, n, lattice);
120 gather_elements(buffer, index_list, n, lattice);
126 return this->get(i, lattice.field_alloc_size());
133 this->set(value, i, lattice.field_alloc_size());
143 return (T *)memalloc(n *
sizeof(T));
The field_storage struct contains minimal information for using the field in a loop....
void place_elements(T *__restrict__ buffer, const unsigned *__restrict__ index_list, int n, const lattice_struct &lattice)
CUDA implementation of place_elements without CUDA aware MPI.
void gather_elements(T *__restrict__ buffer, const unsigned *__restrict__ index_list, int n, const lattice_struct &lattice) const
CUDA implementation of gather_elements without CUDA aware MPI.
void gather_elements_negated(T *__restrict__ buffer, const unsigned *__restrict__ index_list, int n, const lattice_struct &lattice) const
CUDA implementation of gather_elements_negated without CUDA aware MPI.
void set_local_boundary_elements(Direction dir, Parity par, const lattice_struct &lattice, bool antiperiodic)
Place boundary elements from local lattice (used in vectorized version)
auto get_element(const unsigned i, const lattice_struct &lattice) const
Conditionally reture bool type false if type T does't have unary - operator.
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...
constexpr Parity EVEN
bit pattern: 001
constexpr Parity ODD
bit pattern: 010
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Information necessary to communicate with a node.