Skip to content
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions source/elements/oneDPL/source/parallel_api/execution_policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ A device execution policy represents a `SYCL`_ device and queue to run oneDPL al
class device_policy;

inline const device_policy<> dpcpp_default;

template <typename KernelName = /*unspecified*/>
const device_policy<KernelName> dpdefault;

template <typename KernelName = /*unspecified*/>
const device_policy<KernelName> dpgpu;

template <typename KernelName = /*unspecified*/>
const device_policy<KernelName> dpcpu;

template <typename KernelName = /*unspecified*/>
device_policy<KernelName>
Expand Down Expand Up @@ -151,13 +160,23 @@ Return the queue the policy is associated with.

Allow implicit conversion of the policy to a ``sycl::queue`` object.

Predefined Device Policy
^^^^^^^^^^^^^^^^^^^^^^^^
Predefined Device Policies
^^^^^^^^^^^^^^^^^^^^^^^^^^

``dpcpp_default`` is a predefined execution policy object to run algorithms on the default SYCL device.
It is a global immutable (``const``) instance of type ``device_policy<>``.
[*Note*: ``dpcpp_default`` can be copied but cannot be moved. -- *end note*]
Comment on lines 166 to 168
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to deprecate this policy object as well to convince people to switch to the new ones, or leave it as is?

Copy link
Contributor

@timmiesmith timmiesmith Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danhoeflinger isn't the question whether to redefine dpcpp_default to be an instance of dpdefault instead of deprecating it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, beyond just the name shortening, I think the other advantage here is that the new policy templates are on-demand usage and cannot cause problems for broken SYCL environments on startup with eager global queue creation. If we allow an easy path for users to continue using dpcpp_default as a instance of the new template, then we perpetuate both of the things we are aiming to improve.

I don't think we can just remove it, but we can deprecate it for eventual removal of the requirement to have some lazy queue creation system in oneDPL implementations. (uxlfoundation/oneDPL#1652)


``dpdefault``, ``dpgpu``, and ``dpcpu`` are variable templates for creating ``device_policy`` objects,
possibly with explicit kernel names, to run algorithms on the default SYCL device, a GPU device,
and a CPU device, respectively. An object instantiated from one of these templates is a global
immutable ``device_policy`` object. It is associated with a SYCL queue constructed with
the SYCL device selector that corresponds to the used variable template.
[*Example*: ``dpgpu<>`` is associated with a queue created by ``sycl::gpu_selector_v``. -- *end example*]

Creation or use of a ``dpgpu`` or a ``dpcpu`` policy object can throw ``sycl::exception``
if no appropriate device is found.

make_device_policy Function
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
Loading