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

26 lines
553 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;
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;
}