Skip to content

Commit 90ebdb7

Browse files
Added test_sycl_timer
Times memcpy operation and a host computation
1 parent d7fec53 commit 90ebdb7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dpctl/tests/test_sycl_event.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,26 @@ def test_profiling_info():
157157
assert event.profiling_info_end
158158
else:
159159
pytest.skip("No OpenCL CPU queues available")
160+
161+
162+
def test_sycl_timer():
163+
try:
164+
q = dpctl.SyclQueue(property="enable_profiling")
165+
except dpctl.SyclQueueCreationError:
166+
pytest.skip("Queue creation of default device failed")
167+
timer = dpctl.SyclTimer()
168+
m1 = dpctl_mem.MemoryUSMDevice(256 * 1024, queue=q)
169+
m2 = dpctl_mem.MemoryUSMDevice(256 * 1024, queue=q)
170+
with timer(q):
171+
# device task
172+
m1.copy_from_device(m2)
173+
# host task
174+
[x ** 2 for x in range(1024)]
175+
host_dt, device_dt = timer.dt
176+
assert host_dt > device_dt
177+
q_no_profiling = dpctl.SyclQueue()
178+
assert q_no_profiling.has_enable_profiling is False
179+
with pytest.raises(ValueError):
180+
timer(queue=q_no_profiling)
181+
with pytest.raises(TypeError):
182+
timer(queue=None)

0 commit comments

Comments
 (0)