title: What is the canonical way to check for errors using the CUDA runtime API?
body: <p>Looking through the answers and comments on CUDA questions, and in the <a href="https://stackoverflow.com/tags/cuda/info">CUDA tag wiki</a>, I see it is often suggested that the return status of every API call should checked for errors. The API documentation contains functions like <code>cudaGetLastError</code>, <code>cudaPeekAtLastError</code>, and <code>cudaGetErrorString</code>, but what is the best way to put these together to reliably catch and report errors without requiring lots of extra code?</p>