next up previous contents
Next: Initialising the parallelization from Up: Parallelizing the Quantum Computing Previous: Initialising the QCL to   Contents

Initialising the parallelization from the root node

The QCL stores matrix operations in the "extern.cc" class. One particular operator, called Matrix, takes a quantum register and a complex matrix as it's arguments, and then applies the operation to the matrix. This is used as the base for the parallel matrix routines used in this project. The QCL stores each operation name in an array of structs. It searches through this array to find the location of the code to handle each operation. To add an operation to the QCL, it is sufficient to add an entry to this array pointing to the name of the routine;


\begin{lstlisting}[frame=trbl,caption=Extract from extern.cc]{}
{ &ext_pargenmatrix1,''ParMatrix1'' },
\end{lstlisting}

The name of the function must also be added to the "default.qcl" file to allow the QCL compiler to identify it. This is done by adding the following line at the top of the "extern.cc" class;


\begin{lstlisting}[frame=trbl,caption=Extract from extern.cc]{}
//! extern operator ParMatrix1(complex matrix u,qureg q);
\end{lstlisting}


The QCL searches through the file after compilation and extracts all operators proceeded by //!. There are five parallel routines, however their operation in the "extern.cc" class is alike so only the ParMatrix1 function is detailed here. After checking that the matrix to be applied is unitary, and that the matrix has the same dimension as the number of basevectors of the quantum state, the matrix is converted into a 2-dimensional matrix. This is then passed to the appropriate parallelization function along with the quantum state, the dimension of the matrix, and array which will hold the amplitudes after the operation is complete. This is then applied to the quantum register using the apply function of a class called opParallel, in the QCL's numerical simulation library.


\begin{lstlisting}[frame=trbl,caption=Extract from extern.cc]{}
...
// Create ...
..._qubit, matrix, dim);
\par opParallel().apply(*q, final_qubit);
\end{lstlisting}


next up previous contents
Next: Initialising the parallelization from Up: Parallelizing the Quantum Computing Previous: Initialising the QCL to   Contents
Colm O hEigeartaigh 2003-05-30