]> foleosoft.com Git - QAnsel.git/commitdiff
Thu Mar 7 06:27:12 PM EST 2024
authormiha-q <>
Thu, 7 Mar 2024 23:27:12 +0000 (18:27 -0500)
committermiha-q <>
Thu, 7 Mar 2024 23:27:12 +0000 (18:27 -0500)
src/QAnsel.c

index 7b29e1a9fcb66dfa5e8ea0de8ee791d33b031310..a978926530b58820de8c4cf662053c21ba854f99 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
 {
@@ -242,11 +242,11 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                us1 = get_time();
                cpx_mtx_knk_threads(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                us2 = get_time();
-               printf("\tThreads2x2: %lu\n", us2 - us1);
+               printf("\tThreads: %lu\n", us2 - us1);
                us1 = get_time();
                cpx_mtx_knk_threads_2x2(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                us2 = get_time();
-               printf("\tThreads: %lu\n", us2 - us1);
+               printf("\tThreads2x2: %lu\n", us2 - us1);
                us1 = get_time();
                cpx_mtx_knk(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                us2 = get_time();
@@ -263,16 +263,11 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                }
                else if (USE_THREADS && tmp.rows >= 512)
                {
-                       cpx_mtx_knk_threads(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+                       cpx_mtx_knk_threads_2x2(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                }
                else
                {
-                       if (filter.rows / 8  == 0)
-                               cpx_mtx_knk_2x2_R
-                                       (tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
-                       else
-                               cpx_mtx_knk_2x2_Rx4
-                                       (tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
+                       cpx_mtx_knk_2x2(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
                }
                #endif
 
@@ -304,7 +299,7 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
        {
                cpx_mtx_dot_metal(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
        }
-       else if (USE_THREADS && tmp.rows >= 512)
+       else if (USE_THREADS && tmp.cols >= 512)
        {
                cpx_mtx_dot_threads(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
        }
@@ -1439,7 +1434,7 @@ void main(int argc, char** argv)
        RANDOM_FILE = fopen("/dev/TrueRNG0", "r");
        if (!RANDOM_FILE) RANDOM_FILE = fopen("/dev/random", "r");
        USE_GPU = 0;
-       USE_THREADS = 0;
+       USE_THREADS = 1;
        process(argc, argv);
        fclose(RANDOM_FILE);
        if (USE_GPU) cpx_mtx_clean();