]> foleosoft.com Git - QAnsel.git/commitdiff
Tue Mar 5 07:35:47 PM EST 2024
authormiha-q <>
Wed, 6 Mar 2024 00:35:47 +0000 (19:35 -0500)
committermiha-q <>
Wed, 6 Mar 2024 00:35:47 +0000 (19:35 -0500)
examples/slow.txt
src/QAnsel.c
src/kernel.cl
src/kernel.cl.c
src/kernel_cpu.cl.c

index 7d34b45e4a8e5ebc5996d0b94b04c60a397f924a..f4126d6591edb7805ece613083561c0d244610fa 100644 (file)
@@ -1,13 +1,18 @@
 //designed to be slow
 qreg q[14];
-h q[0];
-h q[1];
-h q[2];
-h q[3];
-h q[4];
-h q[5];
-h q[6];
-h q[7];
-h q[8];
-h q[9];
-h q[10];
\ No newline at end of file
+x q[0];
+x q[1];
+x q[2];
+x q[3];
+x q[4];
+x q[5];
+x q[6];
+x q[7];
+x q[8];
+x q[9];
+x q[10];
+x q[11];
+x q[12];
+x q[13];
+
+born;
\ No newline at end of file
index 0eca8d24a0e59aaa35bef4d2712ad857550b8366..833970a50805a8fbdaf5a70cbf995944747f9c41 100644 (file)
@@ -12,7 +12,7 @@ FILE* RANDOM_FILE;
 #define GPU_ENABLED
 unsigned char USE_GPU = 1;
 unsigned char USE_THREADS = 1;
