-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy patherrors.hpp
More file actions
342 lines (176 loc) · 7.12 KB
/
errors.hpp
File metadata and controls
342 lines (176 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/** @file
* Defensively designed functions for checking internal preconditions,
* and raising internal errors. These primarily check that that
* hardware accelerators are behaving as expected, and that runtime
* deployment is consistent with the compiled deployment modes.
*
* @author Tyson Jones
*/
#ifndef ERRORS_HPP
#define ERRORS_HPP
#include "quest/include/types.h"
#include "quest/include/qureg.h"
#include "quest/include/matrices.h"
#include <string>
using std::string;
/*
* VALIDATION ERRORS
*/
void error_validationMessageVarWasIllFormed(string msg, string illFormedVar);
void error_validationMessageVarNotSubstituted(string msg, string var);
void error_validationMessageContainedUnsubstitutedVars(string msg);
void error_validationEncounteredUnsupportedDistributedDenseMatrix();
void error_validationListUniquenessCheckExceededMaskSize();
/*
* ENVIRONMENT ERRORS
*/
void error_allocOfQuESTEnvFailed();
/*
* MEMORY ERRORS
*/
void error_memSizeQueriedButWouldOverflow();
/*
* COMMUNICATION ERRORS
*/
void error_commNotInit();
void error_commAlreadyInit();
void error_commButEnvNotDistributed();
void error_commButQuregNotDistributed();
void error_commOutOfBounds();
void error_commWithSameRank();
void error_commGivenInconsistentNumSubArraysANodes();
void error_commNumMessagesExceedTagMax();
void assert_commBoundsAreValid(Qureg qureg, qindex sendInd, qindex recvInd, qindex numAmps);
void assert_commPayloadIsPowerOf2(qindex numAmps);
void assert_commQuregIsDistributed(Qureg qureg);
void assert_commFullStateDiagMatrIsDistributed(FullStateDiagMatr matr);
void assert_pairRankIsDistinct(Qureg qureg, int pairRank);
void assert_bufferSendRecvDoesNotOverlap(qindex sendInd, qindex recvInd, qindex numAmps);
void assert_receiverCanFitSendersEntireState(Qureg receiver, Qureg sender);
void assert_receiverCanFitSendersEntireElems(Qureg receiver, FullStateDiagMatr sender);
/*
* LOCALISER ERRORS
*/
void error_localiserNumCtrlStatesInconsistentWithNumCtrls();
void error_localiserGivenPauliTensorOrGadgetWithoutXOrY();
void error_localiserPassedStateVecToChannelComCheck();
void error_localiserGivenDistribMatrixAndLocalQureg();
void error_localiserFailedToAllocTempMemory();
void error_localiserGivenPauliStrWithoutXorY();
void error_localiserGivenNonUnityGlobalFactorToZTensor();
void assert_localiserSuccessfullyAllocatedTempMemory(qcomp* ptr, bool isGpu);
void assert_localiserGivenStateVec(Qureg qureg);
void assert_localiserGivenDensMatr(Qureg qureg);
void assert_localiserPartialTraceGivenCompatibleQuregs(Qureg inQureg, Qureg outQureg, int numTargs);
void error_calcFidStateVecDistribWhileDensMatrLocal();
void assert_localiserDistribQuregSpooferGivenValidQuregs(Qureg local, Qureg distrib);
/*
* ACCELERATOR ERRORS
*/
void assert_highPauliStrSumMaskIsZero(PauliStrSum sum);
void assert_numQubitsMatchesQubitStatesAndTemplateParam(int numQubits, int numQubitStates, int templateParam, string label="qubit");
void assert_numCtrlsMatchesNumCtrlStatesAndTemplateParam(int numCtrls, int numCtrlStates, int templateParam);
void assert_numTargsMatchesTemplateParam(int numTargs, int templateParam);
void assert_exponentMatchesTemplateParam(qcomp exponent, bool hasPower);
void assert_exponentMatchesTemplateParam(qcomp exponent, bool hasPower, bool useRealPow);
void assert_mixedQuregIsDensityMatrix(Qureg qureg);
void assert_mixedQuregIsStatevector(Qureg qureg);
void assert_mixedQuregIsDistributed(Qureg qureg);
void assert_mixedQuregIsLocal(Qureg qureg);
void assert_mixedQuregsAreBothOrNeitherDistributed(Qureg a, Qureg b);
void error_mixQuregsAreLocalDensMatrAndDistribStatevec();
void assert_fullStateDiagMatrIsLocal(FullStateDiagMatr matr);
void assert_fullStateDiagMatrIsDistributed(FullStateDiagMatr matr);
void assert_acceleratorQuregIsDistributed(Qureg qureg);
void assert_quregAndFullStateDiagMatrAreBothOrNeitherDistrib(Qureg qureg, FullStateDiagMatr matr);
void assert_calcFidStateVecIsLocal(Qureg qureg);
void assert_calcFidTempGpuAllocSucceeded(qcomp* ptr);
void assert_calcExpecDiagTempGpuAllocSucceeded(qcomp* ptr);
void assert_innerProductedSameDimQuregsHaveSameGpuAccel(Qureg quregA, Qureg quregB);
void assert_partialTraceQuregsAreIdenticallyDeployed(Qureg inQureg, Qureg outQureg);
/*
* BUFFER PACKING ERRORS
*/
void error_noCtrlsGivenToBufferPacker();
void assert_bufferPackerGivenIncreasingQubits(int qubit1, int qubit2, int qubit3);
/*
* BACKEND PRECONDITION ERRORS
*/
void assert_quregAndFullStateDiagMatrHaveSameDistrib(Qureg qureg, FullStateDiagMatr matr);
void assert_quregDistribAndFullStateDiagMatrLocal(Qureg qureg, FullStateDiagMatr matr);
void assert_superposedQuregDimsAndDeploysMatch(Qureg facOut, Qureg in1, Qureg in2);
/*
* CPU ERRORS
*/
void error_cpuThreadsQueriedButEnvNotMultithreaded();
/*
* GPU ERRORS
*/
void error_gpuQueriedButGpuNotCompiled();
void error_gpuSyncedButGpuNotCompiled();
void error_gpuAllocButGpuNotCompiled();
void error_gpuDeallocButGpuNotCompiled();
void error_gpuCopyButGpuNotCompiled();
void error_gpuSimButGpuNotCompiled();
void error_gpuCacheModifiedButGpuNotCompiled();
void error_gpuCopyButQuregNotGpuAccelerated();
void error_gpuCopyButMatrixNotGpuAccelerated();
void error_gpuMemSyncQueriedButEnvNotGpuAccelerated();
void error_gpuUnexpectedlyInaccessible();
void error_gpuDeadCopyMatrixFunctionCalled();
void assert_gpuIsAccessible();
void assert_gpuHasBeenBound(bool isBound);
void assert_quregIsGpuAccelerated(Qureg qureg);
void assert_mixQuregTempGpuAllocSucceeded(qcomp* gpuPtr);
void assert_quregGpuBufferIsNotGraftedToMatrix(Qureg qureg, FullStateDiagMatr matr);
void assert_applyFullStateDiagMatrTempGpuAllocSucceeded(qcomp* gpuPtr);
/*
* CUDA ERRORS
*/
void error_cudaCallFailed(const char* msg, const char* func, const char* caller, const char* file, int line);
/*
* THRUST ERRORS
*/
void error_thrustTempGpuAllocFailed();
/*
* CUQUANTUM ERRORS
*/
void error_cuQuantumInitOrFinalizedButNotCompiled();
void error_cuQuantumTempCpuAllocFailed();
/*
* PAULI ERRORS
*/
void error_pauliStrShiftedByIllegalAmount();
/*
* UTILITY ERRORS
*/
void error_nodeUnexpectedlyContainedNoElems();
void error_utilsGetBraIndGivenNonDensMatr();
void error_utilsGetPrefixIndGivenSuffixQubit();
void error_utilsGetPrefixBraIndGivenNonDensMatr();
void error_utilsGetPrefixBraIndGivenSuffixQubit();
void error_utilsIsBraQubitInSuffixGivenNonDensMatr();
void error_utilsGivenGlobalIndexOutsideNode();
void assert_utilsGivenStateVec(Qureg qureg);
void assert_utilsGivenDensMatr(Qureg qureg);
void assert_utilsGivenNonZeroEpsilon(qreal eps);
/*
* PARSING ERRORS
*/
void error_attemptedToParseComplexFromInvalidString();
void error_attemptedToParseRealFromInvalidString();
void error_attemptedToParseOutOfRangeReal();
void error_attemptedToParsePauliStringFromInvalidString();
void error_attemptedToParseUnrecognisedPauliChar();
void error_couldNotReadFile();
/*
* RANDOMISER ERRORS
*/
void error_randomiserGivenNonNormalisedProbList();
/*
* PRINTER ERRORS
*/
void error_printerFailedToAllocTempMemory();
void assert_printerGivenNonNegativeNumNewlines();
void assert_printerGivenPositiveNumNewlines();
#endif // ERRORS_HPP