4
4
Queue
5
5
#####
6
6
7
- A queue is needed to schedule execution of any computation, or data
8
- copying on the device. Queue construction requires specifying a device
9
- and a context targeting that device as well as additional properties,
10
- such as whether profiling information should be collected or whether
11
- submitted tasks are executed in the order in which they were submitted.
7
+ A queue is needed to schedule execution of any computation or data copying on a
8
+ device. Queue construction requires specifying a device and a context targeting
9
+ that device as well as additional properties, such as whether profiling
10
+ information should be collected or whether submitted tasks are executed in the
11
+ order in which they were submitted.
12
12
13
- The :class: `dpctl.SyclQueue ` class represents a queue and abstracts
14
- the :sycl_queue: `sycl::queue <> ` SYCL runtime class.
13
+ The :class: `dpctl.SyclQueue ` class represents a queue and abstracts the
14
+ :sycl_queue: `sycl::queue <> ` SYCL runtime class.
15
15
16
16
Types of Queues
17
17
---------------
18
18
19
- In SYCL tasks are submitted for execution by the SYCL runtime. The order
20
- in which runtime executes them on the target device is specified by
21
- a sequence of events which must be complete before execution is allowed.
22
- Submission of a task returns an event which can be used to further grow
23
- the graph of computational tasks. SYCL queue stores data needed to manage
24
- this scheduling operations.
19
+ SYCL has a task-based execution model. The order in which a SYCL runtime
20
+ executes a task on a target device is specified by a sequence of events which
21
+ must be complete before execution of the task is allowed. Submission of a task
22
+ returns an event which can be used to further grow the graph of computational
23
+ tasks. A SYCL queue stores the needed data to manage the scheduling operations.
25
24
26
- Unless specified otherwise during constriction of a queue, SYCL runtime
27
- executes tasks whose dependencies were met in an unspecified order,
28
- with possibility for some of the tasks be execute concurrently. Such
29
- queues are said to be 'out-of-order'.
25
+ Unless specified otherwise during constriction of a queue, a SYCL runtime
26
+ executes tasks whose dependencies were met in an unspecified order, with
27
+ possibility for some of the tasks to be execute concurrently. Such queues are
28
+ said to be 'out-of-order'.
30
29
31
- SYCL queues can be specified to indicate that runtime must execute tasks
32
- in the linear order in which they were submitted. In this case tasks submitted
33
- to such a queue, called 'in-order' queues, are never executed concurrently.
30
+ SYCL queues can be specified to indicate that runtime must execute tasks in the
31
+ order in which they were submitted. In this case, tasks submitted to such a
32
+ queue, called 'in-order' queues, are never executed concurrently.
34
33
35
34
Creating a New Queue
36
35
--------------------
37
36
38
- :class: `dpctl.SyclQueue(ctx, dev, property=None) ` creates a new instance for
39
- the given compatible context and device. Keyword parameter `property `
40
- can be set to `"in_order" ` to create an 'in-order' queue, to `"enable_profiling" `
41
- to dynamically collect task execution statistics in the returned event once
42
- the associated task completes.
37
+ :class: `dpctl.SyclQueue(ctx, dev, property=None) ` creates a new queue instance
38
+ for the given compatible context and device. Keyword parameter `property ` can be
39
+ set to `"in_order" ` to create an 'in-order' queue and to `"enable_profiling" ` to
40
+ dynamically collect task execution statistics in the returned event once the
41
+ associated task completes.
43
42
44
43
.. _fig-constructing-queue-context-device-property :
45
44
@@ -49,15 +48,16 @@ the associated task completes.
49
48
:caption: Constructing SyclQueue from context and device
50
49
:linenos:
51
50
52
- A possible output for the example :ref: `fig-constructing-queue-context-device-property: ` may be:
51
+ A possible output for the example
52
+ :ref: `fig-constructing-queue-context-device-property: ` may be:
53
53
54
54
.. program-output :: python ../examples/python/sycl_queue.py -r create_queue_from_subdevice_multidevice_context
55
55
56
- When context is not specified the :sycl_queue: `sycl::queue <> ` constructor
56
+ When a context is not specified the :sycl_queue: `sycl::queue <> ` constructor
57
57
from a device instance is called. Instead of an instance of
58
- :class: `dpctl.SyclDevice ` the argument `dev ` can be a valid filter
59
- selector string. In this case the :sycl_queue: `sycl::queue <> ` constructor
60
- with the corresponding :oneapi_filter_selection: `sycl::ext::oneapi::filter_selector <> `
58
+ :class: `dpctl.SyclDevice ` the argument `dev ` can be a valid filter selector
59
+ string. In this case, the :sycl_queue: `sycl::queue <> ` constructor with the
60
+ corresponding :oneapi_filter_selection: `sycl::ext::oneapi::filter_selector <> `
61
61
is called.
62
62
63
63
.. _fig-constructing-queue-filter-selector :
@@ -68,37 +68,39 @@ is called.
68
68
:caption: Constructing SyclQueue from filter selector
69
69
:linenos:
70
70
71
- A possible output for the example :ref: `fig-constructing-queue-filter-selector ` may be:
71
+ A possible output for the example :ref: `fig-constructing-queue-filter-selector `
72
+ may be:
72
73
73
74
.. program-output :: python ../examples/python/sycl_queue.py -r create_queue_from_filter_selector
74
75
75
76
76
77
Profiling a Task Submitted to a Queue
77
78
-------------------------------------
78
79
79
- The result of scheduling execution of a task on queue is an event which can queried for the status
80
- of the task execution, can be used to order execution of the future tasks after this one is complete,
81
- can be used to wait for the completion of the task, and can carry profiling information of the task
82
- execution. The profiling information is only populated if the queue used was created with
83
- "enable_profiling" property and only becomes available after the task execution is complete.
80
+ The result of scheduling execution of a task on a queue is an event. An event
81
+ has several uses: it can be queried for the status of the task execution, it can
82
+ be used to order execution of the future tasks after it is complete, it can be
83
+ used to wait for execution to complete, and it can carry information to profile
84
+ of the task execution. The profiling information is only populated if the queue
85
+ used was created with the "enable_profiling" property and only becomes available
86
+ after the task execution is complete.
84
87
85
- The class :class: `dpctl.SyclTimer ` implements a context manager that can be used to collect cumulative
86
- profiling information for all the tasks submitted to the queue of interest by functions executed
87
- within the context:
88
+ The class :class: `dpctl.SyclTimer ` implements a Python context manager that can
89
+ be used to collect cumulative profiling information for all the tasks submitted
90
+ to the queue of interest by functions executed within the context:
88
91
89
92
.. code-block :: python
90
93
:caption: Example of timing execution
91
94
92
- import dpctl
93
- import dpctl.tensor as dpt
95
+ import dpctl import dpctl.tensor as dpt
94
96
95
- q = dpctl.SyclQueue(property = " enable_profiling" )
96
- timer_ctx = dpctl.SyclTimer()
97
- with timer_ctx(q):
97
+ q = dpctl.SyclQueue(property = " enable_profiling" ) timer_ctx =
98
+ dpctl.SyclTimer() with timer_ctx(q):
98
99
X = dpt.arange(10 ** 6 , dtype = float , sycl_queue = q)
99
100
100
101
host_dt, device_dt = timer_ctx.dt
101
102
102
- The timer leverages :oneapi_enqueue_barrier: `oneAPI enqueue_barrier SYCL extension <> ` and submits
103
- a barrier at context entrance and a barrier at context exit and records associated events. The elapsed
104
- device time is computed as ``e_exit.profiling_info_start - e_enter.profiling_info_end ``.
103
+ The timer leverages :oneapi_enqueue_barrier: `oneAPI enqueue_barrier SYCL
104
+ extension <> ` and submits a barrier at context entrance and a barrier at context
105
+ exit and records associated events. The elapsed device time is computed as
106
+ ``e_exit.profiling_info_start - e_enter.profiling_info_end ``.
0 commit comments