The Quantum Exact Simulation Toolkit v4.1.0
Loading...
Searching...
No Matches
debug.h
1/** @file
2 * API signatures for debugging QuEST behaviour,
3 * controlling input validation, changing reporter
4 * parameters or seeding random generation.
5 *
6 * @author Tyson Jones
7 *
8 * @defgroup debug Debug
9 * @ingroup api
10 * @brief Utilities for controlling QuEST behaviour such as seeding, input validation and printing.
11 * @{
12 */
13
14#ifndef DEBUG_H
15#define DEBUG_H
16
17#include "quest/include/types.h"
18
19
20
21/*
22 * C AND C++ AGNOSTIC FUNCTIONS
23 */
24
25// enable invocation by both C and C++ binaries
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31
32/**
33 * @defgroup debug_seed Seeding
34 * @brief Functions for seeding QuEST's random generators.
35 * @details Re-seeding with identical seeds will determine all of QuEST's subsequent
36 * random outputs (such as measurement and random state preparation), and can
37 * be done at any stage of execution. When seeding is not explicitly performed,
38 * QuEST will attempt to use a cryptographically secure pseudorandom number generator
39 * (CSPRNG) if locally available, else fall back to a standard PRNG, via using
40 * the standard C++ `random_device` class.
41 * @{
42 */
43
44
45/// @notyetdoced
46void setSeeds(unsigned* seeds, int numSeeds);
47
48
49/// @notyetdoced
51
52
53/// @notyetdoced
54void getSeeds(unsigned* seeds);
55
56
57/// @notyetdoced
58int getNumSeeds();
59
60
61/** @} */
62
63
64
65/**
66 * @defgroup debug_validation Validation
67 * @brief Functions to control QuEST's user-input validation.
68 * @details These can be used to adjust the precision with which properties like unitarity
69 * are checked/enforced, or otherwise disable all input validation (e.g. is the
70 * given qubit index valid?). Note passing erroneous input while validation is
71 * disabled can result in runtime errors like segmentation faults.
72 * @{
73 */
74
75
76/** @notyetdoced
77 *
78 * @see
79 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/setting_errorhandler.c) and
80 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/setting_errorhandler.cpp) examples
81 */
82void setInputErrorHandler(void (*callback)(const char* func, const char* msg));
83
84
85/// @notyetdoced
86void setValidationOn();
87
88
89/// @notyetdoced
90void setValidationOff();
91
92
93/// @notyetdoced
95
96
97/// @notyetdoced
98void setValidationEpsilon(qreal eps);
99
100
101/// @notyetdoced
103
104
105/** @} */
106
107
108
109/**
110 * @defgroup debug_reporting Reporting
111 * @brief Functions to control how QuEST's reporters display and truncate information.
112 * @{
113 */
114
115
116/// @notyetdoced
117/// @notyettested
118void setMaxNumReportedItems(qindex numRows, qindex numCols);
119
120
121/** @notyetdoced
122 * > This function does not affect the significant figures in printed memory sizes
123 * > (e.g. `5.32 KiB`) which is always shown with three significant figures
124 * > (or four when in bytes, e.g. `1023 bytes`).
125 */
126void setMaxNumReportedSigFigs(int numSigFigs);
127
128
129/// @notyetdoced
130void setNumReportedNewlines(int numNewlines);
131
132
133/**
134 * @notyetdoced
135 * @notyettested
136 * @myexample
137 * ```
138 PauliStr str = getInlinePauliStr("XYZ", {0,10,20});
139 reportPauliStr(str);
140
141 setReportedPauliChars(".xyz");
142 reportPauliStr(str);
143 * ```
144 */
145void setReportedPauliChars(const char* paulis);
146
147
148/**
149 * @notyetdoced
150 * @notyettested
151 * @myexample
152 * ```
153 PauliStr str = getInlinePauliStr("XYZ", {0,10,20});
154
155 setReportedPauliStrStyle(0);
156 reportPauliStr(str);
157
158 setReportedPauliStrStyle(1);
159 reportPauliStr(str);
160 * ```
161 */
162void setReportedPauliStrStyle(int style);
163
164
165/** @} */
166
167
168
169/**
170 * @defgroup debug_cache Caching
171 * @brief Functions to control temporary memory used by the QuEST process.
172 * @{
173 */
174
175
176/// @notyetdoced
177qindex getGpuCacheSize();
178
179
180/// @notyetdoced
181void clearGpuCache();
182
183
184/** @} */
185
186
187
188/**
189 * @defgroup debug_info Info
190 * @brief Functions for getting debugging information.
191 * @{
192 */
193
194
195/// @notyetdoced
196/// @notyettested
197void getEnvironmentString(char str[200]);
198
199
200/** @} */
201
202
203
204// end de-mangler
205#ifdef __cplusplus
206}
207#endif
208
209
210
211/*
212 * C++ OVERLOADS
213 *
214 * which are only accessible to C++ binaries, and accept
215 * arguments more natural to C++ (e.g. std::vector). We
216 * manually add these to their respective Doxygen doc groups.
217 */
218
219#ifdef __cplusplus
220
221#include <vector>
222
223
224/// @ingroup debug_seed
225/// @notyettested
226/// @notyetdoced
227/// @cppvectoroverload
228/// @see setSeeds()
229void setSeeds(std::vector<unsigned> seeds);
230
231
232/// @ingroup debug_seed
233/// @notyettested
234/// @notyetdoced
235/// @cpponly
236/// @see getSeeds()
237std::vector<unsigned> getSeeds();
238
239
240#endif // __cplusplus
241
242
243
244#endif // DEBUG_H
245
246/** @} */ // (end file-wide doxygen defgroup)
qindex getGpuCacheSize()
Definition debug.cpp:180
void clearGpuCache()
Definition debug.cpp:191
void getEnvironmentString(char str[200])
void setMaxNumReportedItems(qindex numRows, qindex numCols)
Definition debug.cpp:128
void setReportedPauliStrStyle(int style)
Definition debug.cpp:166
void setMaxNumReportedSigFigs(int numSigFigs)
Definition debug.cpp:142
void setNumReportedNewlines(int numNewlines)
Definition debug.cpp:150
void setReportedPauliChars(const char *paulis)
Definition debug.cpp:158
std::vector< unsigned > getSeeds()
Definition debug.cpp:213
void setSeedsToDefault()
Definition debug.cpp:45
int getNumSeeds()
Definition debug.cpp:52
void setSeeds(unsigned *seeds, int numSeeds)
Definition debug.cpp:37
void setInputErrorHandler(void(*callback)(const char *func, const char *msg))
Definition debug.cpp:74
void setValidationOff()
Definition debug.cpp:86
void setValidationEpsilonToDefault()
Definition debug.cpp:108
void setValidationOn()
Definition debug.cpp:80
qreal getValidationEpsilon()
Definition debug.cpp:115
void setValidationEpsilon(qreal eps)
Definition debug.cpp:100