main.cpp 1.26 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"
7

8
using namespace comparison_benchmarks::base;
9 10

template<typename T, int SIZE>
11
class pls_matrix : public matrix::matrix<T, SIZE> {
12
 public:
13
  pls_matrix() : matrix::matrix<T, SIZE>() {}
14

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

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

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

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

34 35 36
  pls_matrix<double, matrix::MATRIX_SIZE> a;
  pls_matrix<double, matrix::MATRIX_SIZE> b;
  pls_matrix<double, matrix::MATRIX_SIZE> result;
37

38
  scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
39

40 41 42 43 44
  runner.run_iterations(matrix::NUM_ITERATIONS, [&]() {
    scheduler.perform_work([&]() {
      result.multiply(a, b);
    });
  }, matrix::WARMUP_ITERATIONS);
45 46
  runner.commit_results(true);
}