main.cpp 1.28 KB
Newer Older
1
#include "pls/pls.h"
FritzFlorian committed
2 3 4 5 6 7

#include "benchmark_runner.h"
#include "benchmark_base/fib.h"

using namespace comparison_benchmarks::base;

8 9 10
constexpr int MAX_NUM_TASKS = 32;
constexpr int MAX_STACK_SIZE = 4096 * 1;

11
int pls_fib(int n, int d) {
12 13 14 15
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
16
    return 1;
FritzFlorian committed
17 18
  }

19
  int a, b;
20 21
  pls::spawn([n, d, &a]() {
    a = pls_fib(n - 1, d + 1);
22
  });
23 24
  pls::spawn([n, d, &b]() {
    b = pls_fib(n - 2, d + 1);
25
  });
26
  pls::sync();
27

28
  return a + b;
FritzFlorian committed
29 30 31 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);

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

41
  pls::scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
FritzFlorian committed
42 43

  volatile int res;
44
//  scheduler.get_profiler().disable_memory_measure();
45 46
  runner.run_iterations(fib::NUM_ITERATIONS, [&]() {
    scheduler.perform_work([&]() {
47
      res = pls_fib(fib::INPUT_N, 0);
48 49
    });
  }, fib::NUM_WARMUP_ITERATIONS);
50 51
//  scheduler.get_profiler().current_run().print_dag(std::cout);
//  scheduler.get_profiler().current_run().print_stats();
FritzFlorian committed
52

FritzFlorian committed
53 54 55 56
  runner.commit_results(true);

  return 0;
}