2#include "dirac/conjugate_gradient.h"
12int main(
int argc,
char **argv) {
15 struct timeval start, end;
22 lattice.
setup(latsize);
42 for (n_runs = 1; timing < mintime;) {
44 gettimeofday(&start, NULL);
45 for (
int i = 0; i < n_runs; i++) {
46 dfield1[
ALL] = dfield2[X] * dfield3[X];
49 gettimeofday(&end, NULL);
50 timing = timediff(start, end);
53 timing = timing / (double)n_runs;
54 hila::out0 <<
"Double multiply : " << timing <<
" ms \n";
57 for (n_runs = 1; timing < mintime;) {
59 gettimeofday(&start, NULL);
60 for (
int i = 0; i < n_runs; i++) {
61 dfield1[
ALL] = dfield2[X] + dfield3[X];
64 gettimeofday(&end, NULL);
65 timing = timediff(start, end);
68 timing = timing / (double)n_runs;
69 hila::out0 <<
"Double add : " << timing <<
" ms \n";
72 for (n_runs = 1; timing < mintime;) {
74 gettimeofday(&start, NULL);
75 for (
int i = 0; i < n_runs; i++) {
76 ffield1[
ALL] = ffield2[X] * ffield3[X];
79 gettimeofday(&end, NULL);
80 timing = timediff(start, end);
83 timing = timing / (double)n_runs;
84 hila::out0 <<
"Float multiply : " << timing <<
" ms \n";
87 for (n_runs = 1; timing < mintime;) {
89 gettimeofday(&start, NULL);
90 for (
int i = 0; i < n_runs; i++) {
91 ffield1[
ALL] = ffield2[X] + ffield3[X];
94 gettimeofday(&end, NULL);
95 timing = timediff(start, end);
98 timing = timing / (double)n_runs;
99 hila::out0 <<
"Float add : " << timing <<
" ms \n";
122 fmatrix1[X].random();
123 fmatrix2[X].random();
124 fmatrix3[X].random();
125 fvector1[X].random();
126 fvector2[X].random();
131 for (n_runs = 1; timing < mintime;) {
133 gettimeofday(&start, NULL);
134 for (
int i = 0; i < n_runs; i++) {
135 matrix1[
ALL] = matrix1[X] * matrix1[X];
138 gettimeofday(&end, NULL);
139 timing = timediff(start, end);
142 timing = timing / (double)n_runs;
143 hila::out0 <<
"Matrix1 = Matrix1 * Matrix1 : " << timing <<
" ms \n";
147 for (n_runs = 1; timing < mintime;) {
149 gettimeofday(&start, NULL);
150 for (
int i = 0; i < n_runs; i++) {
151 matrix3[
ALL] = matrix1[X] * matrix2[X];
154 gettimeofday(&end, NULL);
155 timing = timediff(start, end);
158 timing = timing / (double)n_runs;
159 hila::out0 <<
"Matrix * Matrix: " << timing <<
"ms \n";
163 for (n_runs = 1; timing < mintime;) {
165 gettimeofday(&start, NULL);
166 for (
int i = 0; i < n_runs; i++) {
167 fmatrix3[
ALL] = fmatrix1[X] * fmatrix2[X];
170 gettimeofday(&end, NULL);
171 timing = timediff(start, end);
174 timing = timing / (double)n_runs;
175 hila::out0 <<
"Single Precision Matrix * Matrix: " << timing <<
"ms \n";
179 for (n_runs = 1; timing < mintime;) {
181 gettimeofday(&start, NULL);
182 for (
int i = 0; i < n_runs; i++) {
183 vector2[
ALL] = matrix1[X] * vector1[X];
186 gettimeofday(&end, NULL);
187 timing = timediff(start, end);
190 timing = timing / (double)n_runs;
191 hila::out0 <<
"Vector * Matrix: " << timing <<
" ms \n";
195 for (n_runs = 1; timing < mintime;) {
197 gettimeofday(&start, NULL);
198 for (
int i = 0; i < n_runs; i++) {
199 fvector2[
ALL] = fmatrix1[X] * fvector1[X];
202 gettimeofday(&end, NULL);
203 timing = timediff(start, end);
207 timing = timing / (double)n_runs;
208 hila::out0 <<
"Single Precision Vector * Matrix: " << timing <<
" ms \n";
215 for (n_runs = 1; timing < mintime;) {
217 gettimeofday(&start, NULL);
220 for (
int i = 0; i < n_runs; i++) {
224 gettimeofday(&end, NULL);
225 timing = timediff(start, end);
228 timing = timing / (double)n_runs;
229 hila::out0 <<
"Vector square sum: " << timing <<
" ms \n";
233 for (n_runs = 1; timing < mintime;) {
235 gettimeofday(&start, NULL);
237 for (
int i = 0; i < n_runs; i++) {
241 gettimeofday(&end, NULL);
242 timing = timediff(start, end);
245 timing = timing / (double)n_runs;
246 hila::out0 <<
"Single Precision vector square sum: " << timing <<
" ms \n";
250 for (n_runs = 1; timing < mintime;) {
252 gettimeofday(&start, NULL);
254 for (
int i = 0; i < n_runs; i++) {
255 matrix1.mark_changed(
ALL);
256 for (
int dir = 0; dir <
NDIRS; dir++) {
262 gettimeofday(&end, NULL);
263 timing = timediff(start, end);
266 timing = timing / 2 /
NDIRS / (double)n_runs;
267 hila::out0 <<
"Matrix nearest neighbour communication: " << timing <<
" ms \n";
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
double squarenorm() const
Squarenorm.
void setup(const CoordinateVector &siz)
General lattice setup.
This header file defines:
constexpr unsigned NDIRS
Number of directions.
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
constexpr Parity ALL
bit pattern: 011
double random()
Real valued uniform random number generator.
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...