Skip to content

Commit 62db871

Browse files
saiyambhararajpascucci-nv
authored andcommitted
test(cuda.core): check the event-record target after the graph completes
Signed-off-by: Saiyam Bharara <[email protected]>
1 parent 448dac4 commit 62db871

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

‎cuda_core/tests/graph/test_graph_node_update.py‎

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pytest
1515
from helpers.graph_kernels import compile_common_kernels
1616

17-
from cuda.core import Device, DeviceMemoryResource, LaunchConfig, LegacyPinnedMemoryResource
17+
from cuda.core import Device, DeviceMemoryResource, EventOptions, LaunchConfig, LegacyPinnedMemoryResource
1818
from cuda.core._memory._synchronous_memory_resource import _SynchronousMemoryResource
1919
from cuda.core._utils._weak_handles import weak_handle
2020
from cuda.core._utils.cuda_utils import CUDAError, driver, handle_return
@@ -96,36 +96,27 @@ def _update_executable_case(graph, case):
9696

9797

9898
def _event_record_case(device):
99-
"""Keep the selected event pending to identify each exec's record target."""
100-
original = device.create_event()
101-
replacement = device.create_event()
102-
invalid_replacement = device.create_event()
99+
"""Identify each exec's record target after completion."""
100+
event_options = EventOptions(timing_enabled=True)
101+
original = device.create_event(options=event_options)
102+
replacement = device.create_event(options=event_options)
103+
invalid_replacement = device.create_event(options=event_options)
103104
invalid_replacement.close()
104105

105-
callback_started = threading.Event()
106-
callback_release = threading.Event()
107-
108-
def blocking_callback():
109-
callback_started.set()
110-
callback_release.wait(timeout=30)
111-
112106
graph_def = GraphDefinition()
113-
callback_node = graph_def.callback(blocking_callback)
114-
node = callback_node.record(original)
107+
node = graph_def.record(original)
115108

116109
def assert_exec_uses(graph, expected):
117-
callback_started.clear()
118-
callback_release.clear()
119110
stream = device.create_stream()
111+
reference = stream.record(options=event_options)
112+
stream.sync()
113+
114+
with pytest.raises(RuntimeError, match=r"^Both Events must be recorded"):
115+
expected - reference
116+
120117
graph.launch(stream)
121-
try:
122-
assert callback_started.wait(timeout=5)
123-
_wait_until(lambda: expected.is_done is False)
124-
unexpected = replacement if expected is original else original
125-
assert unexpected.is_done is True
126-
finally:
127-
callback_release.set()
128-
stream.sync()
118+
stream.sync()
119+
assert isinstance(expected - reference, float)
129120

130121
return _DefinitionUpdateCase(
131122
graph_def=graph_def,

0 commit comments

Comments
 (0)