From 240da0aa45fbcdf443d55a8d3db7975af8d7a300 Mon Sep 17 00:00:00 2001 From: miha-q <> Date: Mon, 4 Mar 2024 00:39:49 -0500 Subject: [PATCH] Mon Mar 4 12:39:49 AM EST 2024 --- src/gpu/gpu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gpu/gpu.c b/src/gpu/gpu.c index eba335d..23a6df5 100644 --- a/src/gpu/gpu.c +++ b/src/gpu/gpu.c @@ -5,8 +5,8 @@ cl_platform_id GPU_platform_id; 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() { @@ -66,7 +66,7 @@ void GPU_clean() { 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) @@ -91,7 +91,7 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, int rowsA, int colsB, int s //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); @@ -107,15 +107,15 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, int rowsA, int colsB, int s 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); } @@ -171,7 +171,7 @@ void GPU_knk(float* ptrR, int rowsR, int colsR, float* ptrA, int rowsA, int cols //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); @@ -187,13 +187,13 @@ void GPU_knk(float* ptrR, int rowsR, int colsR, float* ptrA, int rowsA, int cols 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); } -- 2.39.5