26 lines
553 B
C++
26 lines
553 B
C++
#include <cstdlib>
|
|
|
|
#include "matmul.h"
|
|
|
|
void matmul_cpu_initialize(size_t M, size_t N, size_t K) {
|
|
// Nothing to do
|
|
return;
|
|
}
|
|
|
|
void matmul_cpu(float *A, float *B, float *C, size_t M, size_t N, size_t K) {
|
|
// Naive CPU matrix multiplication
|
|
for (size_t i = 0; i < M; i++) {
|
|
for (size_t j = 0; j < N; j++) {
|
|
float c = 0.0;
|
|
for (size_t k = 0; k < K; k++) {
|
|
c += A[i * M + k] * B[k * N + j];
|
|
}
|
|
C[i * M + j] = c;
|
|
}
|
|
}
|
|
}
|
|
|
|
void matmul_cpu_finalize(size_t M, size_t N, size_t K) {
|
|
// Nothing to do
|
|
return;
|
|
} |