2781a48c
David Mayerich
fixed cuBLAS func...
|
1
2
3
|
#ifndef STIM_CUDA_ERROR_H
#define STIM_CUDA_ERROR_H
|
0174d823
dmayerich
bug fixes and exits
|
4
5
|
#include <stdio.h>
#include <iostream>
|
3eb12494
David Mayerich
removed CUDA depe...
|
6
|
#include "cuda_runtime.h"
|
6e257ab3
dmayerich
ENVI and colormap...
|
7
|
#include "device_launch_parameters.h"
|
3eb12494
David Mayerich
removed CUDA depe...
|
8
|
#include "cufft.h"
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
9
|
#include "cublas_v2.h"
|
3eb12494
David Mayerich
removed CUDA depe...
|
10
11
|
//handle error macro
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
12
|
static void cuHandleError( cudaError_t err, const char *file, int line ) {
|
3eb12494
David Mayerich
removed CUDA depe...
|
13
|
if (err != cudaSuccess) {
|
3eb12494
David Mayerich
removed CUDA depe...
|
14
|
printf("%s in %s at line %d\n", cudaGetErrorString( err ), file, line );
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
15
|
|
3eb12494
David Mayerich
removed CUDA depe...
|
16
17
|
}
}
|
a8d6edd6
Mahsa Lotfollahi
added the definit...
|
18
|
#define HANDLE_ERROR( err ) (cuHandleError( err, __FILE__, __LINE__ ))
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
19
|
static void cufftHandleError( cufftResult err, const char*file, int line )
|
6e257ab3
dmayerich
ENVI and colormap...
|
20
21
22
23
|
{
if (err != CUFFT_SUCCESS)
{
if(err == CUFFT_INVALID_PLAN)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
24
|
std::cout<<"The plan parameter is not a valid handle."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
25
|
else if(err == CUFFT_ALLOC_FAILED)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
26
|
std::cout<<"Allocation failed."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
27
|
else if(err == CUFFT_INVALID_VALUE)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
28
|
std::cout<<"At least one of the parameters idata, odata, and direction is not valid."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
29
|
else if(err == CUFFT_INTERNAL_ERROR)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
30
|
std::cout<<"An internal driver error was detected."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
31
|
else if(err == CUFFT_EXEC_FAILED)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
32
|
std::cout<<"CUFFT failed to execute the transform on the GPU."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
33
|
else if(err == CUFFT_SETUP_FAILED)
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
34
|
std::cout<<"The CUFFT library failed to initialize."<<std::endl;
|
0174d823
dmayerich
bug fixes and exits
|
35
|
else
|
42210bc0
Mahsa Lotfollahi
Removed using nam...
|
36
|
std::cout<<"Unknown error: "<<err<<std::endl;
|
6e257ab3
dmayerich
ENVI and colormap...
|
37
38
|
}
|
3eb12494
David Mayerich
removed CUDA depe...
|
39
|
}
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
40
|
#define CUFFT_HANDLE_ERROR( err ) (cufftHandleError( err, __FILE__, __LINE__ ))
|
3eb12494
David Mayerich
removed CUDA depe...
|
41
|
|
2781a48c
David Mayerich
fixed cuBLAS func...
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
static void cublasHandleError( cublasStatus_t err, const char*file, int line ){
if(err != CUBLAS_STATUS_SUCCESS){
if(err == CUBLAS_STATUS_NOT_INITIALIZED)
std::cout<<"CUBLAS_STATUS_NOT_INITIALIZED" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_ALLOC_FAILED)
std::cout<<"CUBLAS_STATUS_ALLOC_FAILED" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_INVALID_VALUE)
std::cout<<"CUBLAS_STATUS_INVALID_VALUE" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_ARCH_MISMATCH)
std::cout<<"CUBLAS_STATUS_ARCH_MISMATCH" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_MAPPING_ERROR)
std::cout<<"CUBLAS_STATUS_MAPPING_ERROR" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_EXECUTION_FAILED)
std::cout<<"CUBLAS_STATUS_EXECUTION_FAILED" <<" in file "<<file<<" line "<<std::endl;
else if(err == CUBLAS_STATUS_INTERNAL_ERROR)
std::cout<<"CUBLAS_STATUS_INTERNAL_ERROR" <<" in file "<<file<<" line "<<std::endl;
else
std::cout<<"Unknown error"<<" in file "<<file<<" line "<<std::endl;
}
}
#define CUBLAS_HANDLE_ERROR( err ) (cublasHandleError( err, __FILE__, __LINE__ ))
|
3eb12494
David Mayerich
removed CUDA depe...
|
63
64
|
|
f1402849
dmayerich
renewed commit
|
65
|
#endif
|