HILA
Loading...
Searching...
No Matches
bench_FFT.cpp
1#include "bench.h"
2#include "plumbing/timing.h"
3#include "plumbing/fft.h"
4//#include "plumbing/FFT.h"
5
6#ifndef SEED
7#define SEED 100
8#endif
9
10const CoordinateVector latsize = {32, 32, 32, 32};
11
12int main(int argc, char **argv) {
13 int n_runs = 1;
14 struct timeval start, end;
15 double timing;
16
17 hila::initialize(argc, argv);
18
19 lattice.setup(latsize);
20
22
25
26 Field<T> d, d2;
27
28 // Generate a random field
29 onsites(ALL) { d[X].random(); }
30
31 // Run once to make sure everything is set up
32 FFT_field(d, d2);
33
34 timing = 0;
35 for (n_runs = 1; timing < mintime;) {
36 n_runs *= 2;
37 gettimeofday(&start, NULL);
38 for (int i = 0; i < n_runs; i++) {
39 FFT_field(d, d2);
40 }
41 // // synchronize();
42 gettimeofday(&end, NULL);
43 timing = timediff(start, end);
44 hila::broadcast(timing);
45 }
46 timing = timing / (double)n_runs;
47 hila::out0 << "FFT double precision : " << timing << " ms \n";
48
49 // Generate a random field
50 Field<Tf> f, f2;
51
52 // Generate a random field
53 onsites(ALL) { f[X].random(); }
54
55 timing = 0;
56 for (n_runs = 1; timing < mintime;) {
57 n_runs *= 2;
58 gettimeofday(&start, NULL);
59 for (int i = 0; i < n_runs; i++) {
60 FFT_field(f, f2);
61 }
62 // // synchronize();
63 gettimeofday(&end, NULL);
64 timing = timediff(start, end);
65 hila::broadcast(timing);
66 }
67 timing = timing / (double)n_runs;
68 hila::out0 << "FFT single precision : " << timing << " ms \n";
69
71}
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Definition field.h:61
Matrix class which defines matrix operations.
Definition matrix.h:1679
void setup(const CoordinateVector &siz)
General lattice setup.
Definition lattice.cpp:33
constexpr Parity ALL
bit pattern: 011
void FFT_field(const Field< T > &input, Field< T > &result, const CoordinateVector &directions, fft_direction fftdir=fft_direction::forward)
Definition fft.h:376
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...
Definition random.cpp:86
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).
Definition com_mpi.h:153
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...