chundoong-lab-ta/APWS23/matmul-skeleton/matmul_cpu.cpp

24 lines
539 B
C++
Raw Normal View History

2023-02-01 17:12:31 +09:00
#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;
2023-02-14 01:23:28 +09:00
for (size_t k = 0; k < K; k++) { c += A[i * M + k] * B[k * N + j]; }
2023-02-01 17:12:31 +09:00
C[i * M + j] = c;
}
}
}
void matmul_cpu_finalize(size_t M, size_t N, size_t K) {
// Nothing to do
return;
}