improved cuda error checking

This commit is contained in:
2025-01-06 13:18:19 +01:00
parent edf4d9fd60
commit 04defb563f
5 changed files with 46 additions and 88 deletions

13
src/cuda_error.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "cuda_error.h"
#include "cuda_runtime.h"
#include <iostream>
void check_cuda(cudaError_t res, char const* const func, const char* const file, int const line) {
if (res) {
std::cout << "CUDA encountered an error: " << cudaGetErrorString(res) << " in " << file << ":" << line << std::endl;
cudaDeviceReset();
exit(1);
}
}