From afc07d6e836b45cec3bf7b74eefea7800c1b523b Mon Sep 17 00:00:00 2001 From: miha-q <> Date: Mon, 4 Mar 2024 18:03:36 -0500 Subject: [PATCH] Mon Mar 4 06:03:36 PM EST 2024 --- src/QAnsel.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/QAnsel.c b/src/QAnsel.c index bc29e5b..df82734 100644 --- a/src/QAnsel.c +++ b/src/QAnsel.c @@ -228,22 +228,21 @@ 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); -// } - + 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 + free(filter.ptr); filter.ptr = tmp.ptr; filter.rows = tmp.rows; @@ -268,7 +267,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) + { + 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); + } #endif free(stateVector->ptr); stateVector->ptr = tmp.ptr; -- 2.39.5