Skip to content

Commit cee456f

Browse files
author
Diptorup Deb
committed
Add some new examples references in docs.
1 parent ddd5c6a commit cee456f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

examples/python/_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def run_examples(example_description, glbls_dict):
5555
print("Available examples:")
5656
print(", ".join(fns))
5757
else:
58-
print("No examples are availble.")
58+
print("No examples are available.")
5959
exit(0)
6060
if args.run == "all":
6161
fns = []

examples/python/device_selection.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ def create_device_with_aspects():
103103
dev.print_device_info()
104104

105105

106+
def list_devices():
107+
"""Programmatically get a list of the available devices.
108+
109+
The list can be filtered based on backend or device_type.
110+
"""
111+
print("Get a list of all devices:\n")
112+
113+
for d in dpctl.get_devices():
114+
d.print_device_info()
115+
print("=======================================\n")
116+
117+
print("Get the list of only OpenCL devices:\n")
118+
119+
for d in dpctl.get_devices(backend="opencl"):
120+
d.print_device_info()
121+
122+
print("=======================================\n")
123+
124+
print("Get all OpenCL CPU devices:\n")
125+
126+
for d in dpctl.get_devices(backend="opencl", device_type="cpu"):
127+
d.print_device_info()
128+
129+
print("=======================================\n")
130+
131+
106132
if __name__ == "__main__":
107133
import _runner as runner
108134

0 commit comments

Comments
 (0)