Skip to content

Commit 590a1f0

Browse files
authored
[oneDPL] Specify copy and move semantics for device_policy (#594)
1 parent 4ac2613 commit 590a1f0

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

source/elements/oneDPL/source/parallel_api/execution_policies.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ See "Execution policies" in the `C++ Standard`_ for more information.
3939
The ``std::is_execution_policy`` type trait resolves to ``std::false_type`` for oneDPL execution policies.
4040
Implementations and programs should instead use the :ref:`oneDPL type trait <exec-policy-type-trait>`.
4141

42-
Device Execution Policy
43-
+++++++++++++++++++++++
42+
Device Execution Policies
43+
+++++++++++++++++++++++++
4444

45-
A device execution policy class ``oneapi::dpl::execution::device_policy`` specifies
46-
the `SYCL`_ device and queue to run oneDPL algorithms.
45+
A device execution policy represents a `SYCL`_ device and queue to run oneDPL algorithms.
4746

4847
.. code:: cpp
4948
@@ -56,7 +55,7 @@ the `SYCL`_ device and queue to run oneDPL algorithms.
5655
template <typename KernelName = /*unspecified*/>
5756
class device_policy;
5857
59-
const device_policy<> dpcpp_default;
58+
inline const device_policy<> dpcpp_default;
6059
6160
template <typename KernelName = /*unspecified*/>
6261
device_policy<KernelName>
@@ -69,12 +68,11 @@ the `SYCL`_ device and queue to run oneDPL algorithms.
6968
template <typename NewKernelName, typename OldKernelName>
7069
device_policy<NewKernelName>
7170
make_device_policy( const device_policy<OldKernelName>& = dpcpp_default );
71+
7272
}
7373
}
7474
}
7575
76-
``dpcpp_default`` is a predefined execution policy object to run algorithms on the default `SYCL`_ device.
77-
7876
device_policy Class
7977
^^^^^^^^^^^^^^^^^^^
8078

@@ -99,15 +97,22 @@ device_policy Class
9997
An object of the ``device_policy`` type is associated with a ``sycl::queue`` that is used
10098
to run algorithms on a SYCL device. When an algorithm runs with ``device_policy``
10199
it is capable of processing SYCL buffers (passed via ``oneapi::dpl::begin/end``),
102-
data in the host memory and data in Unified Shared Memory (USM), including USM device memory.
103-
Data placed in the host memory and USM can only be passed to oneDPL algorithms
100+
data in the host memory and data in Unified Shared Memory (USM), including device USM.
101+
Data placed in the host memory and USM can be passed to oneDPL algorithms
104102
as pointers and random access iterators. The way to transfer data from the host memory
105103
to a device and back is unspecified; per-element data movement to/from a temporary storage
106104
is a possible valid implementation.
107105

108106
The ``KernelName`` template parameter, also aliased as ``kernel_name`` within the class template,
109107
is to explicitly provide a name for SYCL kernels executed by an algorithm the policy is passed to.
110108

109+
The ``device_policy`` type is copy-constructible, copy-assignable, move-constructible and move-assignable.
110+
A policy instance constructed as or assigned a copy of another instance is associated with
111+
a ``sycl::queue`` that compares equal, as defined by `SYCL`_, to the queue of that other instance.
112+
A policy instance constructed as or assigned a move of another instance is associated with the queue
113+
of that other instance without copying it. It is unspecified whether the moved-from policy instance
114+
is associated with any queue after the move.
115+
111116
.. code:: cpp
112117
113118
device_policy()
@@ -119,8 +124,8 @@ Construct a policy object associated with a queue created with the default devic
119124
template <typename OtherName>
120125
device_policy( const device_policy<OtherName>& policy )
121126
122-
Construct a policy object associated with the same queue as ``policy``, by changing
123-
the kernel name of the given policy to ``kernel_name`` defined for the new policy.
127+
Construct a policy object as if by copying ``policy`` and changing
128+
the kernel name to ``kernel_name`` defined for the new policy.
124129

125130
.. code:: cpp
126131
@@ -146,6 +151,13 @@ Return the queue the policy is associated with.
146151
147152
Allow implicit conversion of the policy to a ``sycl::queue`` object.
148153

154+
Predefined Device Policy
155+
^^^^^^^^^^^^^^^^^^^^^^^^
156+
157+
``dpcpp_default`` is a predefined execution policy object to run algorithms on the default SYCL device.
158+
It is a global immutable (``const``) instance of type ``device_policy<>``.
159+
[*Note*: ``dpcpp_default`` can be copied but cannot be moved. -- *end note*]
160+
149161
make_device_policy Function
150162
^^^^^^^^^^^^^^^^^^^^^^^^^^^
151163

0 commit comments

Comments
 (0)