We will now see how to use event objects with respect to streams; this will give us a highly intricate level of control over the flow of our various GPU operations, allowing us to know exactly how far each individual stream has progressed via the query function, and even allowing us to synchronize particular streams with the host while ignoring the other streams.
First, though, we have to realize this—each stream has to have its own dedicated collection of event objects; multiple streams cannot share an event object. Let's see what this means exactly by modifying the prior example, multi_kernel_streams.py. After the kernel definition, let's add two additional empty lists—start_events and end_events. We will fill these ...