#include "mat_mul.h" #include #include #include #include #define bsize 64 static float *A, *B, *C; static int M, N, K; static int num_threads; static void* mat_mul_thread(void *data) { // TODO: parallelize & optimize matrix multiplication /* for (int i = 0; i < M; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < K; ++k) { C[i * N + j] += A[i * K + k] * B[k * N + j]; } } } */ int pid = *(int*)data; int block = M / num_threads; int start = pid*block; int end = (pid == num_threads-1)? M: (pid+1)*block; float Mat_A; for (int kk=0; kk