|
4 | 4 | Queue
|
5 | 5 | #####
|
6 | 6 |
|
7 |
| -A queue is used to specify a device and a specific set of features of that |
8 |
| -device on which a task is scheduled. The :class:`dpctl.SyclQueue` class |
9 |
| -represents a queue and abstracts the :sycl_queue:`sycl::queue <>` SYCL runtime |
10 |
| -class. |
| 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. |
| 12 | + |
| 13 | +The :class:`dpctl.SyclQueue` class represents a queue and abstracts |
| 14 | +the :sycl_queue:`sycl::queue <>` SYCL runtime class. |
11 | 15 |
|
12 | 16 | Types of Queues
|
13 | 17 | ---------------
|
14 | 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. |
| 25 | + |
| 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'. |
| 30 | + |
| 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. |
| 34 | + |
15 | 35 | Creating a New Queue
|
16 | 36 | --------------------
|
17 | 37 |
|
| 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. |
| 43 | + |
| 44 | +.. _fig-constructing-queue-context-device-property: |
| 45 | + |
| 46 | +.. literalinclude:: ../../../../../examples/python/sycl_queue.py |
| 47 | + :language: python |
| 48 | + :lines: 17-19, 67-79 |
| 49 | + :caption: Constructing SyclQueue from context and device |
| 50 | + :linenos: |
| 51 | + |
| 52 | +A possible output for the example :ref:`fig-constructing-queue-context-device-property:` may be: |
| 53 | + |
| 54 | +.. program-output:: python ../examples/python/sycl_queue.py -r create_queue_from_subdevice_multidevice_context |
| 55 | + |
| 56 | +When context is not specified the :sycl_queue:`sycl::queue <>` constructor |
| 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 :filter_selector:`sycl::ext::oneapi::filter_selector` |
| 61 | +is called. |
| 62 | + |
| 63 | +.. _fig-constructing-queue-filter-selector: |
| 64 | + |
| 65 | +.. literalinclude:: ../../../../../examples/python/sycl_queue.py |
| 66 | + :language: python |
| 67 | + :lines: 17-19, 27-37 |
| 68 | + :caption: Constructing SyclQueue from filter selector |
| 69 | + :linenos: |
| 70 | + |
| 71 | +A possible output for the example :ref:`fig-constructing-queue-filter-selector:` may be: |
| 72 | + |
| 73 | +.. program-output:: python ../examples/python/sycl_queue.py -r create_queue_from_filter_selector |
| 74 | + |
| 75 | + |
18 | 76 | Profiling a Task Submitted to a Queue
|
19 | 77 | -------------------------------------
|
0 commit comments