Qrack
1.7
General classical-emulating-quantum development framework
|
OpenCL enhanced QEngineCPU implementation. More...
#include <qengine_opencl.hpp>
Public Member Functions | |
QEngineOCL (bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, int devID=-1, bool partialInit=false, complex phaseFac=complex(-999.0,-999.0)) | |
Initialize a Qrack::QEngineOCL object. More... | |
QEngineOCL (QEngineOCLPtr toCopy) | |
~QEngineOCL () | |
virtual void | SetQubitCount (bitLenInt qb) |
virtual void | EnableNormalize (bool doN) |
virtual real1 | GetNorm (bool update=true) |
virtual void | SetNorm (real1 n) |
virtual void | LockSync (cl_int flags=(CL_MAP_READ|CL_MAP_WRITE)) |
virtual void | UnlockSync () |
virtual void | Sync () |
virtual complex * | GetStateVector () |
virtual cl::Context & | GetCLContext () |
virtual int | GetCLContextID () |
virtual cl::CommandQueue & | GetCLQueue () |
virtual BufferPtr | GetStateBuffer () |
virtual void | SetPermutation (bitCapInt perm) |
Set to a specific permutation. More... | |
virtual void | CopyState (QInterfacePtr orig) |
Direct copy of raw state vector to produce a clone. More... | |
virtual real1 | ProbAll (bitCapInt fullRegister) |
Direct measure of full register probability to be in permutation state. More... | |
virtual void | X (bitLenInt start, bitLenInt length) |
Bitwise Pauli X (or logical "NOT") operator. More... | |
virtual void | Swap (bitLenInt start1, bitLenInt start2, bitLenInt length) |
Bitwise swap. More... | |
virtual bitLenInt | Cohere (QEngineOCLPtr toCopy) |
virtual bitLenInt | Cohere (QInterfacePtr toCopy) |
Combine another QInterface with this one, after the last bit index of this one. More... | |
virtual void | Decohere (bitLenInt start, bitLenInt length, QInterfacePtr dest) |
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.". More... | |
virtual void | Dispose (bitLenInt start, bitLenInt length) |
Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away. More... | |
virtual void | ROL (bitLenInt shift, bitLenInt start, bitLenInt length) |
"Circular shift left" - shift bits left, and carry last bits. More... | |
virtual void | ROR (bitLenInt shift, bitLenInt start, bitLenInt length) |
"Circular shift right" - shift bits right, and carry first bits. More... | |
virtual void | INC (bitCapInt toAdd, bitLenInt start, bitLenInt length) |
Increment integer (without sign, with carry) More... | |
virtual void | DEC (bitCapInt toSub, bitLenInt start, bitLenInt length) |
Subtract integer (without sign, with carry) More... | |
virtual void | INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Increment integer (without sign, with carry) More... | |
virtual void | DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract integer (without sign, with carry) More... | |
virtual void | INCS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Increment integer (without sign, with carry) More... | |
virtual void | DECS (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract integer (without sign, with carry) More... | |
virtual void | INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex) |
Increment integer (with sign, with carry) More... | |
virtual void | DECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex) |
Subtract integer (with sign, with carry) More... | |
virtual void | INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Increment integer (with sign, with carry) More... | |
virtual void | DECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract integer (with sign, with carry) More... | |
virtual void | INCBCD (bitCapInt toAdd, bitLenInt start, bitLenInt length) |
Increment integer (BCD) More... | |
virtual void | DECBCD (bitCapInt toAdd, bitLenInt start, bitLenInt length) |
Subtract integer (BCD) More... | |
virtual void | INCBCDC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Increment integer (BCD, with carry) More... | |
virtual void | DECBCDC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract integer (BCD, with carry) More... | |
virtual void | MUL (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, bool clearCary=false) |
Multiply by integer. More... | |
virtual void | DIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length) |
Divide by integer. More... | |
virtual void | CMUL (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length, bool clearCarry=false) |
Controlled multiplication by integer. More... | |
virtual void | CDIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length) |
Controlled division by integer. More... | |
virtual bitCapInt | IndexedLDA (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, unsigned char *values, bool isParallel) |
Set 8 bit register bits based on read from classical memory. More... | |
virtual bitCapInt | IndexedLDA (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, unsigned char *values) |
Set 8 bit register bits by a superposed index-offset-based read from classical memory. More... | |
virtual bitCapInt | IndexedADC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values, bool isParallel) |
Add based on an indexed load from classical memory. More... | |
virtual bitCapInt | IndexedADC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values) |
Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory. More... | |
virtual bitCapInt | IndexedSBC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values, bool isParallel) |
Subtract based on an indexed load from classical memory. More... | |
virtual bitCapInt | IndexedSBC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values) |
Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory. More... | |
virtual real1 | Prob (bitLenInt qubit) |
PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state. More... | |
virtual void | PhaseFlip () |
Phase flip always - equivalent to Z X Z X on any bit in the QInterface. More... | |
virtual void | ZeroPhaseFlip (bitLenInt start, bitLenInt length) |
For chips with a zero flag, flip the phase of the state where the register equals zero. More... | |
virtual void | CPhaseFlipIfLess (bitCapInt greaterPerm, bitLenInt start, bitLenInt length, bitLenInt flagIndex) |
The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation. More... | |
virtual int | GetDeviceID () |
virtual void | SetDevice (const int &dID, const bool &forceReInit=false) |
virtual void | SetQuantumState (complex *inputState) |
Set arbitrary pure quantum state, in unsigned int permutation basis. More... | |
virtual void | NormalizeState (real1 nrm=-999.0) |
virtual void | UpdateRunningNorm () |
Public Member Functions inherited from Qrack::QInterface | |
QInterface (bitLenInt n, std::shared_ptr< std::default_random_engine > rgp=nullptr, bool doNorm=true) | |
virtual | ~QInterface () |
Destructor of QInterface. More... | |
int | GetQubitCount () |
Get the count of bits in this register. More... | |
int | GetMaxQPower () |
Get the maximum number of basis states, namely for qubits. More... | |
virtual std::map< QInterfacePtr, bitLenInt > | Cohere (std::vector< QInterfacePtr > toCopy) |
virtual void | ApplySingleBit (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex) |
Apply an arbitrary single bit unitary transformation. More... | |
virtual void | CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Doubly-controlled NOT gate. More... | |
virtual void | AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Anti doubly-controlled NOT gate. More... | |
virtual void | CNOT (bitLenInt control, bitLenInt target) |
Controlled NOT gate. More... | |
virtual void | AntiCNOT (bitLenInt control, bitLenInt target) |
Anti controlled NOT gate. More... | |
virtual void | H (bitLenInt qubitIndex) |
Hadamard gate. More... | |
virtual bool | M (bitLenInt qubitIndex) |
Measurement gate. More... | |
virtual void | X (bitLenInt qubitIndex) |
X gate. More... | |
virtual void | Y (bitLenInt qubitIndex) |
Y gate. More... | |
virtual void | Z (bitLenInt qubitIndex) |
Z gate. More... | |
virtual void | CY (bitLenInt control, bitLenInt target) |
Controlled Y gate. More... | |
virtual void | CZ (bitLenInt control, bitLenInt target) |
Controlled Z gate. More... | |
virtual void | AND (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "AND" gate. More... | |
virtual void | OR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "OR" gate. More... | |
virtual void | XOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "XOR" gate. More... | |
virtual void | CLAND (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "AND" gate. More... | |
virtual void | CLOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "OR" gate. More... | |
virtual void | CLXOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "XOR" gate. More... | |
virtual void | RT (real1 radians, bitLenInt qubitIndex) |
Phase shift gate. More... | |
virtual void | RTDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction phase shift gate. More... | |
virtual void | RX (real1 radians, bitLenInt qubitIndex) |
X axis rotation gate. More... | |
virtual void | RXDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction X axis rotation gate. More... | |
virtual void | Exp (real1 radians, bitLenInt qubitIndex) |
(Identity) Exponentiation gate More... | |
virtual void | ExpDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction (identity) exponentiation gate. More... | |
virtual void | ExpX (real1 radians, bitLenInt qubitIndex) |
Pauli X exponentiation gate. More... | |
virtual void | ExpXDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli X exponentiation gate. More... | |
virtual void | ExpY (real1 radians, bitLenInt qubitIndex) |
Pauli Y exponentiation gate. More... | |
virtual void | ExpYDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli Y exponentiation gate. More... | |
virtual void | ExpZ (real1 radians, bitLenInt qubitIndex) |
Pauli Z exponentiation gate. More... | |
virtual void | ExpZDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli Z exponentiation gate. More... | |
virtual void | CRX (real1 radians, bitLenInt control, bitLenInt target) |
Controlled X axis rotation gate. More... | |
virtual void | CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction X axis rotation gate. More... | |
virtual void | RY (real1 radians, bitLenInt qubitIndex) |
Y axis rotation gate. More... | |
virtual void | RYDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Y axis rotation gate. More... | |
virtual void | CRY (real1 radians, bitLenInt control, bitLenInt target) |
Controlled Y axis rotation gate. More... | |
virtual void | CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction y axis rotation gate. More... | |
virtual void | RZ (real1 radians, bitLenInt qubitIndex) |
Z axis rotation gate. More... | |
virtual void | RZDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Z axis rotation gate. More... | |
virtual void | CRZ (real1 radians, bitLenInt control, bitLenInt target) |
Controlled Z axis rotation gate. More... | |
virtual void | CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction Z axis rotation gate. More... | |
virtual void | CRT (real1 radians, bitLenInt control, bitLenInt target) |
Controlled "phase shift gate". More... | |
virtual void | CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction "phase shift gate". More... | |
virtual void | H (bitLenInt start, bitLenInt length) |
Bitwise Hadamard. More... | |
virtual void | Y (bitLenInt start, bitLenInt length) |
Bitwise Pauli Y operator. More... | |
virtual void | Z (bitLenInt start, bitLenInt length) |
Bitwise Pauli Z operator. More... | |
virtual void | CNOT (bitLenInt inputBits, bitLenInt targetBits, bitLenInt length) |
Bitwise controlled-not. More... | |
virtual void | AntiCNOT (bitLenInt inputBits, bitLenInt targetBits, bitLenInt length) |
Bitwise "anti-"controlled-not. More... | |
virtual void | CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length) |
Bitwise doubly controlled-not. More... | |
virtual void | AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length) |
Bitwise doubly "anti-"controlled-not. More... | |
virtual void | AND (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length) |
Bitwise "AND". More... | |
virtual void | CLAND (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length) |
Classical bitwise "AND". More... | |
virtual void | OR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length) |
Bitwise "OR". More... | |
virtual void | CLOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length) |
Classical bitwise "OR". More... | |
virtual void | XOR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length) |
Bitwise "XOR". More... | |
virtual void | CLXOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length) |
Classical bitwise "XOR". More... | |
virtual void | RT (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise phase shift gate. More... | |
virtual void | RTDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise dyadic fraction phase shift gate. More... | |
virtual void | RX (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise X axis rotation gate. More... | |
virtual void | RXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise dyadic fraction X axis rotation gate. More... | |
virtual void | CRX (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled X axis rotation gate. More... | |
virtual void | CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled dyadic fraction X axis rotation gate. More... | |
virtual void | RY (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise Y axis rotation gate. More... | |
virtual void | RYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise dyadic fraction Y axis rotation gate. More... | |
virtual void | CRY (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled Y axis rotation gate. More... | |
virtual void | CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled dyadic fraction y axis rotation gate. More... | |
virtual void | RZ (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise Z axis rotation gate. More... | |
virtual void | RZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise dyadic fraction Z axis rotation gate. More... | |
virtual void | CRZ (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled Z axis rotation gate. More... | |
virtual void | CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled dyadic fraction Z axis rotation gate. More... | |
virtual void | CRT (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled "phase shift gate". More... | |
virtual void | CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled dyadic fraction "phase shift gate". More... | |
virtual void | Exp (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise (identity) exponentiation gate. More... | |
virtual void | ExpDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise Dyadic fraction (identity) exponentiation gate. More... | |
virtual void | ExpX (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise Pauli X exponentiation gate. More... | |
virtual void | ExpXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise Dyadic fraction Pauli X exponentiation gate. More... | |
virtual void | ExpY (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise Pauli Y exponentiation gate. More... | |
virtual void | ExpYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise Dyadic fraction Pauli Y exponentiation gate. More... | |
virtual void | ExpZ (real1 radians, bitLenInt start, bitLenInt length) |
Bitwise Pauli Z exponentiation gate. More... | |
virtual void | ExpZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length) |
Bitwise Dyadic fraction Pauli Z exponentiation gate. More... | |
virtual void | CY (bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled Y gate. More... | |
virtual void | CZ (bitLenInt control, bitLenInt target, bitLenInt length) |
Bitwise controlled Z gate. More... | |
virtual void | ASL (bitLenInt shift, bitLenInt start, bitLenInt length) |
Arithmetic shift left, with last 2 bits as sign and carry. More... | |
virtual void | ASR (bitLenInt shift, bitLenInt start, bitLenInt length) |
Arithmetic shift right, with last 2 bits as sign and carry. More... | |
virtual void | LSL (bitLenInt shift, bitLenInt start, bitLenInt length) |
Logical shift left, filling the extra bits with |0> More... | |
virtual void | LSR (bitLenInt shift, bitLenInt start, bitLenInt length) |
Logical shift right, filling the extra bits with |0> More... | |
virtual void | QFT (bitLenInt start, bitLenInt length) |
Quantum Fourier Transform - Apply the quantum Fourier transform to the register. More... | |
virtual void | SetReg (bitLenInt start, bitLenInt length, bitCapInt value) |
Set register bits to given permutation. More... | |
virtual bitCapInt | MReg (bitLenInt start, bitLenInt length) |
Measure permutation state of a register. More... | |
virtual void | Swap (bitLenInt qubitIndex1, bitLenInt qubitIndex2) |
Swap values of two bits in register. More... | |
virtual void | Reverse (bitLenInt first, bitLenInt last) |
Reverse all of the bits in a sequence. More... | |
virtual void | SetBit (bitLenInt qubitIndex1, bool value) |
Set individual bit to pure |0> (false) or |1> (true) state. More... | |
virtual bool | ForceM (bitLenInt qubitIndex, bool result, bool doForce=true, real1 nrmlzr=1.0) |
Act as though a measurement was applied, except force the result of the measurement. More... | |
Protected Member Functions | |
virtual void | ApplyM (bitCapInt qPower, bool result, complex nrm) |
void | InitOCL (int devID) |
void | ResetStateVec (complex *nStateVec, BufferPtr nStateBuffer) |
virtual complex * | AllocStateVec (bitCapInt elemCount) |
size_t | FixWorkItemCount (size_t maxI, size_t wic) |
size_t | FixGroupSize (size_t wic, size_t gs) |
void | DecohereDispose (bitLenInt start, bitLenInt length, QEngineOCLPtr dest) |
void | DispatchCall (OCLAPI api_call, bitCapInt(&bciArgs)[BCI_ARG_LEN], unsigned char *values=NULL, bitCapInt valuesLength=0, bool isParallel=false) |
void | Apply2x2 (bitCapInt offset1, bitCapInt offset2, const complex *mtrx, const bitLenInt bitCount, const bitCapInt *qPowersSorted, bool doCalcNorm) |
void | ROx (OCLAPI api_call, bitLenInt shift, bitLenInt start, bitLenInt length) |
void | INT (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length) |
Add or Subtract integer (without sign or carry) More... | |
void | INTC (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex) |
Add or Subtract integer (without sign, with carry) More... | |
void | INTS (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt overflowIndex) |
Add or Subtract integer (with overflow, without carry) More... | |
void | INTSC (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex) |
Add or Subtract integer (with sign, with carry) More... | |
void | INTSC (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt overflowIndex, const bitLenInt carryIndex) |
Add or Subtract integer (with sign, with carry) More... | |
void | INTBCD (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length) |
Add or Subtract integer (BCD) More... | |
void | INTBCDC (OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex) |
Add or Subtract integer (BCD, with carry) More... | |
bitCapInt | OpIndexed (OCLAPI api_call, bitCapInt carryIn, bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values, bool isParallel) |
Add or Subtract based on an indexed load from classical memory. More... | |
Protected Member Functions inherited from Qrack::QInterface | |
virtual real1 | Rand () |
Generate a random real1 from 0 to 1. More... | |
virtual void | SetRandomSeed (uint32_t seed) |
virtual void | ApplyControlled2x2 (bitLenInt control, bitLenInt target, const complex *mtrx, bool doCalcNorm) |
virtual void | ApplyAntiControlled2x2 (bitLenInt control, bitLenInt target, const complex *mtrx, bool doCalcNorm) |
virtual void | ApplyDoublyControlled2x2 (bitLenInt control1, bitLenInt control2, bitLenInt target, const complex *mtrx, bool doCalcNorm) |
virtual void | ApplyDoublyAntiControlled2x2 (bitLenInt control1, bitLenInt control2, bitLenInt target, const complex *mtrx, bool doCalcNorm) |
Protected Attributes | |
complex * | stateVec |
int | deviceID |
DeviceContextPtr | device_context |
cl::CommandQueue | queue |
cl::Context | context |
BufferPtr | stateBuffer |
cl::Buffer | cmplxBuffer |
cl::Buffer | ulongBuffer |
cl::Buffer | nrmBuffer |
real1 * | nrmArray |
size_t | nrmGroupCount |
size_t | nrmGroupSize |
size_t | maxWorkItems |
unsigned int | procElemCount |
Protected Attributes inherited from Qrack::QInterface | |
bitLenInt | qubitCount |
bitCapInt | maxQPower |
real1 | runningNorm |
bool | doNormalize |
uint32_t | randomSeed |
std::shared_ptr< std::default_random_engine > | rand_generator |
std::uniform_real_distribution< real1 > | rand_distribution |
Static Protected Attributes | |
static const int | BCI_ARG_LEN = 10 |
OpenCL enhanced QEngineCPU implementation.
Qrack::QEngineOCL::QEngineOCL | ( | bitLenInt | qBitCount, |
bitCapInt | initState, | ||
std::shared_ptr< std::default_random_engine > | rgp = nullptr , |
||
int | devID = -1 , |
||
bool | partialInit = false , |
||
complex | phaseFac = complex(-999.0, -999.0) |
||
) |
Initialize a Qrack::QEngineOCL object.
Specify the number of qubits and an initial permutation state. Additionally, optionally specify a pointer to a random generator engine object, a device ID from the list of devices in the OCLEngine singleton, and a boolean that is set to "true" to initialize the state vector of the object to zero norm.
"devID" is the index of an OpenCL device in the OCLEngine singleton, to select the device to run this engine on. "partialInit" is usually only set to true when this object is one of several collected in a Qrack::QEngineOCLMulti object, in which case this Qrack::QEngineOCL object might not contain the amplitude of the overall permutation state of the combined object.
Qrack::QEngineOCL::QEngineOCL | ( | QEngineOCLPtr | toCopy | ) |
|
inline |
|
protectedvirtual |
Implements Qrack::QInterface.
Implements Qrack::QInterface.
|
virtual |
Controlled division by integer.
Implements Qrack::QInterface.
|
virtual |
Controlled multiplication by integer.
Implements Qrack::QInterface.
|
virtual |
|
inlinevirtual |
Combine another QInterface with this one, after the last bit index of this one.
"Cohere" combines the quantum description of state of two independent QInterface objects into one object, containing the full permutation basis of the full object. The "inputState" bits are added after the last qubit index of the QInterface to which we "Cohere." Informally, "Cohere" is equivalent to "just setting another group of qubits down next to the first" without interacting them. Schroedinger's equation can form a description of state for two independent subsystems at once or "separable quantum subsystems" without interacting them. Once the description of state of the independent systems is combined, we can interact them, and we can describe their entanglements to each other, in which case they are no longer independent. A full entangled description of quantum state is not possible for two independent quantum subsystems until we "Cohere" them.
"Cohere" multiplies the probabilities of the indepedent permutation states of the two subsystems to find the probabilites of the entire set of combined permutations, by simple combinatorial reasoning. If the probablity of the "left-hand" subsystem being in |00> is 1/4, and the probablity of the "right-hand" subsystem being in |101> is 1/8, than the probability of the combined |00101> permutation state is 1/32, and so on for all permutations of the new combined state.
If the programmer doesn't want to "cheat" quantum mechanically, then the original copy of the state which is duplicated into the larger QInterface should be "thrown away" to satisfy "no clone theorem." This is not semantically enforced in Qrack, because optimization of an emulator might be acheived by "cloning" "under-the-hood" while only exposing a quantum mechanically consistent API or instruction set.
Returns the quantum bit offset that the QInterface was appended at, such that bit 5 in toCopy is equal to offset+5 in this object.
Implements Qrack::QInterface.
|
virtual |
Direct copy of raw state vector to produce a clone.
Implements Qrack::QInterface.
|
virtual |
The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation.
Implements Qrack::QInterface.
Subtract integer (without sign, with carry)
Implements Qrack::QInterface.
Subtract integer (BCD)
Implements Qrack::QInterface.
|
virtual |
Subtract integer (BCD, with carry)
Implements Qrack::QInterface.
|
virtual |
Subtract integer (without sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".
Minimally decohere a set of contigious bits from the full coherent unit. The length of this coherent unit is reduced by the length of bits decohered, and the bits removed are output in the destination QInterface pointer. The destination object must be initialized to the correct number of bits, in 0 permutation state. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."
Like how "Cohere" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Decohere" is like "just moving a few qubits away from the rest." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state.
If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:
If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.
Implements Qrack::QInterface.
|
protected |
|
virtual |
Subtract integer (without sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Subtract integer (with sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Subtract integer (with sign, with carry)
Implements Qrack::QInterface.
|
protected |
Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away.
Minimally decohere a set of contigious bits from the full coherent unit, discarding these bits. The length of this coherent unit is reduced by the length of bits decohered. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."
Like how "Cohere" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Dispose" is like "just moving a few qubits away from the rest, and throwing them in the trash." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state.
If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:
If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.
Implements Qrack::QInterface.
|
virtual |
Divide by integer.
Implements Qrack::QInterface.
|
inlinevirtual |
|
protected |
|
protected |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Increment integer (without sign, with carry)
Implements Qrack::QInterface.
Increment integer (BCD)
Implements Qrack::QInterface.
|
virtual |
Increment integer (BCD, with carry)
Implements Qrack::QInterface.
|
virtual |
Increment integer (without sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Increment integer (without sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Increment integer (with sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Increment integer (with sign, with carry)
Implements Qrack::QInterface.
|
virtual |
Add based on an indexed load from classical memory.
|
inlinevirtual |
Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory.
inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value + values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See IndexedLDA() for context.
FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().
Implements Qrack::QInterface.
|
virtual |
Set 8 bit register bits based on read from classical memory.
|
inlinevirtual |
Set 8 bit register bits by a superposed index-offset-based read from classical memory.
"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits are first cleared, then the separable |input, 00000000> permutation state is mapped to |input, values[input]>, with "values[input]" placed in the "outputStart" register. FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM.
The physical motivation for this addressing mode can be explained as follows: say that we have a superconducting quantum interface device (SQUID) based chip. SQUIDs have already been demonstrated passing coherently superposed electrical currents. In a sufficiently quantum-mechanically isolated qubit chip with a classical cache, with both classical RAM and registers likely cryogenically isolated from the environment, SQUIDs could (hopefully) pass coherently superposed electrical currents into the classical RAM cache to load values into a qubit register. The state loaded would be a superposition of the values of all RAM to which coherently superposed electrical currents were passed.
In qubit system similar to the MOS 6502, say we have qubit-based "accumulator" and "X index" registers, and say that we start with a superposed X index register. In (classical) X addressing mode, the X index register value acts an offset into RAM from a specified starting address. The X addressing mode of a LoaD Accumulator (LDA) instruction, by the physical mechanism described above, should load the accumulator in quantum parallel with the values of every different address of RAM pointed to in superposition by the X index register. The superposed values in the accumulator are entangled with those in the X index register, by way of whatever values the classical RAM pointed to by X held at the time of the load. (If the RAM at index "36" held an unsigned char value of "27," then the value "36" in the X index register becomes entangled with the value "27" in the accumulator, and so on in quantum parallel for all superposed values of the X index register, at once.) If the X index register or accumulator are then measured, the two registers will both always collapse into a random but valid key-value pair of X index offset and value at that classical RAM address.
Note that a "superposed store operation in classical RAM" is not possible by analagous reasoning. Classical RAM would become entangled with both the accumulator and the X register. When the state of the registers was collapsed, we would find that only one "store" operation to a single memory address had actually been carried out, consistent with the address offset in the collapsed X register and the byte value in the collapsed accumulator. It would not be possible by this model to write in quantum parallel to more than one address of classical memory at a time.
Implements Qrack::QInterface.
|
virtual |
Subtract based on an indexed load from classical memory.
|
inlinevirtual |
Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory.
"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value - values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See QInterface::IndexedLDA for context.
FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().
Implements Qrack::QInterface.
|
protected |
|
protected |
Add or Subtract integer (without sign or carry)
|
protected |
Add or Subtract integer (BCD)
|
protected |
Add or Subtract integer (BCD, with carry)
|
protected |
Add or Subtract integer (without sign, with carry)
|
protected |
Add or Subtract integer (with overflow, without carry)
|
protected |
Add or Subtract integer (with sign, with carry)
|
protected |
Add or Subtract integer (with sign, with carry)
|
virtual |
|
virtual |
Multiply by integer.
Implements Qrack::QInterface.
|
virtual |
Implements Qrack::QInterface.
|
protected |
Add or Subtract based on an indexed load from classical memory.
|
virtual |
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Implements Qrack::QInterface.
PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state.
Implements Qrack::QInterface.
Direct measure of full register probability to be in permutation state.
Implements Qrack::QInterface.
"Circular shift left" - shift bits left, and carry last bits.
Reimplemented from Qrack::QInterface.
"Circular shift right" - shift bits right, and carry first bits.
Reimplemented from Qrack::QInterface.
|
protected |
|
virtual |
|
inlinevirtual |
|
virtual |
Set to a specific permutation.
Implements Qrack::QInterface.
|
virtual |
Set arbitrary pure quantum state, in unsigned int permutation basis.
Implements Qrack::QInterface.
|
virtual |
Reimplemented from Qrack::QInterface.
Bitwise swap.
Reimplemented from Qrack::QInterface.
|
virtual |
|
virtual |
|
virtual |
Bitwise Pauli X (or logical "NOT") operator.
Reimplemented from Qrack::QInterface.
For chips with a zero flag, flip the phase of the state where the register equals zero.
Implements Qrack::QInterface.
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |