gpufilter
GPU-Efficient Recursive Filtering and Summed-Area Tables
include/error.h
Go to the documentation of this file.
00001 
00008 #ifndef ERROR_H
00009 #define ERROR_H
00010 
00011 //== INCLUDES =================================================================
00012 
00013 #include <sstream>
00014 #include <iostream>
00015 #include <stdexcept>
00016 
00017 #include <cuda_runtime.h>
00018 
00019 //== NAMESPACES ===============================================================
00020 
00021 namespace gpufilter {
00022 
00023 //== IMPLEMENTATION ===========================================================
00024 
00033 inline void cuda_error( const std::string &msg ) {
00034     cudaError_t err = cudaGetLastError();
00035     if( err != cudaSuccess ) {
00036         if( msg.empty() )
00037             throw std::runtime_error(cudaGetErrorString(err));
00038         else {
00039             std::stringstream ss;
00040             ss << msg << ": " << cudaGetErrorString(err);
00041             throw std::runtime_error(ss.str().c_str());
00042         }
00043     }
00044 }
00045 
00046 //=============================================================================
00047 } // namespace gpufilter
00048 //=============================================================================
00049 #endif // ERROR_H
00050 //=============================================================================
00051 //vi: ai sw=4 ts=4