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

index 3c868eb9b4b51ad2ead28c78647022fa746da2f5..7907c2e6efa450d7c48a46477cd5b4f45dc7fd5e 100644 (file)
@@ -232,19 +232,36 @@ void qansel_instruction(cpx_mtx_t* stateVector, unsigned char qubitCount, QInstr
        }
 
        cpx_mtx_init(&tmp, stateVector->rows, stateVector->cols);
-       if (USE_GPU)
-       {
-               printf("A\n");
-               cpx_mtx_dot_metal(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
-       }
-       else if (USE_THREADS)
-       {
-               cpx_mtx_dot_threads(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
-       }
-       else
-       {
-               cpx_mtx_dot(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
-       }
+       printf("%ix%i\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();
+       printf("\tMetal: %lu\n", us2 - us1);
+       us1 = get_time();
+       cpx_mtx_dot_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_dot(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)
+       //{
+       //      
+       //      cpx_mtx_dot_metal(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+       //}
+       //else if (USE_THREADS)
+       //{
+       //      cpx_mtx_dot_threads(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+       //}
+       //else
+       //{
+       //      cpx_mtx_dot(tmp.ptr, stateVector->ptr, filter.ptr, stateVector->rows, stateVector->cols, filter.rows, filter.cols);
+       //}
        free(stateVector->ptr);
        stateVector->ptr = tmp.ptr;
        free(filter.ptr);
index 4320e716b3eeca0745b349dcf5b6ef5bc16d873a..09e715133ec355eadf3fd7926dfc070604cb54db 100644 (file)
@@ -1,9 +1,10 @@
 #include <stdio.h>
-
+#include <time.h>
 #if defined(_WIN32) || defined(_WIN64)
 #include <windows.h>
 #elif defined(__linux__)
 #include <unistd.h>
+#include <sys/time.h>
 #elif defined(__APPLE__)
 #include <sys/sysctl.h>
 #endif
@@ -50,4 +51,12 @@ int get_core_count()
         }
     }
     return coreCount;
+}
+
+unsigned long int get_time()
+{
+    struct timeval tv;
+    gettimeofday(&tv,NULL);
+    unsigned long int timestamp = 1000000 * tv.tv_sec + tv.tv_usec;
+    return timestamp;
 }
\ No newline at end of file