]> foleosoft.com Git - QAnsel.git/commitdiff
Mon Mar 4 05:31:49 PM EST 2024
authormiha-q <>
Mon, 4 Mar 2024 22:31:49 +0000 (17:31 -0500)
committermiha-q <>
Mon, 4 Mar 2024 22:31:49 +0000 (17:31 -0500)
src/QAnsel.c

index 7907c2e6efa450d7c48a46477cd5b4f45dc7fd5e..db9885a4d045888d99d9a60863523e586da7b90c 100644 (file)
@@ -211,18 +211,34 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                tmp.cols = filter.cols * gate.cols;
                tmp.ptr = malloc(tmp.rows * (tmp.cols * 2) * sizeof(float));
 
-               if (USE_GPU && 0)
-               {
-                       cpx_mtx_knk_metal(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
-               }
-               else if (USE_THREADS)
-               {
-                       cpx_mtx_knk_threads(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
-               }
-               else
-               {
-                       cpx_mtx_knk(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
-               }
+
+               printf("%ix%i (knk)\n", tmp.rows, tmp.cols);
+               unsigned long int us1, us2;
+               us1 = get_time();
+               cpx_mtx_knk_metal(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+               us2 = get_time();
+               printf("\tMetal: %lu\n", us2 - us1);
+               us1 = get_time();
+               cpx_mtx_knk_threads(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+               us2 = get_time();
+               printf("\tThreads: %lu\n", us2 - us1);
+               us1 = get_time();
+               cpx_mtx_knk(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+               us2 = get_time();
+               printf("\tBare: %lu\n", us2 - us1);
+
+//             if (USE_GPU && 0)
+//             {
+//                     cpx_mtx_knk_metal(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+//             }
+//             else if (USE_THREADS)
+//             {
+//                     cpx_mtx_knk_threads(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+//             }
+//             else
+//             {
+//                     cpx_mtx_knk(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+//             }
 
 
                free(filter.ptr);
@@ -232,9 +248,9 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
        }
 
        cpx_mtx_init(&tmp, stateVector->rows, stateVector->cols);
-       printf("%ix%i\n", tmp.rows, tmp.cols);
-       unsigned long int us1, us2;
        
+       printf("%ix%i (dot)\n", tmp.rows, tmp.cols);
+       unsigned long int us1, us2;
        us1 = get_time();
        cpx_mtx_dot_metal(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
        us2 = get_time();