The Quantum Exact Simulation Toolkit v4.0.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/// @notdoced
46void setSeeds(unsigned* seeds, int numSeeds);
47
48
49/// @notdoced
51
52
53/// @notdoced
54void getSeeds(unsigned* seeds);
55
56
57/// @notdoced
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/// @notdoced
77void setInputErrorHandler(void (*callback)(const char* func, const char* msg));
78
79
80/// @notdoced
81void setValidationOn();
82
83
84/// @notdoced
85void setValidationOff();
86
87
88/// @notdoced
90
91
92/// @notdoced
93void setValidationEpsilon(qreal eps);
94
95
96/// @notdoced
98
99
100/** @} */
101
102
103
104/**
105 * @defgroup debug_reporting Reporting
106 * @brief Functions to control how QuEST's reporters display and truncate information.
107 * @{
108 */
109
110
111/// @notdoced
112/// @nottested
113void setMaxNumReportedItems(qindex numRows, qindex numCols);
114
115
116/** @notdoced
117 * > This function does not affect the significant figures in printed memory sizes
118 * > (e.g. `5.32 KiB`) which is always shown with three significant figures
119 * > (or four when in bytes, e.g. `1023 bytes`).
120 */
121void setMaxNumReportedSigFigs(int numSigFigs);
122
123
124/// @notdoced
125void setNumReportedNewlines(int numNewlines);
126
127
128/** @} */
129
130
131
132/**
133 * @defgroup debug_cache Caching
134 * @brief Functions to control temporary memory used by the QuEST process.
135 * @{
136 */
137
138
139/// @notdoced
140qindex getGpuCacheSize();
141
142
143/// @notdoced
144void clearGpuCache();
145
146
147/** @} */
148
149
150
151/**
152 * @defgroup debug_info Info
153 * @brief Functions for getting debugging information.
154 * @{
155 */
156
157
158/// @notdoced
159/// @nottested
160void getEnvironmentString(char str[200]);
161
162
163/** @} */
164
165
166
167// end de-mangler
168#ifdef __cplusplus
169}
170#endif
171
172
173
174/*
175 * C++ OVERLOADS
176 *
177 * which are only accessible to C++ binaries, and accept
178 * arguments more natural to C++ (e.g. std::vector). We
179 * manually add these to their respective Doxygen doc groups.
180 */
181
182#ifdef __cplusplus
183
184#include <vector>
185
186
187/// @ingroup debug_seed
188/// @nottested
189/// @notdoced
190/// @cpponly
191void setSeeds(std::vector<unsigned> seeds);
192
193
194/// @ingroup debug_seed
195/// @nottested
196/// @notdoced
197/// @cpponly
198std::vector<unsigned> getSeeds();
199
200
201#endif // __cplusplus
202
203
204
205#endif // DEBUG_H
206
207/** @} */ // (end file-wide doxygen defgroup)
qindex getGpuCacheSize()
Definition debug.cpp:164
void clearGpuCache()
Definition debug.cpp:175
void getEnvironmentString(char str[200])
void setMaxNumReportedItems(qindex numRows, qindex numCols)
Definition debug.cpp:128
void setMaxNumReportedSigFigs(int numSigFigs)
Definition debug.cpp:142
void setNumReportedNewlines(int numNewlines)
Definition debug.cpp:150
std::vector< unsigned > getSeeds()
Definition debug.cpp:197
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