main.cpp 1.64 KB
Newer Older
1
#include "pls/pls.h"
2

3
using namespace pls;
4

5 6
#include "benchmark_runner.h"
#include "benchmark_base/fft.h"
7

8
using namespace comparison_benchmarks::base;
9

10
void pls_conquer(fft::complex_vector::iterator data, fft::complex_vector::iterator swap_array, int n) {
11
  if (n < 2) {
12
    return;
13 14
  }

15
  fft::divide(data, swap_array, n);
16
  if (n <= fft::RECURSIVE_CUTOFF) {
17 18 19
    FILE* file = fopen("test.text", "w");
    fprintf(file, "test %d", n);
    fclose(file);
20 21
    fft::conquer(data, swap_array, n / 2);
    fft::conquer(data + n / 2, swap_array + n / 2, n / 2);
22
  } else {
23
    spawn([data, n, swap_array]() {
24
      pls_conquer(data, swap_array, n / 2);
25
    });
26
    spawn([data, n, swap_array]() {
27
      pls_conquer(data + n / 2, swap_array + n / 2, n / 2);
28
    });
29
    sync();
30
  }
31 32

  fft::combine(data, n);
33 34
}

35 36
constexpr int MAX_NUM_TASKS = 16;
constexpr int MAX_STACK_SIZE = 4096 * 1;
37

38 39 40 41
int main(int argc, char **argv) {
  int num_threads;
  string directory;
  benchmark_runner::read_args(argc, argv, num_threads, directory);
42

43
  string test_name = to_string(num_threads) + ".csv";
44
  string full_directory = directory + "/PLS_v3/";
45
  benchmark_runner runner{full_directory, test_name};
46

47 48 49
  fft::complex_vector data(fft::SIZE);
  fft::complex_vector swap_array(fft::SIZE);
  fft::fill_input(data);
50

51
  scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
52

53 54
  runner.run_iterations(fft::NUM_ITERATIONS, [&]() {
    scheduler.perform_work([&]() {
55
      pls_conquer(data.begin(), swap_array.begin(), fft::SIZE);;
56
    });
57 58 59
  }, fft::NUM_WARMUP_ITERATIONS, [&]() {
    fft::fill_input(data); // Reset data before each run
  });
60
  runner.commit_results(true);
61

62
  return 0;
63
}