main.cpp 1.74 KB
Newer Older
1
#include "pls/pls.h"
2 3 4

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

6
using namespace comparison_benchmarks::base;
7

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

13
  fft::divide(data, swap_array, n);
14
  if (n <= fft::RECURSIVE_CUTOFF) {
15 16
    fft::conquer(data, swap_array, n / 2);
    fft::conquer(data + n / 2, swap_array + n / 2, n / 2);
17
  } else {
18
    pls::spawn([data, n, swap_array]() {
19
      pls_conquer(data, swap_array, n / 2);
20
    });
21
    pls::spawn([data, n, swap_array]() {
22
      pls_conquer(data + n / 2, swap_array + n / 2, n / 2);
23
    });
24
    pls::sync();
25
  }
26 27

  fft::combine(data, n);
28 29
}

30 31
constexpr int MAX_NUM_TASKS = 16;
constexpr int MAX_STACK_SIZE = 4096 * 1;
32

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

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

42 43 44
  fft::complex_vector data(fft::SIZE);
  fft::complex_vector swap_array(fft::SIZE);
  fft::fill_input(data);
45

46
  pls::scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
47

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

60
  runner.commit_results(true);
61

62
  return 0;
63
}