Skip to content

Commit e4628d5

Browse files
authored
[oneDPL] Create a dedicated page for buffer wrappers (#566)
1 parent bfeb805 commit e4628d5

File tree

2 files changed

+76
-69
lines changed

2 files changed

+76
-69
lines changed

source/elements/oneDPL/source/parallel_api.rst

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,75 +16,7 @@ a set of non-standard parallel algorithms.
1616
.. toctree::
1717

1818
parallel_api/execution_policies.rst
19-
20-
Buffer Wrappers
21-
+++++++++++++++
22-
23-
.. code:: cpp
24-
25-
// Defined in <oneapi/dpl/iterator>
26-
27-
namespace oneapi {
28-
namespace dpl {
29-
30-
template < typename T, typename AllocatorT, typename TagT >
31-
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
32-
TagT tag = sycl::read_write );
33-
34-
template < typename T, typename AllocatorT, typename TagT >
35-
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
36-
TagT tag, sycl::property::no_init );
37-
38-
template < typename T, typename AllocatorT >
39-
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
40-
sycl::property::no_init );
41-
42-
43-
template < typename T, typename AllocatorT, typename TagT >
44-
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
45-
TagT tag = sycl::read_write );
46-
47-
template < typename T, typename AllocatorT, typename TagT >
48-
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
49-
TagT tag, sycl::property::no_init );
50-
51-
template < typename T, typename AllocatorT >
52-
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
53-
sycl::property::no_init );
54-
55-
}
56-
}
57-
58-
``oneapi::dpl::begin`` and ``oneapi::dpl::end`` are helper functions
59-
for passing SYCL buffers to oneDPL algorithms.
60-
These functions accept a buffer and return an object
61-
of an unspecified type that satisfies the following requirements:
62-
63-
- it is ``CopyConstructible``, ``CopyAssignable``, and comparable
64-
with operators ``==`` and ``!=``;
65-
- the following expressions are valid: ``a + n``, ``a - n``,
66-
``a - b``, where ``a`` and ``b`` are objects of the type,
67-
and ``n`` is an integer value;
68-
- it provides the ``get_buffer()`` method that returns the buffer
69-
passed to the ``begin`` or ``end`` function.
70-
71-
When invoking an algorithm, the buffer passed to ``begin`` should be the same
72-
as the buffer passed to ``end``. Otherwise, the behavior is undefined.
73-
74-
SYCL deduction tags (the ``TagT`` parameters) and ``sycl::property::no_init``
75-
allow to specify an access mode to be used by algorithms for accessing the buffer.
76-
The mode serves as a hint, and can be overridden depending on semantics of the algorithm.
77-
When invoking an algorithm, the same access mode arguments should be used
78-
for ``begin`` and ``end``. Otherwise, the behavior is undefined.
79-
80-
.. code:: cpp
81-
82-
using namespace oneapi;
83-
auto buf_begin = dpl::begin(buf, sycl::write_only);
84-
auto buf_end_1 = dpl::end(buf, sycl::write_only);
85-
auto buf_end_2 = dpl::end(buf, sycl::write_only, sycl::no_init);
86-
dpl::fill(dpl::execution::dpcpp_default, buf_begin, buf_end_1, 42); // allowed
87-
dpl::fill(dpl::execution::dpcpp_default, buf_begin, buf_end_2, 42); // not allowed
19+
parallel_api/buffer_wrappers.rst
8820

8921
Iterators
9022
+++++++++
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.. SPDX-FileCopyrightText: 2019-2022 Intel Corporation
2+
.. SPDX-FileCopyrightText: Contributors to the oneAPI Specification project.
3+
..
4+
.. SPDX-License-Identifier: CC-BY-4.0
5+
6+
Buffer Wrappers
7+
---------------
8+
9+
.. code:: cpp
10+
11+
// Defined in <oneapi/dpl/iterator>
12+
13+
namespace oneapi {
14+
namespace dpl {
15+
16+
template < typename T, typename AllocatorT, typename TagT >
17+
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
18+
TagT tag = sycl::read_write );
19+
20+
template < typename T, typename AllocatorT, typename TagT >
21+
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
22+
TagT tag, sycl::property::no_init );
23+
24+
template < typename T, typename AllocatorT >
25+
/*unspecified*/ begin( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
26+
sycl::property::no_init );
27+
28+
29+
template < typename T, typename AllocatorT, typename TagT >
30+
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
31+
TagT tag = sycl::read_write );
32+
33+
template < typename T, typename AllocatorT, typename TagT >
34+
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
35+
TagT tag, sycl::property::no_init );
36+
37+
template < typename T, typename AllocatorT >
38+
/*unspecified*/ end( sycl::buffer<T, /*dim=*/1, AllocatorT> buf,
39+
sycl::property::no_init );
40+
41+
}
42+
}
43+
44+
``oneapi::dpl::begin`` and ``oneapi::dpl::end`` are helper functions
45+
for passing `SYCL`_ buffers to oneDPL algorithms.
46+
These functions accept a buffer and return an object
47+
of an unspecified type that satisfies the following requirements:
48+
49+
- it is ``CopyConstructible``, ``CopyAssignable``, and comparable
50+
with operators ``==`` and ``!=``;
51+
- the following expressions are valid: ``a + n``, ``a - n``,
52+
``a - b``, where ``a`` and ``b`` are objects of the type,
53+
and ``n`` is an integer value;
54+
- it provides the ``get_buffer()`` method that returns the buffer
55+
passed to the ``begin`` or ``end`` function.
56+
57+
When invoking an algorithm, the buffer passed to ``begin`` should be the same
58+
as the buffer passed to ``end``. Otherwise, the behavior is undefined.
59+
60+
SYCL deduction tags (the ``TagT`` parameters) and ``sycl::property::no_init``
61+
allow to specify an access mode to be used by algorithms for accessing the buffer.
62+
The mode serves as a hint, and can be overridden depending on semantics of the algorithm.
63+
When invoking an algorithm, the same access mode arguments should be used
64+
for ``begin`` and ``end``. Otherwise, the behavior is undefined.
65+
66+
.. code:: cpp
67+
68+
using namespace oneapi;
69+
auto buf_begin = dpl::begin(buf, sycl::write_only);
70+
auto buf_end_1 = dpl::end(buf, sycl::write_only);
71+
auto buf_end_2 = dpl::end(buf, sycl::write_only, sycl::no_init);
72+
dpl::fill(dpl::execution::dpcpp_default, buf_begin, buf_end_1, 42); // allowed
73+
dpl::fill(dpl::execution::dpcpp_default, buf_begin, buf_end_2, 42); // not allowed
74+
75+
.. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html

0 commit comments

Comments
 (0)