main.cpp 1.44 KB
Newer Older
FritzFlorian committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "pls/internal/scheduling/scheduler.h"
#include "pls/internal/scheduling/scheduler_memory.h"

using namespace pls::internal::scheduling;

#include <iostream>
#include <complex>
#include <vector>

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

using namespace comparison_benchmarks::base;

15
int pls_fib(int n) {
FritzFlorian committed
16
  if (n <= 1) {
17
    return 1;
FritzFlorian committed
18 19
  }

20 21 22 23
  int a = pls_fib(n - 1);
  int b = pls_fib(n - 2);

  return a + b;
FritzFlorian committed
24 25
}

26
constexpr int MAX_NUM_THREADS = 1;
FritzFlorian committed
27
constexpr int MAX_NUM_TASKS = 64;
28
constexpr int MAX_STACK_SIZE = 128;
FritzFlorian committed
29 30 31 32 33 34 35

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";
36
  string full_directory = directory + "/PLS_v3/";
FritzFlorian committed
37 38 39 40
  benchmark_runner runner{full_directory, test_name};

  static_scheduler_memory<MAX_NUM_THREADS,
                          MAX_NUM_TASKS,
41
                          MAX_STACK_SIZE> static_scheduler_memory;
FritzFlorian committed
42

43
  scheduler scheduler{static_scheduler_memory, (unsigned) num_threads};
FritzFlorian committed
44 45 46 47

  volatile int res;
  for (int i = 0; i < fib::NUM_WARMUP_ITERATIONS; i++) {
    scheduler.perform_work([&]() {
48
      res = pls_fib(fib::INPUT_N);
FritzFlorian committed
49 50 51 52 53 54
    });
  }

  for (int i = 0; i < fib::NUM_ITERATIONS; i++) {
    scheduler.perform_work([&]() {
      runner.start_iteration();
55 56
      res = pls_fib(fib::INPUT_N);
      runner.end_iteration();
FritzFlorian committed
57 58 59 60 61 62
    });
  }
  runner.commit_results(true);

  return 0;
}