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

Improve oneTBB type & named requirements #495

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions source/elements/oneTBB/source/algorithms/functions/feeder.rst
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.

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

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

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

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

.. caution::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ 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 ``Container`` type must meet the :doc:`ContainerBasedSequence requirements <../../named_requirements/algorithms/container_based_sequence>`.
* If ``InputIterator`` does not meet the `Forward Iterator` requirements from the [forward.iterators] ISO C++ Standard section,
the type ``std::iterator_traits<InputIterator>::value_type`` should be constructible from ``std::iterator_traits<InputIterator>::reference``.
* ``decltype(std::declval<Container>().begin())`` should meet the same requirements as ``InputIterator``.

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 [copyconstructible] and
`CopyAssignable` requirements from [copyassignable] ISO C++ Standard sections.
* 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 Expand Up @@ -161,4 +163,3 @@ expressions and the functional form of ``parallel_reduce``.
See also:

* :ref:`Partitioners <Partitioners>`

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 [copyconstructible] and
`CopyAssignable` requirements from [copyassignable] ISO C++ Standard sections.
* 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 Expand Up @@ -183,4 +185,3 @@ See also:

* :doc:`blocked_range class <../../algorithms/blocked_ranges/blocked_range_cls>`
* :doc:`parallel_reduce algorithm <../../algorithms/functions/parallel_reduce_func>`

Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ A type `Value` satisfies `BlockedRangeValue` if it meets the following requireme
.. cpp:function:: void operator=( const Value& )

Assignment.

.. note::

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 by ``blocked_range`` .

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

Value *i* precedes value *j*.

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

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

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

*k*-th value after *i*.

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 @@ -37,15 +37,15 @@ A type `Body` should meet one of the following requirements depending on the fil

.. cpp:function:: void Body::operator()( InputType item ) const

Processes the received item.
Processes the received item.

----------------------------------------------------------------

**SingleFilterBody Requirements: Pseudo-Signature, Semantics**

.. 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 )
.. cpp:function:: friend bool operator<( const Index& i, const Index& j )

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

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

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

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

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

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

Sum of values *i* and *j*.

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

*k*-th value after *i*.

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

Multiplication of values *i* and *j*.

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

Quotient of values *i* and *j*.

``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