Such at the code can return the last error that has been produced by any of the runtime calls in the same host thread and resets it to cudaSuccess. https://www.cs.cmu.edu/afs/cs/academic/class/15668-s11/www/cuda-doc/html/group__CUDART__ERROR_g0a933755a73d874d0d7051a3eb2aa533.html If not, very subsequent cudaCheckLastError() will get a failure message. `cudaError_t mallocBest ( void **devPtr, size_t size ) { ``` cudaError_t returnVal = cudaSuccess; if (cudaMalloc(devPtr, size) != cudaSuccess) { cudaGetLastError(); } ``` }`
Such at the code can return the last error that has been produced by any of the runtime calls in the same host thread and resets it to cudaSuccess.
https://www.cs.cmu.edu/afs/cs/academic/class/15668-s11/www/cuda-doc/html/group__CUDART__ERROR_g0a933755a73d874d0d7051a3eb2aa533.html
If not, very subsequent cudaCheckLastError() will get a failure message.
`cudaError_t mallocBest ( void **devPtr, size_t size ) {
}`