#include "mat_mul.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 TS 32 #define WPT 8 #define MAX_NUM_DEVICES 4 static cl_int err; static cl_platform_id platform; //static cl_device_id device; static cl_device_id devices[MAX_NUM_DEVICES]; static cl_context context; //static cl_command_queue queue; static cl_command_queue queues[MAX_NUM_DEVICES]; static cl_program program; //static cl_kernel kernel; static cl_kernel kernels[MAX_NUM_DEVICES]; static cl_mem a_d[MAX_NUM_DEVICES], b_d[MAX_NUM_DEVICES], c_d[MAX_NUM_DEVICES]; static float *A, *B, *C; static int M, N, K; static int seperate_M[MAX_NUM_DEVICES]; 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; // Setup kernel arguments for (int i=0; i a_d (gpu), B (cpu) -> b_d (gpu) int offset = 0; for (int i=0; i C (cpu) int offset = 0; for (int i=0; i