Skip to content

Commit 03ddbf6

Browse files
aepanchikboyarinov
andauthored
[oneTBB] Improve oneTBB type & named requirements (#496)
Co-authored-by: Alexey Kukanov <[email protected]> Co-authored-by: kboyarinov <[email protected]>
1 parent ca58c40 commit 03ddbf6

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

source/elements/oneTBB/source/algorithms/functions/feeder.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ Member functions
3333

3434
Adds item to a collection of work items to be processed.
3535

36+
**Requirements**: The ``Item`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section of the ISO C++ Standard.
37+
3638
.. cpp:function:: void add( Item&& item )
3739

3840
Same as the above but uses the move constructor of ``Item``, if available.
39-
41+
42+
**Requirements**: The ``Item`` type must meet the `MoveConstructible` requirements from the [moveconstructible] section of the ISO C++ Standard.
4043

4144
.. caution::
4245

source/elements/oneTBB/source/algorithms/functions/parallel_for_each_func.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ Function template that processes work items in parallel.
3737
Requirements:
3838

3939
* The ``Body`` type must meet the :doc:`ParallelForEachBody requirements <../../named_requirements/algorithms/par_for_each_body>`.
40-
* The ``InputIterator`` type must meet the `Input Iterator` requirements from the [input.iterators] ISO C++ Standard section.
40+
* The ``InputIterator`` type must meet the `Input Iterator` requirements from the [input.iterators] section of the ISO C++ Standard.
41+
* If ``InputIterator`` type does not meet the `Forward Iterator` requirements from the [forward.iterators] section of the ISO C++ Standard,
42+
the ``std::iterator_traits<InputIterator>::value_type`` type must be constructible from ``std::iterator_traits<InputIterator>::reference``.
4143
* The ``Container`` type must meet the :doc:`ContainerBasedSequence requirements <../../named_requirements/algorithms/container_based_sequence>`.
44+
* The type returned by ``Container::begin()`` must meet the same requirements as the ``InputIterator`` type above.
4245

4346
The ``parallel_for_each`` template has two forms.
4447

source/elements/oneTBB/source/algorithms/functions/parallel_reduce_func.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Requirements:
5050

5151
* The ``Range`` type must meet the :doc:`Range requirements <../../named_requirements/algorithms/range>`.
5252
* The ``Body`` type must meet the :doc:`ParallelReduceBody requirements <../../named_requirements/algorithms/par_reduce_body>`.
53+
* The ``Value`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section and
54+
`CopyAssignable` requirements from the [copyassignable] section of the ISO C++ Standard.
5355
* The ``Func`` type must meet the :doc:`ParallelReduceFunc requirements <../../named_requirements/algorithms/par_reduce_func>`.
5456
* The ``Reduction`` types must meet :doc:`ParallelReduceReduction requirements <../../named_requirements/algorithms/par_reduce_reduction>`.
5557

source/elements/oneTBB/source/algorithms/functions/parallel_scan_func.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Requirements:
3232

3333
* The ``Range`` type must meet the :doc:`Range requirement <../../named_requirements/algorithms/range>`.
3434
* The ``Body`` type must meet the :doc:`ParallelScanBody requirements <../../named_requirements/algorithms/par_scan_body>`.
35+
* The ``Value`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section and
36+
`CopyAssignable` requirements from the [copyassignable] section of the ISO C++ Standard.
3537
* The ``Scan`` type must meet the :doc:`ParallelScanFunc requirements <../../named_requirements/algorithms/par_scan_func>`.
3638
* The ``Combine`` type must meet the :doc:`ParallelScanCombine requirements <../../named_requirements/algorithms/par_scan_combine>`.
3739

source/elements/oneTBB/source/named_requirements/algorithms/filter_body.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A type `Body` should meet one of the following requirements depending on the fil
2525

2626
.. namespace:: FirstFilterBody
2727

28-
.. cpp:function:: OutputType Body::operator()( oneapi::tbb::flow_control fc ) const
28+
.. cpp:function:: OutputType Body::operator()( oneapi::tbb::flow_control& fc ) const
2929

3030
Returns the next item from an input stream. Calls ``fc.stop()`` at the end of an input stream.
3131

@@ -45,7 +45,7 @@ A type `Body` should meet one of the following requirements depending on the fil
4545

4646
.. namespace:: SingleFilterBody
4747

48-
.. cpp:function:: void Body::operator()( oneapi::tbb::flow_control fc ) const
48+
.. cpp:function:: void Body::operator()( oneapi::tbb::flow_control& fc ) const
4949

5050
Processes an element from an input stream. Calls ``fc.stop()`` at the end of an input stream.
5151

source/elements/oneTBB/source/named_requirements/algorithms/par_for_index.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,48 @@ A type `Index` satisfies `ParallelForIndex` if it meets the following requiremen
2525

2626
Destructor.
2727

28-
.. cpp:function:: void operator=( const Index& )
28+
.. cpp:function:: Index& operator=( const Index& )
2929

3030
Assignment.
3131

32-
.. note::
32+
.. cpp:function:: Index& operator++()
3333

34-
The return type ``void`` in the pseudo-signature denotes that
35-
``operator=`` is not required to return a value. The actual ``operator=``
36-
can return a value, which will be ignored.
34+
Adjust ``*this`` to the next value.
3735

3836
.. cpp:function:: bool operator<( const Index& i, const Index& j )
3937

4038
Value of *i* precedes value of *j*.
4139

40+
.. cpp:function:: bool operator<=( const Index& i, const Index& j )
41+
42+
Value of *i* precedes or equal to the value of *j*.
43+
4244
.. cpp:function:: D operator-( const Index& i, const Index& j )
4345

4446
Number of values in range ``[i,j)``.
4547

48+
.. cpp:function:: Index operator+( const Index& i, const Index& j )
49+
50+
Sum of *i* and *j* values.
51+
4652
.. cpp:function:: Index operator+( const Index& i, D k )
4753

4854
*k*-th value after *i*.
4955

56+
.. cpp:function:: Index operator*( const Index& i, const Index& j )
57+
58+
Multiplication of *i* and *j* values.
59+
60+
.. cpp:function:: Index operator/( const Index& i, const Index& j )
61+
62+
Quotient of *i* and *j* values.
63+
5064
``D`` is the type of the expression ``j-i``. It can be any integral type that is convertible to ``size_t``.
5165
Examples that model the Index requirements are integral types and pointers.
5266

67+
**_NOTE:_** It is recommended to use integral types as ``ParallelForIndex``. See the ``[basic.fundamental]``
68+
section of the ISO C++ Standard for information about integral types.
69+
5370
See also:
5471

5572
* :doc:`parallel_for algorithm <../../algorithms/functions/parallel_for_func>`

0 commit comments

Comments
 (0)