Synchronizing the current context

We're going to see how to explicitly synchronize our device within a context from within Python as in CUDA C; this is actually one of the most fundamental skills to know in CUDA C, and is covered in the first or second chapters in most other books on the topic. So far, we have been able to avoid this topic, since PyCUDA has performed most synchronizations for us automatically with pycuda.gpuarray functions such as to_gpu or get; otherwise, synchronization was handled by streams in the case of the to_gpu_async or get_async functions, as we saw at the beginning of this chapter.

We will be humble and start by modifying the program we wrote in Chapter 3, Getting Started with PyCUDA, which generates an image of ...

Get Hands-On GPU Programming with Python and CUDA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.