forked from QuEST-Kit/QuEST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu_config.hpp
More file actions
125 lines (75 loc) · 2.5 KB
/
Copy pathgpu_config.hpp
File metadata and controls
125 lines (75 loc) · 2.5 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
/** @file
* Utility signatures for querying GPU hardware,
* and allocating and copying GPU VRAM data.
*
* Note that this header is included by /core/ and
* parsed by non-CUDA compilers, so must never contain
* any CUDA-specific signatures
*
* @author Tyson Jones
*/
#ifndef GPU_CONFIG_HPP
#define GPU_CONFIG_HPP
#include "quest/include/config.h"
#include "quest/include/types.h"
#include "quest/include/qureg.h"
#include "quest/include/matrices.h"
#include "quest/include/channels.h"
/*
* CUDA ERROR HANDLING
*/
#if COMPILE_CUDA
#define CUDA_CHECK(cmd) \
assertCudaCallSucceeded((int) (cmd), #cmd, __func__, __FILE__, __LINE__)
void assertCudaCallSucceeded(int code, const char* call, const char* caller, const char* file, int line);
#endif
/*
* HARDWARE AVAILABILITY
*/
bool gpu_isGpuCompiled();
bool gpu_isCuQuantumCompiled();
bool gpu_isGpuAvailable();
bool gpu_isDirectGpuCommPossible();
int gpu_getNumberOfLocalGpus();
int gpu_getComputeCapability();
size_t gpu_getCurrentAvailableMemoryInBytes();
size_t gpu_getTotalMemoryInBytes();
bool gpu_doesGpuSupportMemPools();
qindex gpu_getMaxNumConcurrentThreads();
/*
* ENVIRONMENT MANAGEMENT
*/
void gpu_bindLocalGPUsToNodes();
bool gpu_areAnyNodesBoundToSameGpu();
void gpu_sync();
void gpu_initCuQuantum();
void gpu_finalizeCuQuantum();
/*
* MEMORY MANAGEMENT
*/
qcomp* gpu_allocArray(qindex numLocalAmps);
void gpu_deallocArray(qcomp* amps);
void gpu_copyArray(qcomp* dest, qcomp* src, qindex dim);
void gpu_copyCpuToGpu(qcomp* cpuArr, qcomp* gpuArr, qindex numElems);
void gpu_copyGpuToCpu(qcomp* gpuArr, qcomp* cpuArr, qindex numElems);
void gpu_copyGpuToCpu(Qureg qureg, qcomp* gpuArr, qcomp* cpuArr, qindex numElems);
void gpu_copyGpuToCpu(Qureg qureg);
void gpu_copyCpuToGpu(Qureg qureg, qcomp* cpuArr, qcomp* gpuArr, qindex numElems);
void gpu_copyCpuToGpu(Qureg qureg);
void gpu_copyCpuToGpu(CompMatr matr);
void gpu_copyGpuToCpu(CompMatr matr);
void gpu_copyCpuToGpu(DiagMatr matr);
void gpu_copyGpuToCpu(DiagMatr matr);
void gpu_copyCpuToGpu(SuperOp op);
void gpu_copyGpuToCpu(SuperOp op);
// funnily, there is no need for GPU-to-CPU or FullStateDiagMatr;
// the invoking printer.cpp function uses localiser_fullstatediagamtr_...
// copying to handle the distributed nuisance, which spoofs a Qureg
void gpu_copyCpuToGpu(FullStateDiagMatr matr);
/*
* CACHE MANAGEMENT
*/
qcomp* gpu_getCacheOfSize(qindex numElemsPerThread, qindex numThreads);
void gpu_clearCache();
size_t gpu_getCacheMemoryInBytes();
#endif // GPU_CONFIG_HPP