isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Error.h
1 #pragma once
2 
3 #include <isce3/except/Error.h>
4 #include <cufft.h>
5 
6 namespace isce3 { namespace cuda { namespace except {
7 
8  using namespace isce3::except;
9 
12  template<class T>
14  const T err;
15  CudaError(const SrcInfo& info, const T err);
16  };
17 
18  // Instantiate the for when the error code is a cudaError_t
19  // In this case can get a useful error message via cudaGetErrorString
20  template<>
21  CudaError<cudaError_t>::CudaError(const SrcInfo& info, const cudaError_t err);
22 
23  template<>
24  CudaError<cufftResult>::CudaError(const SrcInfo& info, const cufftResult err);
25 
26  template<class T>
27  CudaError<T>::CudaError(const SrcInfo& info, const T err) :
28  err(err),
29  RuntimeError(info, std::string("cudaError ") + std::to_string(err)) {}
30 
31 }}}
32 
33 template<class T>
34 static inline void checkCudaErrorsImpl(const isce3::except::SrcInfo& info, T err) {
35  if (err)
36  throw isce3::cuda::except::CudaError<T>(info, err);
37 }
38 
39 /* Explicit instantiation for cufft calls,
40  * since we need to compare against cufftResult */
41 template<>
42 inline void checkCudaErrorsImpl<cufftResult>(
43  const isce3::except::SrcInfo& info, cufftResult err) {
44  if (err != CUFFT_SUCCESS)
46 }
47 
48 // Check errors from kernel launches and, if NDEBUG is not defined,
49 // synchronize and check for execution errors
50 inline
51 void checkCudaAsyncErrorsImpl(const isce3::except::SrcInfo & info)
52 {
53  checkCudaErrorsImpl(info, cudaPeekAtLastError());
54 #ifndef NDEBUG
55  checkCudaErrorsImpl(info, cudaDeviceSynchronize());
56 #endif
57 }
58 
59 // Wrapper to pass file name, line number, and function name
60 #define checkCudaErrors(val) checkCudaErrorsImpl(ISCE_SRCINFO(), val)
61 
62 // Wrapper to pass file name, line number, and function name
63 #define checkCudaAsyncErrors() checkCudaAsyncErrorsImpl(ISCE_SRCINFO())
CudaError provide the same information as BaseError, and also retains the original error code...
Definition: Error.h:13
Definition: Error.h:21
Definition: Error.h:10

Generated for ISCE3.0 by doxygen 1.8.5.