A final class that represents CUDA exceptions, inheriting from std::runtime_error.
More...
A final class that represents CUDA exceptions, inheriting from std::runtime_error.
This class is designed to handle and provide detailed information about CUDA-related errors. It captures the file, line number, CUDA error code, and the expression that caused the error. By overriding the what()
method, it can return a formatted error message with all these details.
Type Definitions:
Key Features:
- Error Information Capture: Records the file, line number, CUDA error code, and the expression where the error occurred.
- Formatted Error Message: Generates a detailed and human - readable error message that includes all the captured information.
Usage Example:
#include <iostream>
#include <cuda_runtime.h>
};
void someCudaFunction() {
cudaError_t err = cudaMalloc(nullptr, 1024);
if (err!= cudaSuccess) {
throw CudaException(__FILE__, __LINE__, err,
"cudaMalloc(nullptr, 1024)");
}
}
int main() {
try {
someCudaFunction();
} catch (const CudaException& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
A final class that represents CUDA exceptions, inheriting from std::runtime_error.
- Note
- Ensure that the buffer size of 1024 characters is sufficient for the error message. If the message exceeds this size, it will be truncated.
- The
format_message()
method should be called during object construction to ensure the error message is properly formatted.
- Author
- Mgepahmge(https://github.com/Mgepahmge)
- Date
- 2024/07/24
Definition at line 62 of file NeuZephyrCudaErrorHandling.cuh.