Skip to content

Commit 24d7caf

Browse files
Added test_sycl_timer
Times memcpy operation and a host computation
1 parent d7fec53 commit 24d7caf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dpctl/tests/test_sycl_event.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,20 @@ 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

0 commit comments

Comments
 (0)