]> foleosoft.com Git - QAnsel.git/commitdiff
Sat Mar 2 10:35:12 PM EST 2024
authormiha-q <>
Sun, 3 Mar 2024 03:35:12 +0000 (22:35 -0500)
committermiha-q <>
Sun, 3 Mar 2024 03:35:12 +0000 (22:35 -0500)
src/gpu.c
src/gpu_mmul.cl

index bc06d62afa2528bfd00f32c32e0aabb64a566684..b5e2ef013afcfbd5b07b9c0382ceee3a5d63c0b4 100644 (file)
--- a/src/gpu.c
+++ b/src/gpu.c
@@ -69,7 +69,7 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, size_t rowsA, size_t colsB,
        //Create buffers
        size_t sizeA = rowsA * shared;
        size_t sizeB = shared * colsB;
-       size_t sizeR = shared * shared;
+       size_t sizeR = rowsA * colsB;
        cl_int err;
        cl_mem memA = clCreateBuffer(GPU_context, CL_MEM_READ_ONLY, sizeof(float) * sizeA, NULL, &err);
        if (err != CL_SUCCESS)
@@ -171,7 +171,7 @@ void GPU_mmul(float* ptrR, float* ptrA, float* ptrB, size_t rowsA, size_t colsB,
                exit(1);
        }
        //Run the program
-       size_t work_size[] = {shared, shared};
+       size_t work_size[] = {rowsA, colsB};
        err = clEnqueueNDRangeKernel(GPU_command_queue, kernel, 2, NULL, work_size, NULL, 0, NULL, NULL);
        if (err != CL_SUCCESS)
        {
index 13c5301e2d85df44d6002e2e0164f6efae529473..1f8e4f87690d3df3e1e406430052b26bcbd3d9f7 100644 (file)
@@ -13,9 +13,9 @@ __kernel void gpu_mmul
     int row = get_global_id(0);
     int col = get_global_id(1);
     float sum = 0;
-    for (int i = 0; i < shared; i++)
+    for (int i = 0; i < rowsA; i++)
     {
         sum += ptrA[row * colsA + i] * ptrB[i * colsB + col];
     }
-    ptrR[row * shared + col] = sum;
+    ptrR[row * colsB + col] = sum;
 }
\ No newline at end of file