#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 MAX_DEV 4 static cl_int err; static cl_platform_id platform; static cl_device_id device[MAX_DEV]; static cl_context context; static cl_command_queue queue[MAX_DEV]; static cl_program program[MAX_DEV]; static cl_kernel kernel[MAX_DEV]; static cl_mem a_d[MAX_DEV], b_d[MAX_DEV], c_d[MAX_DEV]; int ndev; static float *A, *B, *C; static int M, N, K; 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 int size; for(int i =0; i a_d (gpu), B (cpu) -> b_d (gpu) // send the Array to Buffer Queue -> Q send A info to GPU a_d for (int i = 0; i C (cpu) for(int i = 0; i