10#include "cusolverDn.h"
13static const char* _cublasGetErrorString(cublasStatus_t error)
17 case CUBLAS_STATUS_SUCCESS:
18 return "CUBLAS_STATUS_SUCCESS";
19 case CUBLAS_STATUS_NOT_INITIALIZED:
20 return "CUBLAS_STATUS_NOT_INITIALIZED";
21 case CUBLAS_STATUS_ALLOC_FAILED:
22 return "CUBLAS_STATUS_ALLOC_FAILED";
23 case CUBLAS_STATUS_INVALID_VALUE:
24 return "CUBLAS_STATUS_INVALID_VALUE";
25 case CUBLAS_STATUS_ARCH_MISMATCH:
26 return "CUBLAS_STATUS_ARCH_MISMATCH";
27 case CUBLAS_STATUS_MAPPING_ERROR:
28 return "CUBLAS_STATUS_MAPPING_ERROR";
29 case CUBLAS_STATUS_EXECUTION_FAILED:
30 return "CUBLAS_STATUS_EXECUTION_FAILED";
31 case CUBLAS_STATUS_INTERNAL_ERROR:
32 return "CUBLAS_STATUS_INTERNAL_ERROR";
33 case CUBLAS_STATUS_NOT_SUPPORTED:
34 return "CUBLAS_STATUS_NOT_SUPPORTED";
35 case CUBLAS_STATUS_LICENSE_ERROR:
36 return "CUBLAS_STATUS_LICENSE_ERROR";
42static const char* _cusolverGetErrorString(cusolverStatus_t error)
46 case CUSOLVER_STATUS_SUCCESS:
47 return "CUSOLVER_STATUS_SUCCESS";
48 case CUSOLVER_STATUS_NOT_INITIALIZED:
49 return "CUSOLVER_STATUS_NOT_INITIALIZED";
50 case CUSOLVER_STATUS_ALLOC_FAILED:
51 return "CUSOLVER_STATUS_ALLOC_FAILED";
52 case CUSOLVER_STATUS_INVALID_VALUE:
53 return "CUSOLVER_STATUS_INVALID_VALUE";
54 case CUSOLVER_STATUS_ARCH_MISMATCH:
55 return "CUSOLVER_STATUS_ARCH_MISMATCH";
56 case CUSOLVER_STATUS_MAPPING_ERROR:
57 return "CUSOLVER_STATUS_MAPPING_ERROR";
58 case CUSOLVER_STATUS_EXECUTION_FAILED:
59 return "CUSOLVER_STATUS_EXECUTION_FAILED";
60 case CUSOLVER_STATUS_INTERNAL_ERROR:
61 return "CUSOLVER_STATUS_INTERNAL_ERROR";
62 case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
63 return "CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
64 case CUSOLVER_STATUS_NOT_SUPPORTED:
65 return "CUSOLVER_STATUS_NOT_SUPPORTED";
66 case CUSOLVER_STATUS_ZERO_PIVOT:
67 return "CUSOLVER_STATUS_ZERO_PIVOT";
68 case CUSOLVER_STATUS_INVALID_LICENSE:
69 return "CUSOLVER_STATUS_INVALID_LICENSE";
70#if CUDA_VERSION >= 11000
71 case CUSOLVER_STATUS_IRS_PARAMS_NOT_INITIALIZED:
72 return "CUSOLVER_STATUS_IRS_PARAMS_NOT_INITIALIZED";
73 case CUSOLVER_STATUS_IRS_PARAMS_INVALID:
74 return "CUSOLVER_STATUS_IRS_PARAMS_INVALID";
75 case CUSOLVER_STATUS_IRS_PARAMS_INVALID_PREC:
76 return "CUSOLVER_STATUS_IRS_PARAMS_INVALID_PREC";
77 case CUSOLVER_STATUS_IRS_PARAMS_INVALID_REFINE:
78 return "CUSOLVER_STATUS_IRS_PARAMS_INVALID_REFINE";
79 case CUSOLVER_STATUS_IRS_PARAMS_INVALID_MAXITER:
80 return "CUSOLVER_STATUS_IRS_PARAMS_INVALID_MAXITER";
81 case CUSOLVER_STATUS_IRS_INTERNAL_ERROR:
82 return "CUSOLVER_STATUS_IRS_INTERNAL_ERROR";
83 case CUSOLVER_STATUS_IRS_NOT_SUPPORTED:
84 return "CUSOLVER_STATUS_IRS_NOT_SUPPORTED";
85 case CUSOLVER_STATUS_IRS_OUT_OF_RANGE:
86 return "CUSOLVER_STATUS_IRS_OUT_OF_RANGE";
87 case CUSOLVER_STATUS_IRS_NRHS_NOT_SUPPORTED_FOR_REFINE_GMRES:
88 return "CUSOLVER_STATUS_IRS_NRHS_NOT_SUPPORTED_FOR_REFINE_GMRES";
89 case CUSOLVER_STATUS_IRS_INFOS_NOT_INITIALIZED:
90 return "CUSOLVER_STATUS_IRS_INFOS_NOT_INITIALIZED";
91 case CUSOLVER_STATUS_IRS_INFOS_NOT_DESTROYED:
92 return "CUSOLVER_STATUS_IRS_INFOS_NOT_DESTROYED";
93 case CUSOLVER_STATUS_IRS_MATRIX_SINGULAR:
94 return "CUSOLVER_STATUS_IRS_MATRIX_SINGULAR";
95 case CUSOLVER_STATUS_INVALID_WORKSPACE:
96 return "CUSOLVER_STATUS_INVALID_WORKSPACE";
103static const char* _cufftGetErrorString(cufftResult_t error)
108 return "CUFFT_SUCCESS";
109 case CUFFT_INVALID_PLAN:
110 return "CUFFT_INVALID_PLAN";
111 case CUFFT_ALLOC_FAILED:
112 return "CUFFT_ALLOC_FAILED";
113 case CUFFT_INVALID_TYPE:
114 return "CUFFT_INVALID_TYPE";
115 case CUFFT_INVALID_VALUE:
116 return "CUFFT_INVALID_VALUE";
117 case CUFFT_INTERNAL_ERROR:
118 return "CUFFT_INTERNAL_ERROR";
119 case CUFFT_EXEC_FAILED:
120 return "CUFFT_EXEC_FAILED";
121 case CUFFT_SETUP_FAILED:
122 return "CUFFT_SETUP_FAILED";
123 case CUFFT_INVALID_SIZE:
124 return "CUFFT_INVALID_SIZE";
125 case CUFFT_UNALIGNED_DATA:
126 return "CUFFT_UNALIGNED_DATA";
127 case CUFFT_INVALID_DEVICE:
128 return "CUFFT_INVALID_DEVICE";
129 case CUFFT_NO_WORKSPACE:
130 return "CUFFT_NO_WORKSPACE";
131 case CUFFT_NOT_IMPLEMENTED:
132 return "CUFFT_NOT_IMPLEMENTED";
133 case CUFFT_NOT_SUPPORTED:
134 return "CUFFT_NOT_SUPPORTED";
135#if defined(CUDA_VERSION) && CUDA_VERSION < 13000
136 case CUFFT_INCOMPLETE_PARAMETER_LIST:
137 return "CUFFT_INCOMPLETE_PARAMETER_LIST";
138 case CUFFT_PARSE_ERROR:
139 return "CUFFT_PARSE_ERROR";
140 case CUFFT_LICENSE_ERROR:
141 return "CUFFT_LICENSE_ERROR";
148#define CHECK_CUDA(func) \
151 cudaError_t status = (func); \
152 if (status != cudaSuccess) \
154 fprintf(stderr, "In File %s : CUDA API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
155 cudaGetErrorString(status), status); \
156 exit(EXIT_FAILURE); \
160#define CHECK_CUBLAS(func) \
163 cublasStatus_t status = (func); \
164 if (status != CUBLAS_STATUS_SUCCESS) \
166 fprintf(stderr, "In File %s : CUBLAS API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
167 _cublasGetErrorString(status), status); \
168 exit(EXIT_FAILURE); \
172#define CHECK_CUSOLVER(func) \
175 cusolverStatus_t status = (func); \
176 if (status != CUSOLVER_STATUS_SUCCESS) \
178 fprintf(stderr, "In File %s : CUSOLVER API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
179 _cusolverGetErrorString(status), status); \
180 exit(EXIT_FAILURE); \
184#define CHECK_CUFFT(func) \
187 cufftResult_t status = (func); \
188 if (status != CUFFT_SUCCESS) \
190 fprintf(stderr, "In File %s : CUFFT API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
191 _cufftGetErrorString(status), status); \
192 exit(EXIT_FAILURE); \
196#define CHECK_LAST_CUDA_ERROR(msg) \
199 cudaError_t status = cudaGetLastError(); \
200 if (status != cudaSuccess) \
202 fprintf(stderr, "%s(%d) : CUDA error : %s : (%d) %s.\n", __FILE__, __LINE__, msg, \
203 static_cast<int>(status), cudaGetErrorString(status)); \
204 exit(EXIT_FAILURE); \
209#define CHECK_CUDA_SYNC() \
212 cudaError_t status = cudaDeviceSynchronize(); \
213 if (status != cudaSuccess) \
215 fprintf(stderr, "In File %s : CUDA sync failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
216 cudaGetErrorString(status), status); \
217 exit(EXIT_FAILURE); \
221#define CHECK_CUDA_SYNC() do {} while (0)
225#if (defined(__CUSOLVERMP) && !defined(__USE_CAL)) || defined(__NCCL_PARALLEL_DEVICE)
228#define CHECK_NCCL(func) \
231 ncclResult_t status = (func); \
232 if (status != ncclSuccess) \
234 fprintf(stderr, "In File %s : NCCL API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
235 ncclGetErrorString(status), status); \
236 exit(EXIT_FAILURE); \
243#include <cusolverMp.h>
248static const char* _calGetErrorString(calError_t error)
256 case CAL_ERROR_INVALID_PARAMETER:
257 return "CAL_ERROR_INVALID_PARAMETER";
258 case CAL_ERROR_INTERNAL:
259 return "CAL_ERROR_INTERNAL";
261 return "CAL_ERROR_CUDA";
263 return "CAL_ERROR_UCC";
264 case CAL_ERROR_NOT_SUPPORTED:
265 return "CAL_ERROR_NOT_SUPPORTED";
266 case CAL_ERROR_INPROGRESS:
267 return "CAL_ERROR_INPROGRESS";
273#define CHECK_CAL(func) \
276 calError_t status = (func); \
277 if (status != CAL_OK) \
279 fprintf(stderr, "In File %s : CAL API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
280 _calGetErrorString(status), status); \
281 exit(EXIT_FAILURE); \
291#include <hip/hip_runtime.h>
292#include <hipblas/hipblas.h>
293#include <hipfft/hipfft.h>
294#include <hipsolver/hipsolver.h>
296static const char* _hipblasGetErrorString(hipblasStatus_t error)
300 case HIPBLAS_STATUS_SUCCESS:
301 return "HIPBLAS_STATUS_SUCCESS";
302 case HIPBLAS_STATUS_NOT_INITIALIZED:
303 return "HIPBLAS_STATUS_NOT_INITIALIZED";
304 case HIPBLAS_STATUS_ALLOC_FAILED:
305 return "HIPBLAS_STATUS_ALLOC_FAILED";
306 case HIPBLAS_STATUS_INVALID_VALUE:
307 return "HIPBLAS_STATUS_INVALID_VALUE";
308 case HIPBLAS_STATUS_ARCH_MISMATCH:
309 return "HIPBLAS_STATUS_ARCH_MISMATCH";
310 case HIPBLAS_STATUS_MAPPING_ERROR:
311 return "HIPBLAS_STATUS_MAPPING_ERROR";
312 case HIPBLAS_STATUS_EXECUTION_FAILED:
313 return "HIPBLAS_STATUS_EXECUTION_FAILED";
314 case HIPBLAS_STATUS_INTERNAL_ERROR:
315 return "HIPBLAS_STATUS_INTERNAL_ERROR";
316 case HIPBLAS_STATUS_NOT_SUPPORTED:
317 return "HIPBLAS_STATUS_NOT_SUPPORTED";
318 case HIPBLAS_STATUS_HANDLE_IS_NULLPTR:
319 return "HIPBLAS_STATUS_HANDLE_IS_NULLPTR";
325static const char* _hipfftGetErrorString(hipfftResult_t error)
330 return "HIPFFT_SUCCESS";
331 case HIPFFT_INVALID_PLAN:
332 return "HIPFFT_INVALID_PLAN";
333 case HIPFFT_ALLOC_FAILED:
334 return "HIPFFT_ALLOC_FAILED";
335 case HIPFFT_INVALID_TYPE:
336 return "HIPFFT_INVALID_TYPE";
337 case HIPFFT_INVALID_VALUE:
338 return "HIPFFT_INVALID_VALUE";
339 case HIPFFT_INTERNAL_ERROR:
340 return "HIPFFT_INTERNAL_ERROR";
341 case HIPFFT_EXEC_FAILED:
342 return "HIPFFT_EXEC_FAILED";
343 case HIPFFT_SETUP_FAILED:
344 return "HIPFFT_SETUP_FAILED";
345 case HIPFFT_INVALID_SIZE:
346 return "HIPFFT_INVALID_SIZE";
347 case HIPFFT_UNALIGNED_DATA:
348 return "HIPFFT_UNALIGNED_DATA";
349 case HIPFFT_INCOMPLETE_PARAMETER_LIST:
350 return "HIPFFT_INCOMPLETE_PARAMETER_LIST";
351 case HIPFFT_INVALID_DEVICE:
352 return "HIPFFT_INVALID_DEVICE";
353 case HIPFFT_PARSE_ERROR:
354 return "HIPFFT_PARSE_ERROR";
355 case HIPFFT_NO_WORKSPACE:
356 return "HIPFFT_NO_WORKSPACE";
357 case HIPFFT_NOT_IMPLEMENTED:
358 return "HIPFFT_NOT_IMPLEMENTED";
359 case HIPFFT_NOT_SUPPORTED:
360 return "HIPFFT_NOT_SUPPORTED";
366static const char* _hipsolverGetErrorString(hipsolverStatus_t error)
370 case HIPSOLVER_STATUS_SUCCESS:
371 return "HIPSOLVER_STATUS_SUCCESS";
372 case HIPSOLVER_STATUS_NOT_INITIALIZED:
373 return "HIPSOLVER_STATUS_NOT_INITIALIZED";
374 case HIPSOLVER_STATUS_ALLOC_FAILED:
375 return "HIPSOLVER_STATUS_ALLOC_FAILED";
376 case HIPSOLVER_STATUS_INVALID_VALUE:
377 return "HIPSOLVER_STATUS_INVALID_VALUE";
378 case HIPSOLVER_STATUS_MAPPING_ERROR:
379 return "HIPSOLVER_STATUS_MAPPING_ERROR";
380 case HIPSOLVER_STATUS_EXECUTION_FAILED:
381 return "HIPSOLVER_STATUS_EXECUTION_FAILED";
382 case HIPSOLVER_STATUS_INTERNAL_ERROR:
383 return "HIPSOLVER_STATUS_INTERNAL_ERROR";
384 case HIPSOLVER_STATUS_NOT_SUPPORTED:
385 return "HIPSOLVER_STATUS_NOT_SUPPORTED";
386 case HIPSOLVER_STATUS_ARCH_MISMATCH:
387 return "HIPSOLVER_STATUS_ARCH_MISMATCH";
388 case HIPSOLVER_STATUS_HANDLE_IS_NULLPTR:
389 return "HIPSOLVER_STATUS_HANDLE_IS_NULLPTR";
390 case HIPSOLVER_STATUS_INVALID_ENUM:
391 return "HIPSOLVER_STATUS_INVALID_ENUM";
392 case HIPSOLVER_STATUS_UNKNOWN:
393 return "HIPSOLVER_STATUS_UNKNOWN";
399#define CHECK_CUDA(func) \
402 hipError_t status = (func); \
403 if (status != hipSuccess) \
405 fprintf(stderr, "In File %s : HIP API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
406 hipGetErrorString(status), status); \
407 exit(EXIT_FAILURE); \
411#define CHECK_CUBLAS(func) \
414 hipblasStatus_t status = (func); \
415 if (status != HIPBLAS_STATUS_SUCCESS) \
417 fprintf(stderr, "In File %s : HIPBLAS API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
418 _hipblasGetErrorString(status), status); \
419 exit(EXIT_FAILURE); \
423#define CHECK_CUSOLVER(func) \
426 hipsolverStatus_t status = (func); \
427 if (status != HIPSOLVER_STATUS_SUCCESS) \
429 fprintf(stderr, "In File %s : HIPSOLVER API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
430 _hipsolverGetErrorString(status), status); \
431 exit(EXIT_FAILURE); \
435#define CHECK_CUFFT(func) \
438 hipfftResult_t status = (func); \
439 if (status != HIPFFT_SUCCESS) \
441 fprintf(stderr, "In File %s : HIPFFT API failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
442 _hipfftGetErrorString(status), status); \
443 exit(EXIT_FAILURE); \
447#define CHECK_LAST_CUDA_ERROR(msg) \
450 hipError_t status = hipGetLastError(); \
451 if (status != hipSuccess) \
453 fprintf(stderr, "%s(%d) : HIP error : %s : (%d) %s.\n", __FILE__, __LINE__, msg, \
454 static_cast<int>(status), hipGetErrorString(status)); \
455 exit(EXIT_FAILURE); \
460#define CHECK_CUDA_SYNC() \
463 hipError_t status = hipDeviceSynchronize(); \
464 if (status != hipSuccess) \
466 fprintf(stderr, "In File %s : HIP sync failed at line %d with error: %s (%d)\n", __FILE__, __LINE__, \
467 hipGetErrorString(status), status); \
468 exit(EXIT_FAILURE); \
472#define CHECK_CUDA_SYNC() do {} while (0)