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

index 94b43d09cd58d4a50d0aad571de408f103df82fa..7eb1b3f603eb8f34b1367a716b4efe209e21c4d2 100644 (file)
@@ -12,13 +12,18 @@ __kernel void gpu_mmul
     const int rowsB = shared;
     const int rowsR = rowsA;
     const int colsR = colsB;
-    const int row = get_global_id(0);
-    const int col = get_global_id(1);
+    const int rowR = get_global_id(0);
+    const int colR = get_global_id(1);
+    int posA, posB;
     float sum = 0;
 
-    for (int i = 0; i < colsR; i++)
+    const int posR = colR + rowR * colsR;
+
+    for (int i = 0; i < shared; i++)
     {
-        sum += ptrA[row * colsA + i] * ptrB[i * colsB + col];
+        int posA = i + rowR * colsA;
+        int posB = colR + i * colsB;
+        sum += ptrA[posA] * ptrB[posB];
     }
     ptrR[row * colsR + col] = sum;
 }
\ No newline at end of file