Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
94 lines (79 loc) · 2.96 KB

File metadata and controls

94 lines (79 loc) · 2.96 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Data Parallel Control (dpctl)
#
# Copyright 2020-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import dpctl
def create_default_queue():
"""Create a queue from default selector."""
q = dpctl.SyclQueue()
# Queue is out-of-order by default
print("Queue {} is in order: {}".format(q, q.is_in_order))
def create_queue_from_filter_selector():
"""Create queue for a GPU device or,
if it is not available, for a CPU device.
Create in-order queue with profiling enabled.
"""
q = dpctl.SyclQueue("gpu,cpu", property=("in_order", "enable_profiling"))
print("Queue {} is in order: {}".format(q, q.is_in_order))
# display the device used
print("Device targeted by the queue:")
q.sycl_device.print_device_info()
def create_queue_from_device():
"""
Create a queue from SyclDevice instance.
"""
cpu_d = dpctl.SyclDevice("opencl:cpu:0")
q = dpctl.SyclQueue(cpu_d, property="enable_profiling")
assert q.sycl_device == cpu_d
print(
"Number of devices in SyclContext " "associated with the queue: ",
q.sycl_context.device_count,
)
def create_queue_from_subdevice():
"""
Create a queue from a sub-device.
"""
cpu_d = dpctl.SyclDevice("opencl:cpu:0")
try:
sub_devs = cpu_d.create_sub_devices(partition=2)
except dpctl.SyclSubDeviceCreationError:
print("Could not create sub device.")
print(f"{cpu_d} has {cpu_d.max_compute_units} compute units")
return
q = dpctl.SyclQueue(sub_devs[0])
# a single-device context is created automatically
print(
"Number of devices in SyclContext " "associated with the queue: ",
q.sycl_context.device_count,
)
def create_queue_from_subdevice_multidevice_context():
"""
Create a queue from a sub-device.
"""
cpu_d = dpctl.SyclDevice("opencl:cpu:0")
try:
sub_devs = cpu_d.create_sub_devices(partition=2)
except dpctl.SyclSubDeviceCreationError:
print("Could not create sub device.")
print(f"{cpu_d} has {cpu_d.max_compute_units} compute units")
return
ctx = dpctl.SyclContext(sub_devs)
q = dpctl.SyclQueue(ctx, sub_devs[0], property="enable_profiling")
print(
"Number of devices in SyclContext " "associated with the queue: ",
q.sycl_context.device_count,
)
if __name__ == "__main__":
import _runner as runner
runner.run_examples("Queue creation examples for dpctl.", globals())
Morty Proxy This is a proxified and sanitized view of the page, visit original site.