#include "mat_mul.h" #include "util.h" #include #include #define CHECK_ERROR(err) \ if (err != CL_SUCCESS) { \ printf("[%s:%d] OpenCL error %d\n", __FILE__, __LINE__, err); \ exit(EXIT_FAILURE); \ } #define NGPU 4 #define VW 8 #define TS 32 #define WPT 8 static cl_int err; static cl_platform_id platform; static cl_device_id device[NGPU]; static cl_context context; static cl_command_queue queue[NGPU]; static cl_program program; static cl_kernel kernel[NGPU]; static cl_mem a_d[NGPU], b_d[NGPU], c_d[NGPU]; static float *A, *B, *C; static int M, N, K; static int min(int x, int y) { return x < y ? x : y; } void mat_mul(float *_A, float *_B, float *_C, int _M, int _N, int _K) { A = _A, B = _B, C = _C; M = _M, N = _N, K = _K; int offset,rows; // Setup kernel arguments for(int i=0; i a_d (gpu), B (cpu) -> b_d (gpu) int offset; int rows; for(int i=0; i C (cpu) int offset,rows; for(int i=0; i