cudacheck¶
API documentation for cudacheck.h.
Error checking code for CUDA calls and kernels.
Defines
-
EXITERROR¶
trueUsed withinErrorCheck. If true, exit if an error is found
-
cudaErrorCheckCall(code)¶
Take a CUDA error message
code, and passes it ontoErrorCheckto check for errors. This can be wrapped around any call tocudaMalloc,cudaMemcpy, orcudaFree.Example usage:
float *d_array=NULL; int num_values=1e6; cudaErrorCheckCall( cudaMalloc( (void**)&(d_array), num_values*sizeof(float)) );
Uses
__FILE__and__LINE__to get file name and line number to pass on toErrorCheck- Parameters
code – [in] A
cudaError_tcode
-
cudaErrorCheckKernel(message, kernel, grid, threads, ...)¶
Takes a CUDA kernel, runs it with given arguments, and passes results onto
ErrorCheckto check for errors.All arguements need to run
kernelmust be included after the listed arguments here.kernelis then run viakernel <<< grid , threads, 0 >>>(__VA_ARGS__)
where
__VA_ARGS__passes on the arguments located at...cudaErrorCheckKernelthen passes the stringmessageon toErrorCheck, along with the file name and line number via__FILE__and__LINE__, and checks the errors from bothcudaGetLastError()andcudaDeviceSynchronize()after running the kernel.For example, if
fancy_kerneltakes the argumentsarg1andarg2, to run it with 10 grids of 64 threads, run the following:dim3 grid, threads; grid.x = 10 threads.x = 64 cudaErrorCheckKernel("Call to fancy_kernel", fancy_kernel, grid, threads, arg1, arg2);
- Parameters
message – [in] Message to report when an error occurs
kernel – [in] Name of kernel to be run
grid – [in] A
dim3containing grid specifications to runkernelwiththreads – [in] A
dim3containing thread specifications to runkernelwith... – [in] All arguments to be passed into
kernel
Functions
-
inline void ErrorCheck(const char *message, cudaError_t code, const char *file, int line, bool abort = EXITERROR)¶
Take a CUDA error message (code), and checks whether an error occurred.
If an error happened, uses
messageto give more information to the user, along with the decoded CUDA error message. Usesfileandlineto report where the error happened. Optional boolabortmeans you can switch off exiting if an error is found (default true)- Parameters
message – [in] User supplied error message
code – [in] Error message out of CUDA call (e.g. cudaMalloc)
file – [in] Name of file call was made in
line – [in] Line of file call was made in
abort – [in] If true, exit the CUDA code when an error is found