Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[oneTBB] Improve oneTBB type & named requirements #496

Merged
merged 10 commits into from
Nov 3, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ Member functions

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

**Requirements**: The ``Item`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section of the ISO C++ Standard.

.. cpp:function:: void add( Item&& item )

Same as the above but uses the move constructor of ``Item``, if available.


**Requirements**: The ``Item`` type must meet the `MoveConstructible` requirements from the [moveconstructible] section of the ISO C++ Standard.

.. caution::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ Function template that processes work items in parallel.
Requirements:

* The ``Body`` type must meet the :doc:`ParallelForEachBody requirements <../../named_requirements/algorithms/par_for_each_body>`.
* The ``InputIterator`` type must meet the `Input Iterator` requirements from the [input.iterators] ISO C++ Standard section.
* The ``InputIterator`` type must meet the `Input Iterator` requirements from the [input.iterators] section of the ISO C++ Standard.
* The ``Container`` type must meet the :doc:`ContainerBasedSequence requirements <../../named_requirements/algorithms/container_based_sequence>`.
* If ``InputIterator`` type does not meet the `Forward Iterator` requirements from the [forward.iterators] section of the ISO C++ Standard,
the ``std::iterator_traits<InputIterator>::value_type`` type must be constructible from ``std::iterator_traits<InputIterator>::reference``.
akukanov marked this conversation as resolved.
Show resolved Hide resolved
* ``decltype(std::declval<Container>().begin())`` must meet the same requirements as the `Input Iterator` type.
akukanov marked this conversation as resolved.
Show resolved Hide resolved

The ``parallel_for_each`` template has two forms.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Requirements:

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Requirements:

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A type `Body` should meet one of the following requirements depending on the fil

.. namespace:: FirstFilterBody

.. cpp:function:: OutputType Body::operator()( oneapi::tbb::flow_control fc ) const
.. cpp:function:: OutputType Body::operator()( oneapi::tbb::flow_control& fc ) const

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

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

.. namespace:: SingleFilterBody

.. cpp:function:: void Body::operator()( oneapi::tbb::flow_control fc ) const
.. cpp:function:: void Body::operator()( oneapi::tbb::flow_control& fc ) const

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,42 @@ A type `Index` satisfies `ParallelForIndex` if it meets the following requiremen

Destructor.

.. cpp:function:: void operator=( const Index& )
.. cpp:function:: Index& operator=( const Index& )

Assignment.

.. note::
.. cpp:function:: Index& operator++()

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

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

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

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

Value of *i* precedes or equal to the value of *j*.

.. cpp:function:: D operator-( const Index& i, const Index& j )

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

.. cpp:function:: Index operator+( const Index& i, const Index& j )

Sum of *i* and *j* values.

.. cpp:function:: Index operator+( const Index& i, D k )

*k*-th value after *i*.

.. cpp:function:: Index operator*( const Index& i, const Index& j )

Multiplication of *i* and *j* values.

.. cpp:function:: Index operator/( const Index& i, const Index& j )

Quotient of *i* and *j* values.

``D`` is the type of the expression ``j-i``. It can be any integral type that is convertible to ``size_t``.
Examples that model the Index requirements are integral types and pointers.

Expand Down