-//#define SPEED_TEST
+#define SPEED_TEST
 
 typedef struct
 {
@@ -226,9 +226,9 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                us1 = get_time();
                cpx_mtx_knk(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                us2 = get_time();
-               printf("\tBare: %lu\n", us2 - us1);
+               printf("\tBare(1): %lu\n", us2 - us1);
                #else
-               if (USE_GPU && 0) //this one's slower for some reason
+               if (USE_GPU) //this one's slower for some reason
                {
                        cpx_mtx_knk_metal(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                }
@@ -238,7 +238,7 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                }
                else
                {
-                       cpx_mtx_knk_2(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+                       cpx_mtx_knk(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                }
                #endif
 
@@ -1404,7 +1404,7 @@ void main(int argc, char** argv)
        USE_GPU = cpx_mtx_begin();
        RANDOM_FILE = fopen("/dev/TrueRNG0", "r");
        if (!RANDOM_FILE) RANDOM_FILE = fopen("/dev/random", "r");
-       USE_GPU = 0;
+       USE_GPU = 1;
        USE_THREADS = 0;
        process(argc, argv);
        fclose(RANDOM_FILE);
index 66c40dbb51eb2a74b7627c6b5c9312d552c8e5ed..37d178fb482d172da806dea69469cfbc1dff250a 100644 (file)
@@ -110,9 +110,9 @@ __kernel void kernel_knk_2
     //      carry out effectively a copy of
     //      the dot product procedure.
     const int rowsI = rowsB;
-    const int colsI = rowsB;
+    const int colsI = rowsI;
     const int rowsJ = colsA;
-    const int colsJ = colsA;
+    const int colsJ = rowsJ;
     const int rowsX = rowsA * rowsI;
     const int colsX = colsA * colsI;
     const int rowsY = rowsJ * rowsB;
@@ -146,8 +146,8 @@ __kernel void kernel_knk_2
         const int rowB = rowY % rowsB;
         const int colB = colY % colsB;
 
-        const int posA = rowA * (colsA * 2) + (colsA * 2);
-        const int posB = rowB * (colsB * 2) + (colsB * 2);
+        const int posA = rowA * (colsA * 2) + (colA * 2);
+        const int posB = rowB * (colsB * 2) + (colB * 2);
 
         const float rA = rowI == colI ? ptrA[posA] : 0;
         const float iA = rowI == colI ? ptrA[posA + 1] : 0;
@@ -165,4 +165,5 @@ __kernel void kernel_knk_2
     }
     ptrR[rowR * (colsR * 2) + (colR * 2)] = rR;
     ptrR[rowR * (colsR * 2) + (colR * 2) + 1] = iR;
+
 }
index 0b2ee4e360a41e6ef3131d55fa6af04ecc01c0b2..bcc822bbb16f21aebfb542dd93b390a2044dfb0f 100644 (file)
@@ -275,12 +275,12 @@ unsigned char src_kernel_cl[] = {
   0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x49, 0x20,
   0x3d, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20,
   0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x63,
-  0x6f, 0x6c, 0x73, 0x49, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x42,
+  0x6f, 0x6c, 0x73, 0x49, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x49,
   0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20,
   0x69, 0x6e, 0x74, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x4a, 0x20, 0x3d, 0x20,
   0x63, 0x6f, 0x6c, 0x73, 0x41, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
   0x6f, 0x6e, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x63, 0x6f, 0x6c,
-  0x73, 0x4a, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x73, 0x41, 0x3b, 0x0a,
+  0x73, 0x4a, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x4a, 0x3b, 0x0a,
   0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x69, 0x6e,
   0x74, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x58, 0x20, 0x3d, 0x20, 0x72, 0x6f,
   0x77, 0x73, 0x41, 0x20, 0x2a, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x49, 0x3b,
@@ -368,60 +368,60 @@ unsigned char src_kernel_cl[] = {
   0x6f, 0x6e, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x70, 0x6f, 0x73,
   0x41, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x41, 0x20, 0x2a, 0x20, 0x28,
   0x63, 0x6f, 0x6c, 0x73, 0x41, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20, 0x2b,
-  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x73, 0x41, 0x20, 0x2a, 0x20, 0x32, 0x29,
-  0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
-  0x6e, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x42,
-  0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x42, 0x20, 0x2a, 0x20, 0x28, 0x63,
-  0x6f, 0x6c, 0x73, 0x42, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20, 0x2b, 0x20,
-  0x28, 0x63, 0x6f, 0x6c, 0x73, 0x42, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x3b,
-  0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
-  0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x41,
-  0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x49, 0x20, 0x3d, 0x3d, 0x20, 0x63,
-  0x6f, 0x6c, 0x49, 0x20, 0x3f, 0x20, 0x70, 0x74, 0x72, 0x41, 0x5b, 0x70,
-  0x6f, 0x73, 0x41, 0x5d, 0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20,
-  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20,
-  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x41, 0x20, 0x3d, 0x20, 0x72,
-  0x6f, 0x77, 0x49, 0x20, 0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x49, 0x20,
-  0x3f, 0x20, 0x70, 0x74, 0x72, 0x41, 0x5b, 0x70, 0x6f, 0x73, 0x41, 0x20,
-  0x2b, 0x20, 0x31, 0x5d, 0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20,
+  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x41, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x3b,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e,
+  0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x42, 0x20,
+  0x3d, 0x20, 0x72, 0x6f, 0x77, 0x42, 0x20, 0x2a, 0x20, 0x28, 0x63, 0x6f,
+  0x6c, 0x73, 0x42, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20, 0x2b, 0x20, 0x28,
+  0x63, 0x6f, 0x6c, 0x42, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x3b, 0x0a, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73,
+  0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x41, 0x20, 0x3d,
+  0x20, 0x72, 0x6f, 0x77, 0x49, 0x20, 0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c,
+  0x49, 0x20, 0x3f, 0x20, 0x70, 0x74, 0x72, 0x41, 0x5b, 0x70, 0x6f, 0x73,
+  0x41, 0x5d, 0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c,
+  0x6f, 0x61, 0x74, 0x20, 0x69, 0x41, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77,
+  0x49, 0x20, 0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x49, 0x20, 0x3f, 0x20,
+  0x70, 0x74, 0x72, 0x41, 0x5b, 0x70, 0x6f, 0x73, 0x41, 0x20, 0x2b, 0x20,
+  0x31, 0x5d, 0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c,
+  0x6f, 0x61, 0x74, 0x20, 0x72, 0x42, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77,
+  0x4a, 0x20, 0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x4a, 0x20, 0x3f, 0x20,
+  0x70, 0x74, 0x72, 0x42, 0x5b, 0x70, 0x6f, 0x73, 0x42, 0x5d, 0x20, 0x3a,
+  0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20,
+  0x69, 0x42, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x4a, 0x20, 0x3d, 0x3d,
+  0x20, 0x63, 0x6f, 0x6c, 0x4a, 0x20, 0x3f, 0x20, 0x70, 0x74, 0x72, 0x42,
+  0x5b, 0x70, 0x6f, 0x73, 0x42, 0x20, 0x2b, 0x20, 0x31, 0x5d, 0x20, 0x3a,
+  0x20, 0x30, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x2f, 0x2f, 0x28, 0x72, 0x41, 0x20, 0x2b, 0x20, 0x69, 0x41, 0x29,
+  0x28, 0x72, 0x42, 0x20, 0x2b, 0x20, 0x69, 0x42, 0x29, 0x0a, 0x20, 0x20,
   0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20,
-  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x42, 0x20, 0x3d, 0x20, 0x72,
-  0x6f, 0x77, 0x4a, 0x20, 0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x4a, 0x20,
-  0x3f, 0x20, 0x70, 0x74, 0x72, 0x42, 0x5b, 0x70, 0x6f, 0x73, 0x42, 0x5d,
-  0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
-  0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61,
-  0x74, 0x20, 0x69, 0x42, 0x20, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x4a, 0x20,
-  0x3d, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x4a, 0x20, 0x3f, 0x20, 0x70, 0x74,
-  0x72, 0x42, 0x5b, 0x70, 0x6f, 0x73, 0x42, 0x20, 0x2b, 0x20, 0x31, 0x5d,
-  0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
-  0x20, 0x20, 0x20, 0x2f, 0x2f, 0x28, 0x72, 0x41, 0x20, 0x2b, 0x20, 0x69,
-  0x41, 0x29, 0x28, 0x72, 0x42, 0x20, 0x2b, 0x20, 0x69, 0x42, 0x29, 0x0a,
+  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20,
+  0x3d, 0x20, 0x72, 0x41, 0x20, 0x2a, 0x20, 0x72, 0x42, 0x3b, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74,
+  0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x65, 0x72,
+  0x20, 0x3d, 0x20, 0x72, 0x41, 0x20, 0x2a, 0x20, 0x69, 0x42, 0x3b, 0x0a,
   0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73,
-  0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x66, 0x69, 0x72, 0x73,
-  0x74, 0x20, 0x3d, 0x20, 0x72, 0x41, 0x20, 0x2a, 0x20, 0x72, 0x42, 0x3b,
+  0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x6e, 0x65,
+  0x72, 0x20, 0x3d, 0x20, 0x69, 0x41, 0x20, 0x2a, 0x20, 0x72, 0x42, 0x3b,
   0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e,
-  0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6f, 0x75, 0x74,
-  0x65, 0x72, 0x20, 0x3d, 0x20, 0x72, 0x41, 0x20, 0x2a, 0x20, 0x69, 0x42,
-  0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
-  0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e,
-  0x6e, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x41, 0x20, 0x2a, 0x20, 0x72,
-  0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63,
-  0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c,
-  0x61, 0x73, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x69, 0x41, 0x20, 0x2a, 0x20,
-  0x69, 0x42, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
-  0x20, 0x72, 0x52, 0x20, 0x2b, 0x3d, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74,
-  0x20, 0x2b, 0x20, 0x6c, 0x61, 0x73, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20,
-  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x52, 0x20, 0x2b, 0x3d, 0x20,
-  0x6f, 0x75, 0x74, 0x65, 0x72, 0x20, 0x2b, 0x20, 0x69, 0x6e, 0x6e, 0x65,
-  0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
-  0x20, 0x70, 0x74, 0x72, 0x52, 0x5b, 0x72, 0x6f, 0x77, 0x52, 0x20, 0x2a,
-  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x73, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29,
-  0x20, 0x2b, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x52, 0x20, 0x2a, 0x20, 0x32,
-  0x29, 0x5d, 0x20, 0x3d, 0x20, 0x72, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20,
-  0x20, 0x70, 0x74, 0x72, 0x52, 0x5b, 0x72, 0x6f, 0x77, 0x52, 0x20, 0x2a,
-  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x73, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29,
-  0x20, 0x2b, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x52, 0x20, 0x2a, 0x20, 0x32,
-  0x29, 0x20, 0x2b, 0x20, 0x31, 0x5d, 0x20, 0x3d, 0x20, 0x69, 0x52, 0x3b,
-  0x0a, 0x7d, 0x00
+  0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c, 0x61, 0x73,
+  0x74, 0x73, 0x20, 0x3d, 0x20, 0x69, 0x41, 0x20, 0x2a, 0x20, 0x69, 0x42,
+  0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
+  0x52, 0x20, 0x2b, 0x3d, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x2b,
+  0x20, 0x6c, 0x61, 0x73, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x69, 0x52, 0x20, 0x2b, 0x3d, 0x20, 0x6f, 0x75,
+  0x74, 0x65, 0x72, 0x20, 0x2b, 0x20, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x3b,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70,
+  0x74, 0x72, 0x52, 0x5b, 0x72, 0x6f, 0x77, 0x52, 0x20, 0x2a, 0x20, 0x28,
+  0x63, 0x6f, 0x6c, 0x73, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20, 0x2b,
+  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x5d,
+  0x20, 0x3d, 0x20, 0x72, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70,
+  0x74, 0x72, 0x52, 0x5b, 0x72, 0x6f, 0x77, 0x52, 0x20, 0x2a, 0x20, 0x28,
+  0x63, 0x6f, 0x6c, 0x73, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20, 0x2b,
+  0x20, 0x28, 0x63, 0x6f, 0x6c, 0x52, 0x20, 0x2a, 0x20, 0x32, 0x29, 0x20,
+  0x2b, 0x20, 0x31, 0x5d, 0x20, 0x3d, 0x20, 0x69, 0x52, 0x3b, 0x0a, 0x0a,
+  0x7d, 0x00
 };
-unsigned int src_kernel_cl_len = 5079;
+unsigned int src_kernel_cl_len = 5078;
index c304adc625831db0be8088696bc852a0f5cc69b2..908a6897356aabe2c792e1abad8fc9f52235f5a2 100644 (file)
@@ -104,9 +104,9 @@ void kernel_knk_2
     //      carry out effectively a copy of
     //      the dot product procedure.
     const int rowsI = rowsB;
-    const int colsI = rowsB;
+    const int colsI = rowsI;
     const int rowsJ = colsA;
-    const int colsJ = colsA;
+    const int colsJ = rowsJ;
     const int rowsX = rowsA * rowsI;
     const int colsX = colsA * colsI;
     const int rowsY = rowsJ * rowsB;
@@ -138,8 +138,8 @@ void kernel_knk_2
         const int rowB = rowY % rowsB;
         const int colB = colY % colsB;
 
-        const int posA = rowA * (colsA * 2) + (colsA * 2);
-        const int posB = rowB * (colsB * 2) + (colsB * 2);
+        const int posA = rowA * (colsA * 2) + (colA * 2);
+        const int posB = rowB * (colsB * 2) + (colB * 2);
 
         const float rA = rowI == colI ? ptrA[posA] : 0;
         const float iA = rowI == colI ? ptrA[posA + 1] : 0;
@@ -157,4 +157,5 @@ void kernel_knk_2
     }
     ptrR[rowR * (colsR * 2) + (colR * 2)] = rR;
     ptrR[rowR * (colsR * 2) + (colR * 2) + 1] = iR;
+
 }