forked from dpardell/KernelFaRer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskip-gemm-5.cc
More file actions
26 lines (24 loc) · 975 Bytes
/
Copy pathskip-gemm-5.cc
File metadata and controls
26 lines (24 loc) · 975 Bytes
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
void striped_gemm(double *A, double *B, double *C,
int m, int n, int k,
int lda, int ldb, int ldc) {
constexpr int i_blk = 128;
constexpr int j_blk = 64;
constexpr int p_blk = 128;
// Naive + Interchange + Blocking GEMM
for (int i = 0; i < m; i+=i_blk) {
for (int p = 0; p < k; p+=p_blk) {
for (int j = 0; j < n; j+=j_blk) {
const int ii_end = ((i + i_blk) < m) ? (i + i_blk) : m;
for (long ii = i; ii < ii_end; ii+=2) {
const int pp_end = ((p + p_blk) < k) ? (p + p_blk) : k;
for (long pp = p; pp < pp_end; pp++) {
const int jj_end = ((j + j_blk) < n) ? (j + j_blk) : n;
for (long jj = j; jj < jj_end; jj++) {
C[ii * ldc + jj] += A[ ii * lda + pp] * B[ pp * ldb + jj];
}
}
}
}
}
}
}