Created
October 1, 2021 15:37
-
-
Save gmarkall/a5579a813f2d16ec36e8d7cb9c6b3d02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterating | |
Stream <CUDA stream 93950825260944 on <CUDA context c_void_p(93950819544272) of device 0>> done | |
Stream <CUDA stream 93950825975488 on <CUDA context c_void_p(93950819544272) of device 0>> done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterating | |
Stream <CUDA stream 94405088815088 on <CUDA context c_void_p(94405082385552) of device 0>> done | |
Iterating | |
Stream <CUDA stream 94405088101008 on <CUDA context c_void_p(94405082385552) of device 0>> done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba import cuda | |
import asyncio | |
async def f(): | |
s1 = cuda.stream() | |
s2 = cuda.stream() | |
f1 = s1.async_done() | |
f2 = s2.async_done() | |
f_to_s = {f1: s1, f2: s2} | |
futures_pending = True | |
pending = set((f1, f2)) | |
while futures_pending: | |
print("Iterating") | |
done, pending = await asyncio.wait(pending, | |
return_when=asyncio.FIRST_COMPLETED) | |
for d in done: | |
print(f"Stream {f_to_s[d]} done") | |
futures_pending = bool(pending) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(f()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment