MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / clearPossibleCudaError

Function clearPossibleCudaError

quest/src/gpu/gpu_config.cpp:68–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void clearPossibleCudaError() {
69
70 // beware that in addition to clearing anticipated CUDA errors (like
71 // cudaMalloc failing), this function will check that the CUDA API is
72 // generally working (i.e. has not encountered an irrecoverable error),
73 // including whether e.g. the CUDA drivers match the runtime version. It
74 // should ergo never be called in settings where GPU is compiled but not
75 // runtime activated, since such settings see CUDA be in an acceptably
76 // broken state - calling this function would throw an internal error
77
78 // clear "non-sticky" errors so that future CUDA API use is not corrupted
79 cudaError_t initialCode = cudaGetLastError();
80
81 // nothing to do if no error had occurred
82 if (initialCode == cudaSuccess)
83 return;
84
85 // sync and re-check if error code is erroneously unchanged, which
86 // indicates that CUDA encountered an irrecoverable "sticky" error
87 CUDA_CHECK( cudaDeviceSynchronize() );
88
89 cudaError_t finalCode = cudaGetLastError();
90 if (initialCode == finalCode)
91 error_cudaEncounteredIrrecoverableError();
92}
93
94#endif
95

Callers 1

gpu_allocArrayFunction · 0.85

Tested by

no test coverage detected