Skip to content

Commit 4d92808

Browse files
Use try/catch to handle failure to create a queue
1 parent 7342189 commit 4d92808

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎examples/python/dppy_kernel.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ def dppy_gemm(a, b, c):
4444
b = np.array(np.random.random(X * X), dtype=np.float32).reshape(X, X)
4545
c = np.ones_like(a).reshape(X, X)
4646

47-
q = dpctl.SyclQueue("opencl:gpu", property="enable_profiling")
47+
try:
48+
q = dpctl.SyclQueue("opencl:gpu", property="enable_profiling")
49+
except dpctl.SyclQueueCreationError:
50+
print(
51+
"Skipping the example, as dpctl.SyclQueue targeting "
52+
"opencl:gpu device could not be created"
53+
)
54+
exit(0)
4855
timer = SyclTimer(time_scale=1)
4956
with dpctl.device_context(q):
5057
with timer(q):

0 commit comments

Comments
 (0)