CUDA is now the dominant language used for programming GPUs, one of the most exciting hardware developments of recent decades. With CUDA, you can use a desktop PC for work that would have previously required a large cluster of PCs or access to a HPC facility. As a result, CUDA is increasingly important in scientific and technical computing across the whole STEM community, from medical physics and financial modelling to big data applications and beyond. This unique book on CUDA draws on the author's passion for and long experience of developing and using computers to acquire and analyse scientific data. The result is an innovative text featuring a much richer set of examples than found in any other comparable book on GPU computing. Much attention has been paid to the C++ coding style, which is compact, elegant and efficient. A code base of examples and supporting material is available online, which readers can build on for their own projects.
A CUDA programming guide emphasizing practical examples and studying source code.
This book gives a general overview of GPU-based parallel computing and practical considerations when writing or optimizing code. It explores several common CUDA use cases such as image-processing, Monte Carlo simulations, and data analysis pipelines. Rather than focusing on theory or algorithms, it focuses on code. The author walks through many examples line-by-line, with explanations for why he wrote the code that way and what alternatives are worth considering. Throughout the book, the author emphasizes the hardware constraints that impact performance and how the code relates to what the GPU device is actually doing at the lowest level. He demonstrates practical methods for analyzing and comparing the performance of parallel algorithms for iterative optimization.
Where this book shines is in its discussions about why you might use various CUDA features, when they're worth while, and how to apply them effectively in specific common use cases. This is something I find to be lacking in the otherwise excellent official CUDA Programming Guide. It's extremely useful to see the author's process of deciding which optimizations to try and weighing the costs and benefits. There's also a fair amount of discussion about style choices and design patterns that make CUDA code more readable and less error-prone. I didn't always agree with the author's style, but his explanations made it obvious what details impact performance and which are just a matter of taste.
Not all of this book is relevant to everyone (especially the chapter on PET scanners), but it's easy to skip around and revisit topics as needed. One distracting shortcoming of the first edition hardcover is that it has lots of typos. Hopefully this will be corrected in future editions. That said, none of the errors I noticed were particularly problematic; it was generally pretty clear what the author meant.
This is a great book for an established C++ programmer who's transitioning from beginner to intermediate CUDA development. It makes an excellent complement to the official docs from Nvidia. By giving explanations, examples, and analysis in the context of realistic code, it makes the complicated and abstract ideas from the CUDA programming model much more tangible.
It's interesting to compare this book to CUDA Programming: A Developer's Guide to Parallel Computing with GPUs. That book starts with the assumption that CUDA is hard. Unless you learn the low-level details, think long and hard about design, and master all the tricks, you'll write bad code and waste much of what the GPU has to offer. In contrast, this book assumes that CUDA is easy, encouraging the reader to just start coding, pointing out gotchas and important performance optimizations along the way. Both of these perspectives are true, in a sense, and which is best for you depends on your needs. If you want to become a CUDA expert and squeeze every ounce of power out of your hardware, check out CUDA Programming. If you're working on a project and you want to try out making it faster by using GPUs, this book is the better choice.