Last active
August 27, 2022 02:39
-
-
Save enp1s0/f74c3201143b549b5467c6139d06f357 to your computer and use it in GitHub Desktop.
cuda_check_error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sstream> | |
#include <stdexcept> | |
inline void cuda_check_error(cudaError_t error, const std::string filename, const std::size_t line, const std::string funcname, const std::string message = ""){ | |
if(error != cudaSuccess){ | |
std::stringstream ss; | |
ss << cudaGetErrorString( error ); | |
if(message.length() != 0){ | |
ss << " : " << message; | |
} | |
ss << " [" << filename << ":" << line << " in " << funcname << "]"; | |
throw std::runtime_error(ss.str()); | |
} | |
} | |
#ifndef CUDA_CHECK_ERROR | |
#define CUDA_CHECK_ERROR(status) cuda_check_error(status, __FILE__, __LINE__, __func__) | |
#endif | |
#ifndef CUDA_CHECK_ERROR_M | |
#define CUDA_CHECK_ERROR_M(status, message) cuda_check_error(status, __FILE__, __LINE__, __func__, message) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment