#include "mat_mul.h" #include #include #include #define BLOCKSIZE 32 #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif static float *A, *B, *C; static int M, N, K; static int num_threads; static void* worker(void *data) { int pid = * (int *) data; int slice = M / num_threads; int start = pid * slice; int end = pid == num_threads - 1 ? M : (pid + 1) * slice; float Aik; int bs = BLOCKSIZE; int ssize; int j; /* for (int kk = 0; kk < K; kk += bs) { for (int jj = 0; jj < N; jj += bs) { for (int i = start; i < end; ++i) { for (int k = kk; k < min(kk + bs, K); ++k) { Aik = A[i * K + k]; ssize = (min(jj + bs, N)/8)*8; for (j = jj; j < ssize; j+=8 ) { C[i * N + j] += Aik * B[k * N + j]; C[i * N + j+1] += Aik * B[k * N + j+1]; C[i * N + j+2] += Aik * B[k * N + j+2]; C[i * N + j+3] += Aik * B[k * N + j+3]; C[i * N + j+4] += Aik * B[k * N + j+4]; C[i * N + j+5] += Aik * B[k * N + j+5]; C[i * N + j+6] += Aik * B[k * N + j+6]; C[i * N + j+7] += Aik * B[k * N + j+7]; } for(j;j