]> foleosoft.com Git - QAnsel.git/commitdiff
Mon Mar 4 12:39:49 AM EST 2024
authormiha-q <>
Mon, 4 Mar 2024 05:39:49 +0000 (00:39 -0500)
committermiha-q <>
Mon, 4 Mar 2024 05:39:49 +0000 (00:39 -0500)
src/gpu/gpu.c

index eba335d4d6408e220a46d2f7449bddd3661301fd..23a6df5b17ed3291c26d4ce678df2535bbb61dd5 100644 (file)
@@ -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);
        }