16 #error OpenCL has not been enabled 67 int devID = -1,
bool partialInit =
false,
complex phaseFac =
complex(-999.0, -999.0));
88 virtual void LockSync(cl_int flags = (CL_MAP_READ | CL_MAP_WRITE));
134 bitLenInt length,
bool clearCarry =
false);
139 bitLenInt valueLength,
unsigned char* values,
bool isParallel);
143 return IndexedLDA(indexStart, indexLength, valueStart, valueLength, values,
false);
150 return IndexedADC(indexStart, indexLength, valueStart, valueLength, carryIndex, values,
false);
157 return IndexedSBC(indexStart, indexLength, valueStart, valueLength, carryIndex, values,
false);
167 virtual void SetDevice(
const int& dID,
const bool& forceReInit =
false);
186 bitCapInt valuesLength = 0,
bool isParallel =
false);
189 const bitCapInt* qPowersSorted,
bool doCalcNorm);
virtual void DECSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Subtract integer (with sign, with carry)
Definition: opencl.cpp:767
cl::Buffer ulongBuffer
Definition: qengine_opencl.hpp:43
void INTBCDC(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex)
Add or Subtract integer (BCD, with carry)
Definition: opencl.cpp:848
virtual void Sync()
Definition: opencl.cpp:72
cl::Buffer nrmBuffer
Definition: qengine_opencl.hpp:44
virtual void UpdateRunningNorm()
Definition: opencl.cpp:1181
void INTC(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex)
Add or Subtract integer (without sign, with carry)
Definition: opencl.cpp:670
virtual void DECBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Subtract integer (BCD)
Definition: opencl.cpp:842
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.
Definition: opencl.cpp:1009
virtual int GetCLContextID()
Definition: qengine_opencl.hpp:93
OCLAPI
Definition: oclengine.hpp:38
void INT(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length)
Add or Subtract integer (without sign or carry)
Definition: opencl.cpp:646
size_t nrmGroupSize
Definition: qengine_opencl.hpp:47
virtual void DECBCDC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract integer (BCD, with carry)
Definition: opencl.cpp:878
real1 * nrmArray
Definition: qengine_opencl.hpp:45
virtual void X(bitLenInt start, bitLenInt length)
Bitwise Pauli X (or logical "NOT") operator.
Definition: opencl.cpp:599
virtual void CDIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length)
Controlled division by integer.
Definition: opencl.cpp:956
virtual void ROL(bitLenInt shift, bitLenInt start, bitLenInt length)
"Circular shift left" - shift bits left, and carry last bits.
Definition: opencl.cpp:640
virtual void X(bitLenInt qubitIndex)
X gate.
Definition: gates.cpp:147
void Apply2x2(bitCapInt offset1, bitCapInt offset2, const complex *mtrx, const bitLenInt bitCount, const bitCapInt *qPowersSorted, bool doCalcNorm)
Definition: opencl.cpp:274
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: qengine_opencl.hpp:140
virtual void SetQuantumState(complex *inputState)
Set arbitrary pure quantum state, in unsigned int permutation basis.
Definition: opencl.cpp:1137
static const int BCI_ARG_LEN
Definition: qengine_opencl.hpp:175
virtual void EnableNormalize(bool doN)
Definition: qengine_opencl.hpp:77
virtual complex * AllocStateVec(bitCapInt elemCount)
Definition: opencl.cpp:1208
real1 runningNorm
Definition: qinterface.hpp:103
virtual void PhaseFlip()
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Definition: opencl.cpp:1071
std::shared_ptr< OCLDeviceContext > DeviceContextPtr
Definition: oclengine.hpp:34
virtual void SetQubitCount(bitLenInt qb)
Definition: opencl.cpp:203
virtual real1 Prob(bitLenInt qubit)
PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state.
Definition: opencl.cpp:554
size_t nrmGroupCount
Definition: qengine_opencl.hpp:46
unsigned int procElemCount
Definition: qengine_opencl.hpp:49
#define real1
Definition: qinterface.hpp:36
virtual void LockSync(cl_int flags=(CL_MAP_READ|CL_MAP_WRITE))
Definition: opencl.cpp:61
virtual void Swap(bitLenInt start1, bitLenInt start2, bitLenInt length)
Bitwise swap.
Definition: opencl.cpp:614
void DispatchCall(OCLAPI api_call, bitCapInt(&bciArgs)[BCI_ARG_LEN], unsigned char *values=NULL, bitCapInt valuesLength=0, bool isParallel=false)
Definition: opencl.cpp:231
BufferPtr stateBuffer
Definition: qengine_opencl.hpp:41
virtual void Decohere(bitLenInt start, bitLenInt length, QInterfacePtr dest)
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".
Definition: opencl.cpp:546
void INTS(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt overflowIndex)
Add or Subtract integer (with overflow, without carry)
Definition: opencl.cpp:710
void InitOCL(int devID)
Definition: opencl.cpp:209
~QEngineOCL()
Definition: qengine_opencl.hpp:69
void INTSC(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length, const bitLenInt carryIndex)
Add or Subtract integer (with sign, with carry)
Definition: opencl.cpp:781
virtual void DIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Divide by integer.
Definition: opencl.cpp:911
cl::CommandQueue queue
Definition: qengine_opencl.hpp:37
void ResetStateVec(complex *nStateVec, BufferPtr nStateBuffer)
Definition: opencl.cpp:211
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: qengine_opencl.hpp:154
virtual real1 GetNorm(bool update=true)
Definition: qengine_opencl.hpp:78
virtual BufferPtr GetStateBuffer()
Definition: qengine_opencl.hpp:95
virtual void SetPermutation(bitCapInt perm)
Set to a specific permutation.
Definition: opencl.cpp:219
void ROx(OCLAPI api_call, bitLenInt shift, bitLenInt start, bitLenInt length)
Definition: opencl.cpp:629
#define complex
Definition: qinterface.hpp:35
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract integer (without sign, with carry)
Definition: opencl.cpp:664
virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Increment integer (without sign, with carry)
Definition: opencl.cpp:726
virtual void MUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, bool clearCary=false)
Multiply by integer.
Definition: opencl.cpp:891
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.cpp:1112
virtual void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Increment integer (BCD, with carry)
Definition: opencl.cpp:866
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.
Definition: opencl.cpp:1056
OpenCL enhanced QEngineCPU implementation.
Definition: qengine_opencl.hpp:32
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.
Definition: opencl.cpp:1064
size_t FixGroupSize(size_t wic, size_t gs)
Definition: opencl.cpp:86
virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract integer (without sign, with carry)
Definition: opencl.cpp:697
virtual real1 ProbAll(bitCapInt fullRegister)
Direct measure of full register probability to be in permutation state.
Definition: opencl.cpp:122
#define bitCapInt
Definition: qinterface.hpp:22
void INTBCD(OCLAPI api_call, bitCapInt toMod, const bitLenInt inOutStart, const bitLenInt length)
Add or Subtract integer (BCD)
Definition: opencl.cpp:821
void DecohereDispose(bitLenInt start, bitLenInt length, QEngineOCLPtr dest)
Definition: opencl.cpp:406
DeviceContextPtr device_context
Definition: qengine_opencl.hpp:36
virtual void CopyState(QInterfacePtr orig)
Direct copy of raw state vector to produce a clone.
Definition: opencl.cpp:102
#define bitLenInt
Definition: qinterface.hpp:21
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.
Definition: opencl.cpp:22
virtual void DECS(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract integer (without sign, with carry)
Definition: opencl.cpp:732
"Qrack::OCLEngine" manages the single OpenCL context.
Definition: oclengine.hpp:130
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.
Definition: opencl.cpp:977
virtual complex * GetStateVector()
Definition: qengine_opencl.hpp:91
int deviceID
Definition: qengine_opencl.hpp:35
virtual void INCBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Increment integer (BCD)
Definition: opencl.cpp:836
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.cpp:551
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:99
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: qengine_opencl.hpp:147
bool doNormalize
Definition: qinterface.hpp:104
virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Increment integer (without sign, with carry)
Definition: opencl.cpp:685
size_t maxWorkItems
Definition: qengine_opencl.hpp:48
virtual void SetNorm(real1 n)
Definition: qengine_opencl.hpp:85
virtual void ZeroPhaseFlip(bitLenInt start, bitLenInt length)
For chips with a zero flag, flip the phase of the state where the register equals zero...
Definition: opencl.cpp:1089
virtual void INCSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Increment integer (with sign, with carry)
Definition: opencl.cpp:754
std::shared_ptr< QEngineOCL > QEngineOCLPtr
Definition: qengine_opencl.hpp:27
virtual bitLenInt Cohere(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qengine_opencl.hpp:107
cl::Context context
Definition: qengine_opencl.hpp:38
complex * stateVec
Definition: qengine_opencl.hpp:34
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:46
virtual void SetDevice(const int &dID, const bool &forceReInit=false)
Definition: opencl.cpp:134
std::shared_ptr< cl::Buffer > BufferPtr
Definition: qengine_opencl.hpp:23
virtual void CMUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length, bool clearCarry=false)
Controlled multiplication by integer.
Definition: opencl.cpp:931
size_t FixWorkItemCount(size_t maxI, size_t wic)
Definition: opencl.cpp:78
virtual int GetDeviceID()
Definition: qengine_opencl.hpp:166
virtual void UnlockSync()
Definition: opencl.cpp:66
Definition: complex16simd.hpp:21
virtual void ROR(bitLenInt shift, bitLenInt start, bitLenInt length)
"Circular shift right" - shift bits right, and carry first bits.
Definition: opencl.cpp:643
virtual void NormalizeState(real1 nrm=-999.0)
Definition: opencl.cpp:1145
virtual cl::Context & GetCLContext()
Definition: qengine_opencl.hpp:92
cl::Buffer cmplxBuffer
Definition: qengine_opencl.hpp:42
virtual cl::CommandQueue & GetCLQueue()
Definition: qengine_opencl.hpp:94
virtual bitLenInt Cohere(QEngineOCLPtr toCopy)
Definition: opencl.cpp:357
virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Increment integer (without sign, with carry)
Definition: opencl.cpp:658
virtual void ApplyM(bitCapInt qPower, bool result, complex nrm)
Definition: opencl.cpp:330