|
12 | 12 | import pytest |
13 | 13 |
|
14 | 14 | import cuda.core.experimental |
15 | | -from cuda.core.experimental import Device, EventOptions |
| 15 | +from cuda.core.experimental import Device, EventOptions, LaunchConfig, Program, ProgramOptions, launch |
16 | 16 |
|
17 | 17 |
|
18 | 18 | def test_event_init_disabled(): |
@@ -116,14 +116,32 @@ def test_error_timing_recorded(): |
116 | 116 | def test_error_timing_incomplete(): |
117 | 117 | device = Device() |
118 | 118 | device.set_current() |
| 119 | + |
| 120 | + # This kernel is designed to not complete |
| 121 | + code = """ |
| 122 | +extern "C" |
| 123 | +__global__ void wait() { |
| 124 | + while (1 > 0) { |
| 125 | + } |
| 126 | +} |
| 127 | +""" |
| 128 | + |
| 129 | + arch = "".join(f"{i}" for i in device.compute_capability) |
| 130 | + program_options = ProgramOptions(std="c++11", arch=f"sm_{arch}") |
| 131 | + prog = Program(code, code_type="c++", options=program_options) |
| 132 | + mod = prog.compile(target_type="cubin") |
| 133 | + ker = mod.get_kernel("wait") |
| 134 | + |
| 135 | + config = LaunchConfig(grid=1, block=1) |
| 136 | + ker_args = () |
| 137 | + |
119 | 138 | enabled = EventOptions(enable_timing=True) |
120 | 139 | stream = device.create_stream() |
121 | 140 |
|
122 | 141 | event1 = stream.record(options=enabled) |
123 | | - event2 = device.create_event(options=enabled) |
124 | | - stream.wait(event2) |
| 142 | + launch(stream, config, ker, *ker_args) |
125 | 143 | event3 = stream.record(options=enabled) |
126 | 144 |
|
127 | | - # event3 will never complete because the stream is waiting on event2 which is never recorded |
| 145 | + # event3 will never complete because the stream is waiting on wait() to complete |
128 | 146 | with pytest.raises(RuntimeError, match="^One or both events have not completed."): |
129 | 147 | event3 - event1 |
0 commit comments