main.cpp 1.74 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
    fft::conquer(data, swap_array, n / 2);
    fft::conquer(data + n / 2, swap_array + n / 2, n / 2);
19
  } else {
20
    spawn([data, n, swap_array]() {
21
      pls_conquer(data, swap_array, n / 2);
22
    });
23
    spawn([data, n, swap_array]() {
24
      pls_conquer(data + n / 2, swap_array + n / 2, n / 2);
25
    });
26
    sync();
27
  }
28 29

  fft::combine(data, n);
30 31
}

32 33
constexpr int MAX_NUM_TASKS = 16;
constexpr int MAX_STACK_SIZE = 4096 * 1;
34

35 36 37 38
int main(int argc, char **argv) {
  int num_threads;
  string directory;
  benchmark_runner::read_args(argc, argv, num_threads, directory);
39

40
  string test_name = to_string(num_threads) + ".csv";
41
  string full_directory = directory + "/PLS_v3/";
42
  benchmark_runner runner{full_directory, test_name};
43

44 45 46
  fft::complex_vector data(fft::SIZE);
  fft::complex_vector swap_array(fft::SIZE);
  fft::fill_input(data);
47

48
  scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
49

50 51
//  scheduler.get_profiler().disable_memory_measure();
  runner.run_iterations(10, [&]() {
52
    scheduler.perform_work([&]() {
53
      pls_conquer(data.begin(), swap_array.begin(), fft::SIZE);;
54
    });
55 56
//    scheduler.get_profiler().current_run().print_stats();
  }, 1, [&]() {
57 58
    fft::fill_input(data); // Reset data before each run
  });
59 60 61
//  scheduler.get_profiler().current_run().print_dag(std::cout);
//  scheduler.get_profiler().current_run().print_stats();

62
  runner.commit_results(true);
63

64
  return 0;
65
}