Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Functions
apply_large_kernel_to_input_AVX.h File Reference

Header file for AVX-optimized implementations for applying multi-qubit gate kernels to quantum state vectors and matrices. More...

#include <immintrin.h>
#include "matrix.h"
#include "matrix_float.h"
#include "common.h"
#include "apply_large_kernel_to_input.h"
Include dependency graph for apply_large_kernel_to_input_AVX.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP (Matrix &two_qbit_unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 Apply two-qubit gate kernel to an input matrix using AVX optimization and OpenMP parallelization. More...
 
void apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP32 (Matrix_float &two_qbit_unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_AVX (Matrix &u3_1qbit1, Matrix &u3_qbit2, Matrix &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization. More...
 
void apply_crot_kernel_to_matrix_input_AVX32 (Matrix_float &u3_1qbit1, Matrix_float &u3_qbit2, Matrix_float &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_AVX_parallel (Matrix &u3_1qbit1, Matrix &u3_1qbit2, Matrix &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization and parallel processing. More...
 
void apply_crot_kernel_to_matrix_input_AVX_parallel32 (Matrix_float &u3_1qbit1, Matrix_float &u3_1qbit2, Matrix_float &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_from_right_AVX (Matrix &u3_1qbit1, Matrix &u3_qbit2, Matrix &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_from_right_AVX32 (Matrix_float &u3_1qbit1, Matrix_float &u3_qbit2, Matrix_float &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_from_right_AVX_parallel (Matrix &u3_1qbit1, Matrix &u3_1qbit2, Matrix &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_crot_kernel_to_matrix_input_from_right_AVX_parallel32 (Matrix_float &u3_1qbit1, Matrix_float &u3_1qbit2, Matrix_float &input, const int &target_qbit, const int &control_qbit, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX_OpenMP (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX_OpenMP32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX_TBB (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_from_right_AVX_TBB32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_to_input_AVX (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 Apply multi-qubit gate kernel to an input matrix using AVX optimization. More...
 
void apply_large_kernel_to_input_AVX32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_to_input_AVX_OpenMP (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 Apply multi-qubit gate kernel to an input matrix using AVX optimization and OpenMP parallelization. More...
 
void apply_large_kernel_to_input_AVX_OpenMP32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
void apply_large_kernel_to_input_AVX_TBB (Matrix &unitary, Matrix &input, std::vector< int > involved_qbits, const int &matrix_size)
 Apply multi-qubit gate kernel to an input matrix using AVX optimization and TBB parallelization. More...
 
void apply_large_kernel_to_input_AVX_TBB32 (Matrix_float &unitary, Matrix_float &input, std::vector< int > involved_qbits, const int &matrix_size)
 
__m256d complex_mult_AVX (__m256d input_vec, __m256d unitary_row_vec, __m256d neg)
 Perform complex multiplication using AVX intrinsics. More...
 
__m256d * construct_mv_xy_vectors (const Matrix &gate_kernel_unitary, const int &matrix_size)
 Precompute AVX vectors for the unitary matrix to optimize complex multiplication. More...
 
__m256d get_AVX_vector (double *element_outer, double *element_inner)
 Helper function to load and prepare AVX vectors with outer and inner elements for complex multiplication. More...
 
void get_block_indices (int N, const std::vector< int > &tq, const std::vector< int > &non_targets, int iter_idx, std::vector< int > &indices)
 Compute the indices for a given block in the quantum state. More...
 
void get_block_indices_fast (int iter_idx, const std::vector< int > &target_qubits, const std::vector< int > &non_targets, const std::vector< int > &block_pattern, std::vector< int > &indices)
 Efficiently compute the indices for a given block using precomputed patterns. More...
 
void precompute_index_mapping (const std::vector< int > &target_qubits, const std::vector< int > &non_targets, std::vector< int > &block_pattern)
 Precompute the index mapping for target and non-target qubits. More...
 

Detailed Description

Header file for AVX-optimized implementations for applying multi-qubit gate kernels to quantum state vectors and matrices.

Definition in file apply_large_kernel_to_input_AVX.h.

Function Documentation

◆ apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP()

void apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP ( Matrix two_qbit_unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Apply two-qubit gate kernel to an input matrix using AVX optimization and OpenMP parallelization.

Parameters
two_qbit_unitaryThe 4x4 unitary matrix representing the two-qubit gate operation
inputThe input matrix on which the transformation is applied
involved_qbitsThe qubits involved in the gate operation (2 qubits)
matrix_sizeThe size of the input matrix (should be a power of 2)

Definition at line 3520 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP32()

void apply_2qbit_kernel_to_matrix_input_parallel_AVX_OpenMP32 ( Matrix_float two_qbit_unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5960 of file apply_large_kernel_to_input_AVX.cpp.

◆ apply_crot_kernel_to_matrix_input_AVX()

void apply_crot_kernel_to_matrix_input_AVX ( Matrix u3_1qbit1,
Matrix u3_1qbit2,
Matrix input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization.

Parameters
u3_1qbit1The U3 gate matrix for the first qubit
u3_qbit2The U3 gate matrix for the second qubit
inputThe input matrix on which the transformation is applied
target_qbitThe target qubit index
control_qbitThe control qubit index
matrix_sizeThe size of the input matrix (should be a power of 2)

Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization.

Parameters
u3_1qbit1The 2x2 kernel to be applied on target |1>
u3_1qbit2The 2x2 kernel to be applied on target |0>
inputThe input matrix on which the transformation is applied
target_qbitThe target qubit
control_qbitThe control qubit
matrix_sizeThe size of the input

Definition at line 3617 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_AVX32()

void apply_crot_kernel_to_matrix_input_AVX32 ( Matrix_float u3_1qbit1,
Matrix_float u3_qbit2,
Matrix_float input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 6160 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_AVX_parallel()

void apply_crot_kernel_to_matrix_input_AVX_parallel ( Matrix u3_1qbit1,
Matrix u3_1qbit2,
Matrix input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization and parallel processing.

Parameters
u3_1qbit1The U3 gate matrix for the first qubit
u3_1qbit2The U3 gate matrix for the second qubit
inputThe input matrix on which the transformation is applied
target_qbitThe target qubit index
control_qbitThe control qubit index
matrix_sizeThe size of the input matrix (should be a power of 2)

Apply controlled rotation (CROT) kernel to a matrix input using AVX optimization and parallel processing.

Parameters
u3_1qbit1The 2x2 kernel to be applied on target |1>
u3_1qbit2The 2x2 kernel to be applied on target |0>
inputThe input matrix on which the transformation is applied
target_qbitThe target qubit
control_qbitThe control qubit
matrix_sizeThe size of the input

Definition at line 3836 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_AVX_parallel32()

void apply_crot_kernel_to_matrix_input_AVX_parallel32 ( Matrix_float u3_1qbit1,
Matrix_float u3_1qbit2,
Matrix_float input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 6000 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_from_right_AVX()

void apply_crot_kernel_to_matrix_input_from_right_AVX ( Matrix u3_1qbit1,
Matrix u3_qbit2,
Matrix input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 4089 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_from_right_AVX32()

void apply_crot_kernel_to_matrix_input_from_right_AVX32 ( Matrix_float u3_1qbit1,
Matrix_float u3_qbit2,
Matrix_float input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 6203 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_from_right_AVX_parallel()

void apply_crot_kernel_to_matrix_input_from_right_AVX_parallel ( Matrix u3_1qbit1,
Matrix u3_1qbit2,
Matrix input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 4217 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_crot_kernel_to_matrix_input_from_right_AVX_parallel32()

void apply_crot_kernel_to_matrix_input_from_right_AVX_parallel32 ( Matrix_float u3_1qbit1,
Matrix_float u3_1qbit2,
Matrix_float input,
const int target_qbit,
const int control_qbit,
const int matrix_size 
)

Definition at line 6060 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ apply_large_kernel_from_right_AVX()

void apply_large_kernel_from_right_AVX ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5568 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_from_right_AVX32()

void apply_large_kernel_from_right_AVX32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5610 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_from_right_AVX_OpenMP()

void apply_large_kernel_from_right_AVX_OpenMP ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5582 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:

◆ apply_large_kernel_from_right_AVX_OpenMP32()

void apply_large_kernel_from_right_AVX_OpenMP32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5624 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:

◆ apply_large_kernel_from_right_AVX_TBB()

void apply_large_kernel_from_right_AVX_TBB ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5596 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_from_right_AVX_TBB32()

void apply_large_kernel_from_right_AVX_TBB32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 5638 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX()

void apply_large_kernel_to_input_AVX ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Apply multi-qubit gate kernel to an input matrix using AVX optimization.

Parameters
unitaryThe 2^Nx2^N unitary matrix representing the gate operation
inputThe input matrix on which the transformation is applied
involved_qbitsThe qubits involved in the gate operation
matrix_sizeThe size of the input matrix (should be a power of 2)

Definition at line 90 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX32()

void apply_large_kernel_to_input_AVX32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 4345 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX_OpenMP()

void apply_large_kernel_to_input_AVX_OpenMP ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Apply multi-qubit gate kernel to an input matrix using AVX optimization and OpenMP parallelization.

Parameters
unitaryThe 2^Nx2^N unitary matrix representing the gate operation
inputThe input matrix on which the transformation is applied
involved_qbitsThe qubits involved in the gate operation
matrix_sizeThe size of the input matrix (should be a power of 2)

Definition at line 145 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX_OpenMP32()

void apply_large_kernel_to_input_AVX_OpenMP32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 4389 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX_TBB()

void apply_large_kernel_to_input_AVX_TBB ( Matrix unitary,
Matrix input,
std::vector< int involved_qbits,
const int matrix_size 
)

Apply multi-qubit gate kernel to an input matrix using AVX optimization and TBB parallelization.

Parameters
unitaryThe 2^Nx2^N unitary matrix representing the gate operation
inputThe input matrix on which the transformation is applied
involved_qbitsThe qubits involved in the gate operation
matrix_sizeThe size of the input matrix (should be a power of 2)

Definition at line 373 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_large_kernel_to_input_AVX_TBB32()

void apply_large_kernel_to_input_AVX_TBB32 ( Matrix_float unitary,
Matrix_float input,
std::vector< int involved_qbits,
const int matrix_size 
)

Definition at line 4433 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ complex_mult_AVX()

__m256d complex_mult_AVX ( __m256d  input_vec,
__m256d  unitary_row_vec,
__m256d  neg 
)
inline

Perform complex multiplication using AVX intrinsics.

Parameters
input_vecAVX vector containing the input complex number (real and imaginary parts)
unitary_row_vecAVX vector containing the unitary matrix row element (real and imaginary parts)
negAVX vector containing sign pattern for complex multiplication
Returns
AVX vector containing the result of complex multiplication

Definition at line 62 of file apply_large_kernel_to_input_AVX.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_mv_xy_vectors()

__m256d* construct_mv_xy_vectors ( const Matrix gate_kernel_unitary,
const int matrix_size 
)
inline

Precompute AVX vectors for the unitary matrix to optimize complex multiplication.

Parameters
gate_kernel_unitaryThe unitary matrix of the gate operation
matrix_sizeThe size of the unitary matrix
Returns
Pointer to the precomputed AVX vectors

Precompute AVX vectors for the unitary matrix to optimize complex multiplication.

Parameters
inputThe input matrix to be updated
new_block_realThe real parts of the new block
new_block_imagThe imaginary parts of the new block
indicesThe indices where the new block should be written Precompute AVX vectors for the unitary matrix to optimize complex multiplication
gate_kernel_unitaryThe unitary matrix of the gate operation
matrix_sizeThe size of the unitary matrix
Returns
Pointer to the precomputed AVX vectors

Definition at line 481 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ get_AVX_vector()

__m256d get_AVX_vector ( double *  element_outer,
double *  element_inner 
)
inline

Helper function to load and prepare AVX vectors with outer and inner elements for complex multiplication.

Parameters
element_outerPointer to the outer element (real and imaginary parts)
element_innerPointer to the inner element (real and imaginary parts)
Returns
Prepared AVX vector for complex multiplication

Definition at line 43 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ get_block_indices()

void get_block_indices ( int  N,
const std::vector< int > &  tq,
const std::vector< int > &  non_targets,
int  iter_idx,
std::vector< int > &  indices 
)
inline

Compute the indices for a given block in the quantum state.

Parameters
NThe number of qubits
tqThe target qubits involved in the gate operation
non_targetsThe qubits not involved in the gate operation
iter_idxThe current iteration index
indicesThe computed indices for the current block (output parameter)

◆ get_block_indices_fast()

void get_block_indices_fast ( int  iter_idx,
const std::vector< int > &  target_qubits,
const std::vector< int > &  non_targets,
const std::vector< int > &  block_pattern,
std::vector< int > &  indices 
)
inline

Efficiently compute the indices for a given block using precomputed patterns.

Parameters
iter_idxThe current iteration index
target_qubitsThe qubits involved in the gate operation
non_targetsThe qubits not involved in the gate operation
block_patternThe precomputed index mapping
indicesThe computed indices for the current block (output parameter)
iter_idxThe current iteration index
target_qubitsThe qubits involved in the gate operation
non_targetsThe qubits not involved in the gate operation
block_patternThe precomputed index mapping
indicesThe computed indices for the current block

Definition at line 451 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function:

◆ precompute_index_mapping()

void precompute_index_mapping ( const std::vector< int > &  target_qubits,
const std::vector< int > &  non_targets,
std::vector< int > &  block_pattern 
)

Precompute the index mapping for target and non-target qubits.

Parameters
target_qubitsThe qubits involved in the gate operation
non_targetsThe qubits not involved in the gate operation
block_patternThe precomputed index mapping (output parameter)

Definition at line 426 of file apply_large_kernel_to_input_AVX.cpp.

Here is the caller graph for this function: