-
Notifications
You must be signed in to change notification settings - Fork 57
fix: extract handle value in Event.query() call to match other driver calls #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
55d484a
b698a5d
876c90f
93e7577
0951c7c
dc4fb1a
f6d3c59
ddbb792
ce8c81a
1e92818
c24fc42
8138622
138411e
1175800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| # SPDX-License-Identifier: BSD-2-Clause | ||
|
|
||
| import numpy as np | ||
| from numba import cuda | ||
| from numba import cuda, int32 | ||
| from numba.cuda.testing import unittest, CUDATestCase | ||
| from numba.cuda._compat import Device | ||
| from numba.cuda.testing import skip_on_cudasim | ||
|
|
@@ -48,6 +48,41 @@ def event_elapsed_inner(self, stream): | |
| # Exercise the code path | ||
| evtstart.elapsed_time(evtend) | ||
|
|
||
| def test_event_query(self): | ||
| from time import perf_counter | ||
|
|
||
| @cuda.jit | ||
| def spin(ms): | ||
| # Sleep for ms | ||
| for i in range(ms): | ||
| cuda.nanosleep(int32(1_000_000)) # 1 ms | ||
|
|
||
| stream = cuda.stream() | ||
| evt = cuda.event() | ||
|
|
||
| # Run once to compile | ||
| spin[1, 1, stream](1) | ||
|
|
||
| t0 = perf_counter() | ||
| spin_ms = 250 | ||
| spin[1, 1, stream](250) | ||
| evt.record(stream) | ||
|
|
||
| # Query immediately. | ||
| event_time = perf_counter() - t0 | ||
| while not evt.query(): | ||
| event_time = perf_counter() - t0 | ||
cpcloud marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Synchronize and capture stream-finished time. | ||
| evt.synchronize() | ||
| sync_time = perf_counter() - t0 | ||
|
|
||
| # If this assertion fails, it was nanosleep inaccuracy that caused it | ||
| assert sync_time * 1000 > spin_ms * 0.9 | ||
|
|
||
| # If this assertion fails, the event query returned early | ||
| assert event_time * 1000 > spin_ms * 0.9 | ||
|
||
|
|
||
|
|
||
kkraus14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Uh oh!
There was an error while loading. Please reload this page.