-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.cpp
More file actions
51 lines (38 loc) · 1.43 KB
/
bench.cpp
File metadata and controls
51 lines (38 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <iomanip>
#include <omp.h>
#include "matmul.h"
#include "goto.h"
#include "layered.h"
#include "util.h"
#include "blis.h"
void bench_1920() {
const int N = 1920;
float* a = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* b = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* c = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* ans = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
rand_matrix<N>(a);
rand_matrix<N>(b);
test_program<N>("baseline", baseline<N>, a, b, ans, ans);
test_program<N>("blis_12x8", blis_12x8<N, 96, 48, 960>, a, b, c, ans);
}
void bench_1024() {
const int N = 1024;
float* a = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* b = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* c = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
float* ans = static_cast<float*>(std::aligned_alloc(32, sizeof(float) * N * N));
rand_matrix<N>(a);
rand_matrix<N>(b);
test_program<N>("baseline", baseline<N>, a, b, ans, ans);
test_program<N>("layered", gemm<N>, a, b, c, ans);
test_program<N>("layered2", gemm2<N>, a, b, c, ans);
test_program<N>("blis", blis<N, 128, 64, 1024>, a, b, c, ans);
}
int main() {
std::cout << "N = 1024\n";
bench_1024();
std::cout << "\nN = 1920\n";
bench_1920();
}