|
23 | 23 |
|
24 | 24 | print("Result computed by NumPy") |
25 | 25 | print(X.sum(axis=0)) |
26 | | -print("Result computed by SYCL extension using default offloading target") |
27 | | -print(sb.columnwise_total(X)) |
28 | 26 |
|
| 27 | +try: |
| 28 | + res = sb.columnwise_total(X) |
| 29 | + print("Result computed by SYCL extension using default offloading target") |
| 30 | + print(res) |
| 31 | +except dpctl.SyclQueueCreationError: |
| 32 | + print( |
| 33 | + "Could not create SyclQueue for default selected device. Nothing to do." |
| 34 | + ) |
| 35 | + exit(0) |
29 | 36 |
|
30 | 37 | print("") |
31 | 38 |
|
32 | 39 | # controlling where to offload |
33 | 40 |
|
34 | | -q = dpctl.SyclQueue("opencl:gpu") |
35 | | -print("Running on: ", q.sycl_device.name) |
36 | | -print(sb.columnwise_total(X, queue=q)) |
37 | | - |
38 | | -q = dpctl.SyclQueue("opencl:cpu") |
39 | | -print("Running on: ", q.sycl_device.name) |
40 | | -print(sb.columnwise_total(X, queue=q)) |
| 41 | +try: |
| 42 | + q = dpctl.SyclQueue("opencl:gpu") |
| 43 | + print("Running on: ", q.sycl_device.name) |
| 44 | + print(sb.columnwise_total(X, queue=q)) |
| 45 | +except dpctl.SyclQueueCreationError: |
| 46 | + print("Not running onf opencl:gpu, queue could not be created") |
| 47 | + |
| 48 | +try: |
| 49 | + q = dpctl.SyclQueue("opencl:cpu") |
| 50 | + print("Running on: ", q.sycl_device.name) |
| 51 | + print(sb.columnwise_total(X, queue=q)) |
| 52 | +except dpctl.SyclQueueCreationError: |
| 53 | + print("Not running onf opencl:cpu, queue could not be created") |
0 commit comments