16template <
typename A,
typename B,
typename C>
17void sum_test_function(A &a,
const B &b,
const C &c) {
18 onsites(
ALL) { a[X] = b[X] + c[X + e_x]; }
21template <
typename T> T test_template_function(T a) {
return 2 * a; }
23element<Complex<double>> test_nontemplate_function(element<
Complex<double>> a) {
24 element<Complex<double>> b = a;
28#include "dirac/staggered.h"
30int main(
int argc,
char **argv) {
36 d = next_direction(d);
37 d2 = next_direction(d2);
44 test_setup(argc, argv);
58 onsites(
ALL) { sum += s1[X].re; }
59 assert(sum == 2 * (
double)lattice.volume() &&
"onsites reduction");
70 s1[
ALL] = s2[X] + s3[X];
72 onsites(
ALL) { sum += s1[X].re; }
73 assert(sum == (
double)lattice.volume() &&
"test setting field with parity");
86 assert(!s1.is_gathered(d,
EVEN));
87 assert(!s1.is_gathered(d,
ODD));
88 assert(!s1.is_gathered(d,
ALL));
89 assert(!s1.is_move_started(d,
EVEN));
90 assert(!s1.is_move_started(d,
ODD));
91 assert(!s1.is_move_started(d,
ALL));
92 assert(s1.move_not_done(d,
EVEN) &&
"move not done initially");
93 assert(s1.move_not_done(d,
ODD) &&
"move not done initially");
94 assert(s1.move_not_done(d,
ALL) &&
"move not done initially");
99 s1.mark_move_started(d,
EVEN);
100 assert(s1.is_move_started(d,
EVEN));
101 assert(!s1.is_gathered(d,
EVEN));
102 assert(!s1.move_not_done(d,
EVEN) &&
"move not done after starting");
103 assert(!s1.is_gathered(d,
ODD));
104 assert(!s1.is_gathered(d,
ALL));
105 assert(!s1.is_move_started(d,
ODD));
106 assert(!s1.is_move_started(d,
ALL));
107 assert(s1.move_not_done(d,
ODD));
108 assert(s1.move_not_done(d,
ALL));
110 s1.mark_gathered(d,
EVEN);
111 assert(s1.is_gathered(d,
EVEN));
112 assert(!s1.is_move_started(d,
EVEN));
113 assert(!s1.move_not_done(d,
EVEN));
115 s1.mark_changed(
ALL);
117 s1.mark_move_started(d,
ODD);
118 assert(s1.is_move_started(d,
ODD));
119 assert(!s1.is_gathered(d,
ODD));
120 assert(!s1.move_not_done(d,
ODD) &&
"move not done after starting");
122 s1.mark_gathered(d,
ODD);
123 assert(s1.is_gathered(d,
ODD));
124 assert(!s1.is_move_started(d,
ODD));
125 assert(!s1.move_not_done(d,
ODD));
127 s1.mark_changed(
ALL);
129 s1.mark_move_started(d,
ALL);
130 assert(s1.is_move_started(d,
ALL));
131 assert(!s1.is_gathered(d,
ALL));
132 assert(!s1.move_not_done(d,
ALL) &&
"move not done after starting");
134 s1.mark_gathered(d,
ALL);
135 assert(s1.is_gathered(d,
ALL));
136 assert(!s1.is_move_started(d,
ALL));
137 assert(!s1.move_not_done(d,
ALL));
139 s1.mark_changed(
ALL);
147 assert(elem.re == 1 && elem.im == 0 &&
"set_element");
153 assert(elem.re == 1 && elem.im == 0 &&
"set_element on other node");
165 assert(elem.re == 1 && elem.im == 0);
172 coord2[d] = (coord[d] - 1 + nd[d]) % nd[d];
174 if (elem.re != 1 || elem.im != 0) {
175 hila::out0 <<
"Problem in communicating to Direction " << d <<
"\n";
177 assert(elem.re == 1 && elem.im == 0);
186 coord1[0] = (nd[0] - 1) % nd[0];
194 assert(moved_element == 1 &&
"moved up");
202 assert(moved_element == 1 &&
"moved down");
213 assert(moved_element == -1 &&
"moved up antiperiodic");
221 assert(moved_element == -1 &&
"moved down antiperiodic");
226 assert(moved_element == 1 &&
"moved back antiperiodic");
237 double a = s1[X + d].re;
241 assert(sum == 0 &&
"Test communicating a filled field");
251 sum += X.coordinates()[0];
255 double result = lattice.volume() * (nd[0] - 1) / 2;
256 assert(sum == result &&
"Reproduce write problem 1");
262 sum += X.coordinates()[0];
266 assert(sum == result &&
"Reproduce write problem 2");
273 for (
int i = 0; i < 2; i++) {
278 s2[
ODD] = s2[X] - s1[X + dir];
279 s2[
EVEN] = s2[X] + s2[X - dir];
282 sum = (r + i) * (r + i);
284 assert(sum < 1e-8 &&
"Even-odd comm test");
293 s2[
ODD] = -s1[X + e_x];
294 s2.start_gather(e_x,
ODD);
297 onsites(
ALL) { sum += s2[X].re; }
305 s4[2][
ALL] = s4[0][X] - s4[1][X];
308 onsites(
ALL) { sum += (s4[2][X] * s4[2][X]).re; }
314 sum_test_function(s3, s1, s2);
316 element<double> diff = s3[X].re - 1.0;
325 s1[X] = test_template_function(s1[X]);
326 s2[X] = test_nontemplate_function(s2[X]);
329 element<double> diff1 = s1[X].re - 2.0;
330 element<double> diff2 = s2[X].re - 2.0;
331 sum += diff1 * diff1 + diff2 * diff2;
347 arraysum[t] += dfield[X];
350 for (
int t = 0; t < nd[e_t]; t++) {
351 assert(arraysum[t] == nd[e_x] * nd[e_y] * nd[e_z]);
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
void set_boundary_condition(Direction dir, hila::bc bc)
Set the boundary condition in a given Direction (periodic or antiperiodic)
const T get_element(const CoordinateVector &coord) const
Get singular element which will be broadcast to all nodes.
const T set_element(const CoordinateVector &coord, const A &value)
Get singular element which will be broadcast to all nodes.
bool is_initialized(Parity p) const
Returns true if the Field has been assigned to.
bool is_allocated() const
Returns true if the Field data has been allocated.
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
int myrank()
rank of this node
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...