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

3
using namespace pls;
4

5 6
#include "benchmark_runner.h"
#include "benchmark_base/matrix.h"
FritzFlorian committed
7
#include <iostream>
8

9
using namespace comparison_benchmarks::base;
10

11 12
template<typename T>
class pls_matrix : public matrix::matrix<T> {
13
 public:
14
  explicit pls_matrix(size_t size) : matrix::matrix<T>(size) {}
15

16 17
  void multiply(const matrix::matrix<T> &a, const matrix::matrix<T> &b) override {
    pls::algorithm::for_each_range(0, this->size_, [&](int i) {
18 19 20 21 22
      this->multiply_column(i, a, b);
    });
  }
};

23
constexpr int MAX_NUM_TASKS = 32;
24
constexpr int MAX_STACK_SIZE = 4096 * 1;
25

26 27 28 29
int main(int argc, char **argv) {
  int num_threads;
  string directory;
  benchmark_runner::read_args(argc, argv, num_threads, directory);
30

31
  string test_name = to_string(num_threads) + ".csv";
32
  string full_directory = directory + "/PLS_v3/";
33
  benchmark_runner runner{full_directory, test_name};
34
  runner.enable_memory_stats();
35
  runner.pre_allocate_stats();
36

37 38 39
  pls_matrix<double> a{matrix::MATRIX_SIZE};
  pls_matrix<double> b{matrix::MATRIX_SIZE};
  pls_matrix<double> result{matrix::MATRIX_SIZE};
40

41
  scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
42

43
//  scheduler.get_profiler().disable_memory_measure();
44 45 46 47 48
  runner.run_iterations(matrix::NUM_ITERATIONS, [&]() {
    scheduler.perform_work([&]() {
      result.multiply(a, b);
    });
  }, matrix::WARMUP_ITERATIONS);
49 50
//  scheduler.get_profiler().current_run().print_dag(std::cout);
//  scheduler.get_profiler().current_run().print_stats();
FritzFlorian committed
51

52 53
  runner.commit_results(true);
}