Skip to content

Commit

Permalink
one malloc for all scratch buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
elinx committed Oct 5, 2021
1 parent c7b7973 commit 9416d59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ for my hardware in single thread

| | Shape | Memory | Memory(Readable) |
| :-----------: | :------: | :-----: | :--------------: |
| L1 Cache Size | | 196608 | 192 KB |
| L2 Cache Size | | 1572864 | 1.5 MB |
| L1 Cache Size | | 32768 | 32 KB |
| L2 Cache Size | | 262144 | 256 KB |
| L3 Cache Size | | 9437184 | 9 MB |
| M | 640 | | |
| N | 640 | | |
Expand Down
11 changes: 5 additions & 6 deletions manual_optimize_dgemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,10 @@ void manual_dgemm(const double *A, const double *B, double *C, const uint32_t M,
static_assert(!(MC % MR));
static_assert(!(KC % 4));

double *Bc = (double *)aligned_alloc(32, sizeof(double) * KC * NC);
double *Ac = (double *)aligned_alloc(32, sizeof(double) * MC * KC);
double *Cc = (double *)aligned_alloc(32, sizeof(double) * MR * NR);
double *buf = (double *)aligned_alloc(32, sizeof(double) * ((KC * NC) + (MC * KC) + (MR * NR)));
double *Bc = buf;
double *Ac = buf + KC * NC;
double *Cc = Ac + MC * KC;

for (uint32_t n_outer = 0; n_outer < n_outer_bound; n_outer += NC) {
for (uint32_t k_outer = 0; k_outer < k_outer_bound; k_outer += KC) {
Expand All @@ -829,9 +830,7 @@ void manual_dgemm(const double *A, const double *B, double *C, const uint32_t M,
}
}
}
free(Cc);
free(Ac);
free(Bc);
free(buf);
}

int main() {
Expand Down

0 comments on commit 9416d59

Please sign in to comment.