3#include "dirac/conjugate_gradient.h"
13int main(
int argc,
char **argv) {
16 struct timeval start, end;
23 lattice.
setup(latsize);
32 onsites(
ALL) { U[d][X].random(); }
35 sunvec1[X].gaussian_random();
36 sunvec2[X].gaussian_random();
42 using sunvec = SU_vector<N, double>;
45 dirac_stg D_staggered(0.1, U);
46 D_staggered.apply(sunvec1, sunvec2);
49 for (n_runs = 1; timing < mintime;) {
51 gettimeofday(&start, NULL);
52 for (
int i = 0; i < n_runs; i++) {
53 sunvec1.mark_changed(
ALL);
54 D_staggered.apply(sunvec1, sunvec2);
57 gettimeofday(&end, NULL);
58 timing = timediff(start, end);
61 timing = timing / (double)n_runs;
62 hila::out0 <<
"Dirac staggered: " << timing <<
"ms \n";
68 stg_inverse.apply(sunvec2, sunvec1);
69 for (n_runs = 1; timing < mintime;) {
72 gettimeofday(&start, NULL);
73 for (
int i = 0; i < n_runs; i++) {
75 stg_inverse.apply(sunvec2, sunvec1);
79 gettimeofday(&end, NULL);
80 timing = timediff(start, end);
84 timing = timing / (double)n_runs;
85 hila::out0 <<
"Staggered CG: " << timing <<
"ms / iteration\n";
89 wvec1[X].gaussian_random();
90 wvec2[X].gaussian_random();
97 D_wilson.apply(wvec1, wvec2);
100 for (n_runs = 1; timing < mintime;) {
102 gettimeofday(&start, NULL);
103 for (
int i = 0; i < n_runs; i++) {
104 wvec1.mark_changed(
ALL);
105 D_wilson.apply(wvec1, wvec2);
108 gettimeofday(&end, NULL);
109 timing = timediff(start, end);
112 timing = timing / (double)n_runs;
113 hila::out0 <<
"Dirac Wilson: " << timing <<
"ms \n";
119 w_inverse.apply(wvec2, wvec1);
120 for (n_runs = 1; timing < mintime;) {
124 gettimeofday(&start, NULL);
125 for (
int i = 0; i < n_runs; i++) {
127 w_inverse.apply(wvec2, wvec1);
131 gettimeofday(&end, NULL);
132 timing = timediff(start, end);
136 timing = timing / (double)n_runs;
137 hila::out0 <<
"Dirac Wilson CG: " << timing <<
"ms / iteration\n";
The conjugate gradient operator. Applies the inverse square of an operator on a vector.
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
void setup(const CoordinateVector &siz)
General lattice setup.
This header file defines:
#define foralldir(d)
Macro to loop over (all) Direction(s)
constexpr Parity ALL
bit pattern: 011
std::ostream out0
This writes output only from main process (node 0)
void initialize(int argc, char **argv)
Read in command line arguments. Initialise default stream and MPI communication.
void seed_random(uint64_t seed, bool device_rng=true)
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ran...
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...