Blame view

stim/cuda/cudatools/error.h 1.5 KB
0174d823   dmayerich   bug fixes and exits
1
2
  #include <stdio.h>
  #include <iostream>
3eb12494   David Mayerich   removed CUDA depe...
3
4
  using namespace std;
  #include "cuda_runtime.h"
6e257ab3   dmayerich   ENVI and colormap...
5
  #include "device_launch_parameters.h"
3eb12494   David Mayerich   removed CUDA depe...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include "cufft.h"
  
  #ifndef CUDA_HANDLE_ERROR_H
  #define CUDA_HANDLE_ERROR_H
  
  //handle error macro
  static void HandleError( cudaError_t err, const char *file,  int line ) {
     	if (err != cudaSuccess) {
  			//FILE* outfile = fopen("cudaErrorLog.txt", "w");
        		//fprintf(outfile,  "%s in %s at line %d\n", cudaGetErrorString( err ),  file, line );
  			//fclose(outfile);
              printf("%s in %s at line %d\n", cudaGetErrorString( err ),  file, line );
         		//exit( EXIT_FAILURE );
  
     	}
  }
6e257ab3   dmayerich   ENVI and colormap...
22
23
24
25
26
27
28
  #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
  
  static void CufftError( cufftResult err )
  {
      if (err != CUFFT_SUCCESS)
      {
          if(err == CUFFT_INVALID_PLAN)
0174d823   dmayerich   bug fixes and exits
29
30
31
32
33
34
35
36
37
38
39
40
41
              cout<<"The plan parameter is not a valid handle."<<endl;
          else if(err == CUFFT_ALLOC_FAILED)
              cout<<"Allocation failed."<<endl;
          else if(err == CUFFT_INVALID_VALUE)
              cout<<"At least one of the parameters idata, odata, and direction is not valid."<<endl;
          else if(err == CUFFT_INTERNAL_ERROR)
              cout<<"An internal driver error was detected."<<endl;
          else if(err == CUFFT_EXEC_FAILED)
              cout<<"CUFFT failed to execute the transform on the GPU."<<endl;
          else if(err == CUFFT_SETUP_FAILED)
              cout<<"The CUFFT library failed to initialize."<<endl;
          else
              cout<<"Unknown error: "<<err<<endl;
6e257ab3   dmayerich   ENVI and colormap...
42
43
  
      }
3eb12494   David Mayerich   removed CUDA depe...
44
45
46
47
  }
  
  
  
f1402849   dmayerich   renewed commit
48
  #endif