Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On GPU Programming with Python and CUDA

You're reading from  Hands-On GPU Programming with Python and CUDA

Product type Book
Published in Nov 2018
Publisher Packt
ISBN-13 9781788993913
Pages 310 pages
Edition 1st Edition
Languages
Author (1):
Dr. Brian Tuomanen Dr. Brian Tuomanen
Profile icon Dr. Brian Tuomanen

Table of Contents (15) Chapters

Preface 1. Why GPU Programming? 2. Setting Up Your GPU Programming Environment 3. Getting Started with PyCUDA 4. Kernels, Threads, Blocks, and Grids 5. Streams, Events, Contexts, and Concurrency 6. Debugging and Profiling Your CUDA Code 7. Using the CUDA Libraries with Scikit-CUDA 8. The CUDA Device Function Libraries and Thrust 9. Implementation of a Deep Neural Network 10. Working with Compiled GPU Code 11. Performance Optimization in CUDA 12. Where to Go from Here 13. Assessment 14. Other Books You May Enjoy

The CUDA Thrust library

We will now look at the CUDA Thrust Library. This library's central feature is a high-level vector container that is similar C++'s own vector container. While this may sound trivial, this will allow us to program in CUDA C with less reliance on pointers, mallocs, and frees. Like the C++ vector container, Thrust's vector container handles the resizing and concatenation of elements automatically, and with the magic of C++ destructors, freeing is also handled automatically when a Thrust vector object goes out of scope.

Thrust actually provides two vector containers: one for the host-side, and one for the device-side. The host-side Thrust vector is more or less identical to the STL vector, with the main difference being that it can interact more easily with the GPU. Let's write a little bit of code in proper CUDA C to get a feel for how...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}