Skip to content

Commit 8e44952

Browse files
Renamed create_sycl_queues to lsplatforms
1 parent e6270e4 commit 8e44952

File tree

3 files changed

+64
-77
lines changed

3 files changed

+64
-77
lines changed

examples/python/create_sycl_queues.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

examples/python/lsplatform.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Data Parallel Control (dpctl)
2+
#
3+
# Copyright 2020-2021 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""Demonstrates SYCL queue selection operations provided by dpctl.
18+
"""
19+
20+
import dpctl
21+
22+
23+
def print_available_platforms():
24+
"""
25+
Print information about SYCL platforms visible to runtime.
26+
27+
Environment variable `SYCL_DEVICE_FILTER` affects this list.
28+
"""
29+
dpctl.lsplatform()
30+
31+
32+
def list_available_platforms():
33+
"""
34+
Get a list of SyclPlatform instances corresponding to platforms
35+
visible to SYCL runtime.
36+
37+
Environment variable `SYCL_DEVICE_FILTER` affects this list.
38+
"""
39+
for p in dpctl.get_platforms():
40+
print(p)
41+
42+
43+
if __name__ == "__main__":
44+
import _runner as runner
45+
46+
runner.run_examples("", globals())

examples/python/sycl_queue.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,21 @@
1616

1717
import dpctl
1818

19+
1920
def create_default_queue():
20-
""" Create a queue from default selector.
21-
"""
21+
"""Create a queue from default selector."""
2222
q = dpctl.SyclQueue()
2323
# Queue is out-of-order by default
2424
print("Queue {} is in order: {}".format(q, q.is_in_order))
2525

2626

2727
def create_queue_from_filter_selector():
28-
""" Create queue for a GPU device or,
28+
"""Create queue for a GPU device or,
2929
if it is not available, for a CPU device.
3030
3131
Create in-order queue with profilign enabled.
3232
"""
33-
q = dpctl.SyclQueue(
34-
"gpu,cpu",
35-
property=("in_order", "enable_profiling")
36-
)
33+
q = dpctl.SyclQueue("gpu,cpu", property=("in_order", "enable_profiling"))
3734
print("Queue {} is in order: {}".format(q, q.is_in_order))
3835
# display the device used
3936
print("Device targeted by the queue:")
@@ -47,8 +44,10 @@ def create_queue_from_device():
4744
cpu_d = dpctl.SyclDevice("opencl:cpu:0")
4845
q = dpctl.SyclQueue(cpu_d, property="enable_profiling")
4946
assert q.sycl_device == cpu_d
50-
print("Number of devices in SyclContext "
51-
"associated with the queue: ", q.sycl_context.device_count)
47+
print(
48+
"Number of devices in SyclContext " "associated with the queue: ",
49+
q.sycl_context.device_count,
50+
)
5251

5352

5453
def create_queue_from_subdevice():
@@ -59,8 +58,10 @@ def create_queue_from_subdevice():
5958
sub_devs = cpu_d.create_sub_devices(partition=4)
6059
q = dpctl.SyclQueue(sub_devs[0])
6160
# a single-device context is created automatically
62-
print("Number of devices in SyclContext "
63-
"associated with the queue: ", q.sycl_context.device_count)
61+
print(
62+
"Number of devices in SyclContext " "associated with the queue: ",
63+
q.sycl_context.device_count,
64+
)
6465

6566

6667
def create_queue_from_subdevice_multidevice_context():
@@ -72,13 +73,13 @@ def create_queue_from_subdevice_multidevice_context():
7273
ctx = dpctl.SyclContext(sub_devs)
7374
q = dpctl.SyclQueue(ctx, sub_devs[0])
7475
# a single-device context is created automatically
75-
print("Number of devices in SyclContext "
76-
"associated with the queue: ", q.sycl_context.device_count)
76+
print(
77+
"Number of devices in SyclContext " "associated with the queue: ",
78+
q.sycl_context.device_count,
79+
)
7780

7881

7982
if __name__ == "__main__":
8083
import _runner as runner
81-
runner.run_examples(
82-
"Queue creation examples for dpctl.",
83-
globals()
84-
)
84+
85+
runner.run_examples("Queue creation examples for dpctl.", globals())

0 commit comments

Comments
 (0)