cl_device_id GPU_device_id;
cl_context GPU_context;
cl_command_queue GPU_command_queue;
-unsigned char* GPU_mmul_cache = NULL;
-size_t GPU_mmul_cache_len = 0;
+unsigned char* GPU_cache = NULL;
+size_t GPU_cache_len = 0;
uint8_t GPU_init()
{
{
fprintf(stderr, "GPU error: clReleaseContext() failed.\n");
}
- free(GPU_mmul_cache);
+ free(GPU_cache);
}
void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, int rowsA, int colsB, int shared)
//Load and compile program
cl_program program;
- if (GPU_mmul_cache == NULL)
+ if (GPU_cache == NULL)
{
program = clCreateProgramWithSource(GPU_context, 1, (const char*[]){src_gpu_mmul_cl}, NULL, &err);
gpuerr(clCreateProgramWithSource);
free(log);
exit(1);
}
- err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &GPU_mmul_cache_len, NULL);
+ err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &GPU_cache_len, NULL);
gpuerr(clGetProgramInfo);
- GPU_mmul_cache = malloc(GPU_mmul_cache_len);
- clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char*), &GPU_mmul_cache, NULL);
+ GPU_cache = malloc(GPU_cache_len);
+ clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char*), &GPU_cache, NULL);
gpuerr(clGetProgramInfo);
}
else
{
- program = clCreateProgramWithBinary(GPU_context, 1, &GPU_device_id, &GPU_mmul_cache_len, (const unsigned char**)&GPU_mmul_cache, NULL, &err);
+ program = clCreateProgramWithBinary(GPU_context, 1, &GPU_device_id, &GPU_cache_len, (const unsigned char**)&GPU_cache, NULL, &err);
gpuerr(clCreateProgramWithBinary);
}
//Load and compile program
cl_program program;
- if (GPU_mmul_cache == NULL)
+ if (GPU_cache == NULL)
{
program = clCreateProgramWithSource(GPU_context, 1, (const char*[]){src_gpu_mmul_cl}, NULL, &err);
gpuerr(clCreateProgramWithSource);
free(log);
exit(1);
}
- err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &GPU_mmul_cache_len, NULL); gpuerr(clGetProgramInfo);
- GPU_mmul_cache = malloc(GPU_mmul_cache_len);
- clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char*), &GPU_mmul_cache, NULL); gpuerr(clGetProgramInfo);
+ err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &GPU_cache_len, NULL); gpuerr(clGetProgramInfo);
+ GPU_cache = malloc(GPU_cache_len);
+ clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char*), &GPU_cache, NULL); gpuerr(clGetProgramInfo);
}
else
{
- program = clCreateProgramWithBinary(GPU_context, 1, &GPU_device_id, &GPU_mmul_cache_len, (const unsigned char**)&GPU_mmul_cache, NULL, &err);
+ program = clCreateProgramWithBinary(GPU_context, 1, &GPU_device_id, &GPU_cache_len, (const unsigned char**)&GPU_cache, NULL, &err);
gpuerr(clCreateProgramWithBinary);
}