ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
global.h
Go to the documentation of this file.
1#ifndef GLOBAL_H
2#define GLOBAL_H
3
8#include "source_io/restart.h"
10#ifdef __EXX
13#endif
16#ifdef __CUDA
17#include "cublas_v2.h"
18#include "cufft.h"
20
21static const char* _cublasGetErrorString(cublasStatus_t error)
22{
23 switch (error)
24 {
25 case CUBLAS_STATUS_SUCCESS:
26 return "CUBLAS_STATUS_SUCCESS";
27 case CUBLAS_STATUS_NOT_INITIALIZED:
28 return "CUBLAS_STATUS_NOT_INITIALIZED";
29 case CUBLAS_STATUS_ALLOC_FAILED:
30 return "CUBLAS_STATUS_ALLOC_FAILED";
31 case CUBLAS_STATUS_INVALID_VALUE:
32 return "CUBLAS_STATUS_INVALID_VALUE";
33 case CUBLAS_STATUS_ARCH_MISMATCH:
34 return "CUBLAS_STATUS_ARCH_MISMATCH";
35 case CUBLAS_STATUS_MAPPING_ERROR:
36 return "CUBLAS_STATUS_MAPPING_ERROR";
37 case CUBLAS_STATUS_EXECUTION_FAILED:
38 return "CUBLAS_STATUS_EXECUTION_FAILED";
39 case CUBLAS_STATUS_INTERNAL_ERROR:
40 return "CUBLAS_STATUS_INTERNAL_ERROR";
41 }
42 return "<unknown>";
43}
44
45#define CHECK_CUDA(func) \
46 { \
47 cudaError_t status = (func); \
48 if (status != cudaSuccess) \
49 { \
50 printf("In File %s : CUDA API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
51 cudaGetErrorString(status), status); \
52 } \
53 }
54
55#define CHECK_CUBLAS(func) \
56 { \
57 cublasStatus_t status = (func); \
58 if (status != CUBLAS_STATUS_SUCCESS) \
59 { \
60 printf("In File %s : CUBLAS API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
61 _cublasGetErrorString(status), status); \
62 } \
63 }
64
65#define CHECK_CUSOLVER(func) \
66 { \
67 cusolverStatus_t status = (func); \
68 if (status != CUSOLVER_STATUS_SUCCESS) \
69 { \
70 printf("In File %s : CUSOLVER API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
71 _cusolverGetErrorString(status), status); \
72 } \
73 }
74
75#define CHECK_CUFFT(func) \
76 { \
77 cufftResult_t status = (func); \
78 if (status != CUFFT_SUCCESS) \
79 { \
80 printf("In File %s : CUFFT API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
81 ModuleBase::cuda_compat::cufftGetErrorStringCompat(status), status); \
82 } \
83 }
84#endif // __CUDA
85
86#ifdef __ROCM
87#include <hip/hip_runtime.h>
88#include <hipblas/hipblas.h>
89#include <hipfft/hipfft.h>
90
91static const char* _hipblasGetErrorString(hipblasStatus_t error)
92{
93 switch (error)
94 {
95 case HIPBLAS_STATUS_SUCCESS:
96 return "HIPBLAS_STATUS_SUCCESS";
97 case HIPBLAS_STATUS_NOT_INITIALIZED:
98 return "HIPBLAS_STATUS_NOT_INITIALIZED";
99 case HIPBLAS_STATUS_ALLOC_FAILED:
100 return "HIPBLAS_STATUS_ALLOC_FAILED";
101 case HIPBLAS_STATUS_INVALID_VALUE:
102 return "HIPBLAS_STATUS_INVALID_VALUE";
103 case HIPBLAS_STATUS_ARCH_MISMATCH:
104 return "HIPBLAS_STATUS_ARCH_MISMATCH";
105 case HIPBLAS_STATUS_MAPPING_ERROR:
106 return "HIPBLAS_STATUS_MAPPING_ERROR";
107 case HIPBLAS_STATUS_EXECUTION_FAILED:
108 return "HIPBLAS_STATUS_EXECUTION_FAILED";
109 case HIPBLAS_STATUS_INTERNAL_ERROR:
110 return "HIPBLAS_STATUS_INTERNAL_ERROR";
111 case HIPBLAS_STATUS_NOT_SUPPORTED:
112 return "HIPBLAS_STATUS_NOT_SUPPORTED";
113 case HIPBLAS_STATUS_HANDLE_IS_NULLPTR:
114 return "HIPBLAS_STATUS_HANDLE_IS_NULLPTR";
115 default:
116 return "<unknown>";
117 }
118 return "<unknown>";
119}
120
121// static const char *_rocsolverGetErrorString(rocsolver_status error)
122// {
123// switch (error)
124// {
125// // case ROCSOLVER_STATUS_SUCCESS:
126// // return "CUSOLVER_STATUS_SUCCESS";
127// }
128// return "<unknown>";
129// }
130
131static const char* _hipfftGetErrorString(hipfftResult_t error)
132{
133 switch (error)
134 {
135 case HIPFFT_SUCCESS:
136 return "HIPFFT_SUCCESS";
137 case HIPFFT_INVALID_PLAN:
138 return "HIPFFT_INVALID_PLAN";
139 case HIPFFT_ALLOC_FAILED:
140 return "HIPFFT_ALLOC_FAILED";
141 case HIPFFT_INVALID_TYPE:
142 return "HIPFFT_INVALID_TYPE";
143 case HIPFFT_INVALID_VALUE:
144 return "HIPFFT_INVALID_VALUE";
145 case HIPFFT_INTERNAL_ERROR:
146 return "HIPFFT_INTERNAL_ERROR";
147 case HIPFFT_EXEC_FAILED:
148 return "HIPFFT_EXEC_FAILED";
149 case HIPFFT_SETUP_FAILED:
150 return "HIPFFT_SETUP_FAILED";
151 case HIPFFT_INVALID_SIZE:
152 return "HIPFFT_INVALID_SIZE";
153 case HIPFFT_UNALIGNED_DATA:
154 return "HIPFFT_UNALIGNED_DATA";
155 case HIPFFT_INCOMPLETE_PARAMETER_LIST:
156 return "HIPFFT_INCOMPLETE_PARAMETER_LIST";
157 case HIPFFT_INVALID_DEVICE:
158 return "HIPFFT_INVALID_DEVICE";
159 case HIPFFT_PARSE_ERROR:
160 return "HIPFFT_PARSE_ERROR";
161 case HIPFFT_NO_WORKSPACE:
162 return "HIPFFT_NO_WORKSPACE";
163 case HIPFFT_NOT_IMPLEMENTED:
164 return "HIPFFT_NOT_IMPLEMENTED";
165 case HIPFFT_NOT_SUPPORTED:
166 return "HIPFFT_NOT_SUPPORTED";
167 }
168 return "<unknown>";
169}
170
171#define CHECK_CUDA(func) \
172 { \
173 hipError_t status = (func); \
174 if (status != hipSuccess) \
175 { \
176 printf("In File %s : HIP API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
177 hipGetErrorString(status), status); \
178 } \
179 }
180
181#define CHECK_CUBLAS(func) \
182 { \
183 hipblasStatus_t status = (func); \
184 if (status != HIPBLAS_STATUS_SUCCESS) \
185 { \
186 printf("In File %s : HIPBLAS API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
187 _hipblasGetErrorString(status), status); \
188 } \
189 }
190
191// #define CHECK_CUSOLVER(func)\
192// {\
193// rocsolver_status status = (func);\
194// if(status != CUSOLVER_STATUS_SUCCESS)\
195// {\
196// printf("In File %s : CUSOLVER API failed at line %d with error: %s (%d)\n",\
197// __FILE__, __LINE__, _rocsolverGetErrorString(status), status);\
198// }\
199// }
200
201#define CHECK_CUFFT(func) \
202 { \
203 hipfftResult_t status = (func); \
204 if (status != HIPFFT_SUCCESS) \
205 { \
206 printf("In File %s : HIPFFT API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
207 _hipfftGetErrorString(status), status); \
208 } \
209 }
210#endif // __ROCM
211
212//==========================================================
213// EXPLAIN : define "GLOBAL CLASS"
214//==========================================================
215namespace GlobalC
216{
217//#ifdef __EXX
218 extern Exx_Info exx_info;
219//#endif
220} // namespace GlobalC
221
223#include "source_cell/unitcell.h"
224namespace GlobalC
225{
226extern Restart restart; // Peize Lin add 2020.04.04
227} // namespace GlobalC
228
229// extern Magnetism mag;
230
231#endif
Definition restart.h:12
Compatibility layer for CUDA and NVTX headers across different CUDA Toolkit versions.
Definition cal_epsilon_test.cpp:31
Exx_Info exx_info
Definition test_xc.cpp:29
Restart restart
Definition for_testing_input_conv.h:255
Definition exx_info.h:12