// vim:ts=2:sw=2:expandtab #include "mat_mul.h" #include "util.h" #include #include #include #include static float *A, *B, *C; static int M, N, K; static int num_threads; static int mpi_rank, mpi_world_size; static int tslice; static int BK; static int BJ; static int BI; static int psize; // size of a process inline int min(const int a, const int b){return a>b ? b : a;} static void mat_mul_omp() { // TODO: parallelize & optimize matrix multiplication // Use num_threads per node omp_set_num_threads(num_threads); tslice = (int) (psize / num_threads); BI = 32; BJ = 1024; BK = 1024; #pragma omp parallel { int tid = omp_get_thread_num(); int tstart = tslice * tid; int tend = (tid ==(num_threads-1)) ? psize : tstart + tslice; // printf("(tid, tstart, tend) = (%d, %d, %d)\n", tid, tstart, tend); float Aik; for(int ii=tstart; ii