48 int deviceCount = -1);
65 std::shared_ptr<std::default_random_engine> rgp =
nullptr);
71 subEngineCount = substateEngines.size();
74 subBufferSize =
sizeof(
complex) * subMaxQPower >> 1;
83 return Cohere(std::dynamic_pointer_cast<QEngineOCLMulti>(toCopy));
85 virtual std::map<QInterfacePtr, bitLenInt>
Cohere(std::vector<QInterfacePtr> toCopy);
89 Decohere(start, length, std::dynamic_pointer_cast<QEngineOCLMulti>(dest));
143 bitLenInt valueLength,
unsigned char* values);
153 virtual void CopyState(QEngineOCLMultiPtr orig);
173 template <
typename F,
typename... Args>
void SingleBitGate(
bool doNormalize, bitLenInt bit, F fn, Args... gfnArgs);
174 template <
typename CF,
typename F,
typename... Args>
175 void ControlledGate(
bool anti, bitLenInt controlBit, bitLenInt targetBit, CF cfn, F fn, Args... gfnArgs);
176 template <
typename CCF,
typename CF,
typename F,
typename... Args>
177 void DoublyControlledGate(
bool anti, bitLenInt controlBit1, bitLenInt controlBit2, bitLenInt targetBit, CCF ccfn,
178 CF cfn, F fn, Args... gfnArgs);
180 template <
typename F,
typename OF>
void RegOp(F fn, OF ofn, bitLenInt length, std::vector<bitLenInt> bits);
185 template <
typename F>
void CombineAndOp(F fn, std::vector<bitLenInt> bits);
186 template <
typename F>
void CombineAndOpSafe(F fn, std::vector<bitLenInt> bits);
190 void MetaX(bitLenInt start, bitLenInt length);
191 void MetaCNOT(
bool anti, std::vector<bitLenInt> controls, bitLenInt target);
192 template <
typename F,
typename... Args>
193 void MetaControlled(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, F fn, Args... gfnArgs);
194 template <
typename F,
typename... Args>
195 void SemiMetaControlled(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, F fn, Args... gfnArgs);
196 template <
typename F,
typename... Args>
197 void ControlledSkip(
bool anti, bitLenInt controlDepth, bitLenInt targetBit, F fn, Args... gfnArgs);
204 bitLenInt
SeparateMetaCNOT(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, bitLenInt length);
209 bitLenInt p = n >> 1;
virtual void RX(real1 radians, bitLenInt qubitIndex)
X axis rotation gate.
Definition: opencl_multi.cpp:717
void ShuffleBuffers(complex *stateVec1, complex *stateVec2)
Definition: opencl_multi.cpp:120
virtual bitLenInt Cohere(QEngineOCLMultiPtr toCopy)
Definition: opencl_multi.cpp:322
void NormalizeState()
Definition: opencl_multi.cpp:1338
virtual real1 ProbAll(bitCapInt fullRegister)
Direct measure of full register probability to be in permutation state.
Definition: opencl_multi.cpp:1166
virtual void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add classical BCD integer (without sign, with carry)
Definition: opencl_multi.cpp:795
virtual void Decohere(bitLenInt start, bitLenInt length, QEngineOCLMultiPtr dest)
Definition: opencl_multi.cpp:345
virtual void SetQuantumState(complex *inputState)
Set an arbitrary pure quantum state.
Definition: opencl_multi.cpp:289
virtual void CopyState(QInterfacePtr orig)
Direct copy of raw state vector to produce a clone.
Definition: qengine_opencl_multi.hpp:152
virtual real1 Prob(bitLenInt qubitIndex)
Direct measure of bit probability to be in |1> state.
Definition: opencl_multi.cpp:1126
Definition: parallel_for.hpp:22
virtual void DECBCDC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract BCD integer (without sign, with carry)
Definition: opencl_multi.cpp:831
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 classi...
Definition: opencl_multi.cpp:1041
void ControlledSkip(bool anti, bitLenInt controlDepth, bitLenInt targetBit, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:650
bitLenInt subEngineCount
Definition: qengine_opencl_multi.hpp:30
virtual void CY(bitLenInt control, bitLenInt target)
Controlled Y gate.
Definition: opencl_multi.cpp:703
virtual void Swap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register.
Definition: opencl_multi.cpp:1054
virtual void X(bitLenInt qubitIndex)
X gate.
Definition: opencl_multi.cpp:690
void MetaX(bitLenInt start, bitLenInt length)
Definition: opencl_multi.cpp:498
virtual void DECBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Subtract BCD integer (without sign)
Definition: opencl_multi.cpp:826
virtual void INCBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add classical BCD integer (without sign)
Definition: opencl_multi.cpp:790
bitCapInt maxQPower
Definition: qinterface.hpp:97
virtual void ExpX(real1 radians, bitLenInt qubitIndex)
Pauli X exponentiation gate.
Definition: opencl_multi.cpp:733
virtual void CRT(real1 radians, bitLenInt control, bitLenInt target)
Controlled "phase shift gate".
Definition: opencl_multi.cpp:757
void CombineAndOp(F fn, std::vector< bitLenInt > bits)
Definition: opencl_multi.cpp:1250
virtual void DECS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Subtract a classical integer from the register, with sign and without carry.
Definition: opencl_multi.cpp:810
virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "XOR".
Definition: opencl_multi.cpp:1001
virtual void RT(real1 radians, bitLenInt qubitIndex)
Phase shift gate.
Definition: opencl_multi.cpp:713
#define real1
Definition: qinterface.hpp:35
virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: opencl_multi.cpp:774
bitLenInt maxDeviceOrder
Definition: qengine_opencl_multi.hpp:31
virtual void DECSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Subtract a classical integer from the register, with sign and with carry.
Definition: opencl_multi.cpp:815
void CombineAndOpSafe(F fn, std::vector< bitLenInt > bits)
Definition: opencl_multi.cpp:1283
void(QEngineOCL::* GFn)(bitLenInt)
Definition: qengine_opencl_multi.hpp:167
virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Anti doubly-controlled NOT gate.
Definition: opencl_multi.cpp:401
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...
Definition: opencl_multi.cpp:1029
void ControlledGate(bool anti, bitLenInt controlBit, bitLenInt targetBit, CF cfn, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:212
void(QEngineOCL::* RGFn)(real1, bitLenInt)
Definition: qengine_opencl_multi.hpp:168
virtual void SetQubitCount(bitLenInt qb)
Definition: qengine_opencl_multi.hpp:67
virtual void Z(bitLenInt qubitIndex)
Z gate.
Definition: opencl_multi.cpp:701
virtual bool M(bitLenInt qubitIndex)
Measurement gate.
Definition: opencl_multi.cpp:431
void MetaControlled(bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:547
virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "OR".
Definition: opencl_multi.cpp:982
std::vector< QEngineOCLPtr > substateEngines
Definition: qengine_opencl_multi.hpp:34
#define complex
Definition: qinterface.hpp:34
virtual void Exp(real1 radians, bitLenInt qubitIndex)
(Identity) Exponentiation gate
Definition: opencl_multi.cpp:729
virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: opencl_multi.cpp:769
void MetaCNOT(bool anti, std::vector< bitLenInt > controls, bitLenInt target)
Definition: opencl_multi.cpp:515
bitLenInt SeparateMetaCNOT(bool anti, std::vector< bitLenInt > controls, bitLenInt target, bitLenInt length)
Definition: opencl_multi.cpp:876
virtual void PhaseFlip()
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Definition: opencl_multi.cpp:847
virtual void Dispose(bitLenInt start, bitLenInt length)
Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away...
Definition: opencl_multi.cpp:359
void SemiMetaControlled(bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:610
virtual void CZ(bitLenInt control, bitLenInt target)
Controlled Z gate.
Definition: opencl_multi.cpp:708
virtual void Y(bitLenInt qubitIndex)
Y gate.
Definition: opencl_multi.cpp:699
virtual void RZ(real1 radians, bitLenInt qubitIndex)
Z axis rotation gate.
Definition: opencl_multi.cpp:725
virtual void CNOT(bitLenInt control, bitLenInt target)
Controlled NOT gate.
Definition: opencl_multi.cpp:388
virtual void ApplySingleBit(const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
Apply an arbitrary single bit unitary transformation.
Definition: opencl_multi.cpp:685
virtual void CRY(real1 radians, bitLenInt control, bitLenInt target)
Controlled Y axis rotation gate.
Definition: opencl_multi.cpp:749
OpenCL enhanced QEngineCPU implementation.
Definition: qengine_opencl.hpp:32
virtual void CRX(real1 radians, bitLenInt control, bitLenInt target)
Controlled X axis rotation gate.
Definition: opencl_multi.cpp:745
std::vector< int > deviceIDs
Definition: qengine_opencl_multi.hpp:36
virtual void Decohere(bitLenInt start, bitLenInt length, QInterfacePtr dest)
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".
Definition: qengine_opencl_multi.hpp:87
#define bitCapInt
Definition: qinterface.hpp:22
virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "AND".
Definition: opencl_multi.cpp:963
#define bitLenInt
Definition: qinterface.hpp:21
size_t subBufferSize
Definition: qengine_opencl_multi.hpp:32
OpenCL enhanced QEngineCPU implementation.
Definition: qengine_opencl_multi.hpp:25
QEngineOCLMulti(bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, int deviceCount=-1)
Initialize a Qrack::QEngineOCLMulti object.
Definition: opencl_multi.cpp:36
void Init(bitLenInt qBitCount, bitCapInt initState)
Definition: opencl_multi.cpp:64
void CombineEngines(bitLenInt bit)
Definition: opencl_multi.cpp:1176
virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: opencl_multi.cpp:764
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract classical integer (without sign)
Definition: opencl_multi.cpp:800
"Qrack::OCLEngine" manages the single OpenCL context.
Definition: oclengine.hpp:110
virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-controlled NOT gate.
Definition: opencl_multi.cpp:373
std::vector< std::vector< cl::Buffer > > substateBuffers
Definition: qengine_opencl_multi.hpp:35
virtual void CRZ(real1 radians, bitLenInt control, bitLenInt target)
Controlled Z axis rotation gate.
Definition: opencl_multi.cpp:753
real1 runningNorm
Definition: qengine_opencl_multi.hpp:27
virtual void SetPermutation(bitCapInt perm)
Set to a specific permutation.
Definition: opencl_multi.cpp:296
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:94
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.
Definition: opencl_multi.cpp:1019
virtual bitLenInt Cohere(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qengine_opencl_multi.hpp:81
std::shared_ptr< QEngineOCLMulti > QEngineOCLMultiPtr
Definition: qengine_opencl_multi.hpp:21
bitLenInt qubitCount
Definition: qinterface.hpp:96
void(QEngineOCL::* CGFn)(bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:169
virtual void ExpY(real1 radians, bitLenInt qubitIndex)
Pauli Y exponentiation gate.
Definition: opencl_multi.cpp:737
virtual void ZeroPhaseFlip(bitLenInt start, bitLenInt length)
Reverse the phase of the state where the register equals zero.
Definition: opencl_multi.cpp:837
void DoublyControlledGate(bool anti, bitLenInt controlBit1, bitLenInt controlBit2, bitLenInt targetBit, CCF ccfn, CF cfn, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:242
virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract classical integer (without sign, with carry)
Definition: opencl_multi.cpp:805
OCLEngine * clObj
Definition: qengine_opencl_multi.hpp:33
virtual void RY(real1 radians, bitLenInt qubitIndex)
Y axis rotation gate.
Definition: opencl_multi.cpp:721
virtual void H(bitLenInt qubitIndex)
Hadamard gate.
Definition: opencl_multi.cpp:429
virtual void INCSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Add a classical integer to the register, with sign and with carry.
Definition: opencl_multi.cpp:779
bitCapInt subMaxQPower
Definition: qengine_opencl_multi.hpp:29
virtual void ExpZ(real1 radians, bitLenInt qubitIndex)
Pauli Z exponentiation gate.
Definition: opencl_multi.cpp:741
void SingleBitGate(bool doNormalize, bitLenInt bit, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:128
void(QEngineOCL::* ASBFn)(const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
Definition: qengine_opencl_multi.hpp:172
void SeparateEngines()
Definition: opencl_multi.cpp:1212
virtual void AntiCNOT(bitLenInt control, bitLenInt target)
Anti controlled NOT gate.
Definition: opencl_multi.cpp:416
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:41
bitCapInt log2(bitCapInt n)
Definition: qengine_opencl_multi.hpp:206
void RegOp(F fn, OF ofn, bitLenInt length, std::vector< bitLenInt > bits)
Definition: opencl_multi.cpp:1295
Definition: complex16simd.hpp:21
bitLenInt subQubitCount
Definition: qengine_opencl_multi.hpp:28
void(QEngineOCL::* CRGFn)(real1, bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:170
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.
Definition: opencl_multi.cpp:842
void(QEngineOCL::* CCGFn)(bitLenInt, bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:171