How to Query Device Properties and Handle Errors in CUDA C/C++

Originally published at: https://developer.nvidia.com/blog/how-query-device-properties-and-handle-errors-cuda-cc/

In this third post of the CUDA C/C++ series we discuss various characteristics of the wide range of CUDA-capable GPUs, how to query device properties from within a CUDA C/C++ program, and how to handle errors. Querying Device Properties In our last post, about performance metrics, we discussed how to compute the theoretical peak bandwidth of a…

Nice explanation Mark! Thanks for share with us.

I would like to explain how to deal with errors and free memory allocated device.
A common practice in many CUDA examples is a macro that check error and call exit(-1); in that case. But... what about free allocated memory?

There is some method to free all allocated memory from current application before exit?

This will be a nice topic for a Part-II of this explanation.
Thanks!

Thanks for reading! The CUDA examples are not meant to be professional applications. A professional application would of course correctly manage memory and free allocations at exit, rather than just exiting directly. But there are many ways to manage memory and many opinions on best practices. Properly cleaning up your application is a standard programming practice and is not GPU- or parallel programming-specific, and therefore I consider it outside the scope of this article / blog.

FYI: helpful.