libcuproj
24.02.00
|
#include <cuproj/assert.cuh>
#include <cuda_runtime_api.h>
#include <stdexcept>
#include <string>
Go to the source code of this file.
Classes | |
struct | cuproj::logic_error |
Exception thrown when logical precondition is violated. More... | |
struct | cuproj::cuda_error |
Exception thrown when a CUDA error is encountered. More... | |
Macros | |
#define | CUPROJ_STRINGIFY_DETAIL(x) #x |
#define | CUPROJ_STRINGIFY(x) CUPROJ_STRINGIFY_DETAIL(x) |
#define | CUPROJ_EXPECTS(cond, reason) |
Macro for checking (pre-)conditions that throws an exception when a condition is violated. | |
#define | CUPROJ_HOST_DEVICE_EXPECTS(cond, reason) CUPROJ_EXPECTS(cond, reason) |
Macro for checking (pre-)conditions that throws an exception when a condition is violated. | |
#define | CUPROJ_FAIL(reason) |
Indicates that an erroneous code path has been taken. | |
#define | CUPROJ_CUDA_TRY(call) |
Error checking macro for CUDA runtime API functions. | |
#define | CUPROJ_CHECK_CUDA(stream) |
Debug macro to check for CUDA errors. | |
Functions | |
void | cuproj::detail::throw_cuda_error (cudaError_t error, const char *file, unsigned int line) |
#define CUPROJ_CHECK_CUDA | ( | stream | ) |
Debug macro to check for CUDA errors.
In a non-release build, this macro will synchronize the specified stream before error checking. In both release and non-release builds, this macro checks for any pending CUDA errors from previous calls. If an error is reported, an exception is thrown detailing the CUDA error that occurred.
The intent of this macro is to provide a mechanism for synchronous and deterministic execution for debugging asynchronous CUDA execution. It should be used after any asynchronous CUDA call, e.g., cudaMemcpyAsync, or an asynchronous kernel launch.
#define CUPROJ_CUDA_TRY | ( | call | ) |
Error checking macro for CUDA runtime API functions.
Invokes a CUDA runtime API function call, if the call does not return cudaSuccess, invokes cudaGetLastError() to clear the error and throws an exception detailing the CUDA error that occurred
#define CUPROJ_EXPECTS | ( | cond, | |
reason ) |
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Example usage:
[in] | cond | Expression that evaluates to true or false |
[in] | reason | String literal description of the reason that cond is expected to be true |
cuproj::logic_error | if the condition evaluates to false. |
#define CUPROJ_FAIL | ( | reason | ) |
Indicates that an erroneous code path has been taken.
In host code, throws a cuproj::logic_error
.
Example usage:
[in] | reason | String literal description of the reason |
#define CUPROJ_HOST_DEVICE_EXPECTS | ( | cond, | |
reason ) CUPROJ_EXPECTS(cond, reason) |
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Example usage:
[in] | cond | Expression that evaluates to true or false |
[in] | reason | String literal description of the reason that cond is expected to be true |
(if on host)
cuproj::logic_error | if the condition evaluates to false. (if on device) program terminates and assertion error message is printed to stderr. |