]> foleosoft.com Git - QAnsel.git/commitdiff
Mon Mar 4 06:25:30 PM EST 2024
authormiha-q <>
Mon, 4 Mar 2024 23:25:30 +0000 (18:25 -0500)
committermiha-q <>
Mon, 4 Mar 2024 23:25:30 +0000 (18:25 -0500)
src/QAnsel.c
src/complex.c

index e501f37c8f687fb91602a843550ff482e9e120d6..90c68aa1b420f30e3eaa3ab646197be5e5802415 100644 (file)
@@ -212,22 +212,6 @@ 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));
 
-
-               printf("%ix%i (knk)\n", tmp.rows, tmp.cols);
-               unsigned long int us1, us2;
-               us1 = get_time();
-               cpx_mtx_knk_metal(tmp.ptr, filter.ptr, gate.ptr, filter.rows, filter.cols, gate.rows, gate.cols);
-               us2 = get_time();
-               printf("\tMetal: %lu\n", us2 - us1);
-               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("\tThreads: %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();
-               printf("\tBare: %lu\n", us2 - us1);
-
                #ifdef SPEED_TEST
                printf("%ix%i (knk)\n", tmp.rows, tmp.cols);
                unsigned long int us1, us2;
@@ -244,6 +228,18 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
                us2 = get_time();
                printf("\tBare: %lu\n", us2 - us1);
                #else
+               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);
+               }
                #endif
 
 
@@ -1407,8 +1403,6 @@ void process(int argc, char** argv)
 void main(int argc, char** argv)
 {
        USE_GPU = cpx_mtx_begin();
-       USE_GPU = 0;
-       USE_THREADS = 0;
 
        RANDOM_FILE = fopen("/dev/TrueRNG0", "r");
        if (!RANDOM_FILE) RANDOM_FILE = fopen("/dev/random", "r");
index 3688faeda360e4e46104473c1c9d5810ebf7b257..4aca6ecfa0366beea13a12089bb73e2456feb3ec 100644 (file)
@@ -474,7 +474,7 @@ void cpx_mtx_knk_metal(float* ptrR, float* ptrA, float* ptrB, int rowsA, int col
        err = clSetKernelArg(kernel, 6, sizeof(int), &colsB); gpuerr(clSetKernelArg);
 
        //Run the program
-       err = clEnqueueNDRangeKernel(cpx_mtx_command_queue, kernel, 1, NULL, (size_t[]){rowsR}, NULL, 0, NULL, NULL);
+       err = clEnqueueNDRangeKernel(cpx_mtx_command_queue, kernel, 2, NULL, (size_t[]){rowsR, colsR}, NULL, 0, NULL, NULL);
        gpuerr(clEnqueueNDRangeKernel);
 
        //Wait for completion