Skip to content

Commit 6653e2f

Browse files
kboyarinovakukanov
andauthored
[oneTBB] Allow new data types as algorithm and flow graph bodies (#510)
Co-authored-by: Alexey Kukanov <[email protected]>
1 parent 03ddbf6 commit 6653e2f

File tree

10 files changed

+28
-13
lines changed

10 files changed

+28
-13
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ 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+
Since C++17, ``Body`` may also be a pointer to a member function in ``Index``.
4041
* The ``InputIterator`` type must meet the `Input Iterator` requirements from the [input.iterators] section of the ISO C++ Standard.
4142
* If ``InputIterator`` type does not meet the `Forward Iterator` requirements from the [forward.iterators] section of the ISO C++ Standard,
4243
the ``std::iterator_traits<InputIterator>::value_type`` type must be constructible from ``std::iterator_traits<InputIterator>::reference``.

source/elements/oneTBB/source/algorithms/functions/parallel_pipeline_func/filter_cls.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ filter
77
======
88
**[algorithms.parallel_pipeline.filter]**
99

10-
A ``filter`` class template represents a strongly-typed filter in a ``parallel_pipeline`` algorithm,
10+
A ``filter`` class template represents a strongly-typed filter in a ``parallel_pipeline`` algorithm,
1111
with its template parameters specifying the filter input and output types.
1212
A ``filter`` can be constructed from a functor or by composing two ``filter`` objects with
1313
``operator&()``. The same ``filter`` object can be reused in multiple ``&`` expressions.
@@ -17,7 +17,7 @@ The ``filter`` class should only be used in conjunction with ``parallel_pipeline
1717
.. code:: cpp
1818
1919
// Defined in header <oneapi/tbb/parallel_pipeline.h>
20-
20+
2121
namespace oneapi {
2222
namespace tbb {
2323
@@ -48,9 +48,12 @@ The ``filter`` class should only be used in conjunction with ``parallel_pipeline
4848
4949
Requirements:
5050

51-
* If `InputType` is ``void``, a ``Body`` type must meet the :doc:`StartFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
52-
* If `OutputType` is ``void``, a ``Body`` type must meet the :doc:`OutputFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
51+
* If `InputType` is ``void``, a ``Body`` type must meet the :doc:`FirstFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
52+
* If `OutputType` is ``void``, a ``Body`` type must meet the :doc:`LastFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
53+
Since C++17, ``Body`` may also be a pointer to a member function in ``InputType``.
5354
* If `InputType` and `OutputType` are not ``void``, a ``Body`` type must meet the :doc:`MiddleFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
55+
Since C++17, ``Body`` may also be a pointer to a member function in ``InputType`` that returns ``OutputType``
56+
or a pointer to a data member in ``InputType`` of type ``OutputType``.
5457
* If `InputType` and `OutputType` are ``void``, a ``Body`` type must meet the :doc:`SingleFilterBody requirements <../../../named_requirements/algorithms/filter_body>`.
5558

5659
filter_mode Enumeration

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ Requirements:
5353
* The ``Value`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section and
5454
`CopyAssignable` requirements from the [copyassignable] section of the ISO C++ Standard.
5555
* The ``Func`` type must meet the :doc:`ParallelReduceFunc requirements <../../named_requirements/algorithms/par_reduce_func>`.
56+
Since C++17, ``Func`` may also be a pointer to a const member function in ``Range`` that takes ``const Value&`` argument and returns ``Value``.
5657
* The ``Reduction`` types must meet :doc:`ParallelReduceReduction requirements <../../named_requirements/algorithms/par_reduce_reduction>`.
58+
Since C++17, ``Reduction`` may also be a pointer to a const member function in ``Value`` that takes ``const Value&`` argument and returns ``Value``.
5759

5860
The function template ``parallel_reduce`` has two forms:
5961
The functional form is designed to be easy to use in conjunction with lambda expressions.
@@ -163,4 +165,3 @@ expressions and the functional form of ``parallel_reduce``.
163165
See also:
164166

165167
* :ref:`Partitioners <Partitioners>`
166-

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ Requirements:
3535
* The ``Value`` type must meet the `CopyConstructible` requirements from the [copyconstructible] section and
3636
`CopyAssignable` requirements from the [copyassignable] section of the ISO C++ Standard.
3737
* The ``Scan`` type must meet the :doc:`ParallelScanFunc requirements <../../named_requirements/algorithms/par_scan_func>`.
38+
Since C++17, ``Scan`` may also be a pointer to a const member function in ``Range`` that takes ``const Value&`` and ``bool`` arguments and
39+
returns ``Value``.
3840
* The ``Combine`` type must meet the :doc:`ParallelScanCombine requirements <../../named_requirements/algorithms/par_scan_combine>`.
41+
Since C++17, ``Combine`` may also be a pointer to a const member function in ``Value`` that takes ``const Value&`` argument
42+
and returns ``Value``.
3943

4044
The function template ``parallel_scan`` computes a parallel prefix, also known as a parallel scan.
4145
This computation is an advanced concept in parallel computing that is sometimes useful in scenarios
@@ -185,4 +189,3 @@ See also:
185189

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

source/elements/oneTBB/source/flow_graph/async_node_cls.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Requirements:
4747
and the `CopyConstructible` requirements from [copyconstructible] ISO C++ Standard sections.
4848
* The type ``Policy`` can be specified as :doc:`lightweight, queueing and rejecting policies<functional_node_policies>` or defaulted.
4949
* The type ``Body`` must meet the :doc:`AsyncNodeBody requirements <../named_requirements/flow_graph/async_node_body>`.
50+
Since C++17, ``Body`` may also be a pointer to a const member function in ``Input`` that takes ``gateway_type&`` argument.
5051

5152
``async_node`` executes a user-provided body on incoming messages. The body typically submits the
5253
messages to an external activity for processing outside of the graph. It is responsibility of
@@ -61,8 +62,8 @@ messages to an external activity for processing outside of the graph. It is resp
6162
The user can also provide a value of type ``std::size_t`` to limit concurrency to a value between 1 and
6263
:doc:`tbb::flow::unlimited <predefined_concurrency_limits>`.
6364

64-
The body object passed to a ``async_node`` is copied. Updates to member variables do not affect the original object used to construct the node.
65-
If the state held within a body object must be inspected from outside of the node,
65+
The body object passed to a ``async_node`` is copied. Updates to member variables do not affect the original object used to construct the node.
66+
If the state held within a body object must be inspected from outside of the node,
6667
the :doc:`copy_body <copy_body_func>` function can be used to obtain an updated copy.
6768

6869
Member types
@@ -79,7 +80,7 @@ Member functions
7980
async_node( graph &g, size_t concurrency, Body body,
8081
node_priority_t priority = no_priority );
8182
82-
Constructs an ``async_node`` that invokes a copy of ``body``. The ``concurrency`` value limits the number of simultaneous
83+
Constructs an ``async_node`` that invokes a copy of ``body``. The ``concurrency`` value limits the number of simultaneous
8384
``body`` invocations for the node.
8485

8586
This function specifies :doc:`node priority<node_priorities>`.

source/elements/oneTBB/source/flow_graph/func_node_cls.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Requirements:
4747
[copyconstructible] ISO C++ Standard section.
4848
* The type ``Policy`` may be specified as :doc:`lightweight, queueing and rejecting policies<functional_node_policies>` or defaulted.
4949
* The type ``Body`` must meet the :doc:`FunctionNodeBody requirements <../named_requirements/flow_graph/function_node_body>`.
50+
Since C++17, ``Body`` may also be a pointer to a const member function in ``Input`` that returns ``Output`` or
51+
a pointer to a data member in ``Input`` of type ``Output``.
5052

5153
``function_node`` has a user-settable concurrency limit. It can be set to one of :doc:`predefined values <predefined_concurrency_limits>`.
5254
The user can also provide a value of type ``std::size_t`` to limit concurrency to a value between 1 and :doc:`tbb::flow::unlimited <predefined_concurrency_limits>`.

source/elements/oneTBB/source/flow_graph/join_node_cls.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Requirements:
7979
* The ``JoinPolicy`` type must be specified as one of :doc:`buffering policies <join_node_policies>` for ``join_node``.
8080
* The ``KHash`` type must meet the :doc:`HashCompare requirements <../named_requirements/containers/hash_compare>`.
8181
* The ``Bi`` types must meet the :doc:`JoinNodeFunctionObject requirements <../named_requirements/flow_graph/join_node_func_obj>`.
82+
Since C++17, each of ``Bi`` types may also be a pointer to a const member function in ``Input`` that returns ``Key`` or
83+
a pointer to a data member of type ``Key`` in ``Input``.
8284

8385
A ``join_node`` is a ``graph_node`` and a ``sender<OutputTuple>``.
8486
It contains a tuple of input ports, each of which is a ``receiver<Type>`` for each `Type` in

source/elements/oneTBB/source/flow_graph/multifunc_node_cls.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Requirements:
4747
and the `CopyConstructible` requirements from [copyconstructible] ISO C++ Standard sections.
4848
* The type ``Policy`` can be specified as :doc:`lightweight, queueing and rejecting policies<functional_node_policies>` or defaulted.
4949
* The type ``Body`` must meet the :doc:`MultifunctionNodeBody requirements <../named_requirements/flow_graph/multifunction_node_body>`.
50+
Since C++17, ``Body`` may also be a pointer to a const member function in ``Input`` that takes ``output_ports_type&`` argument.
5051

5152
``multifunction_node`` has a user-settable concurrency limit. It can be set to one of :doc:`predefined values <predefined_concurrency_limits>`.
5253
The user can also provide a value of type ``std::size_t`` to limit concurrency to a value between 1 and :doc:`tbb::flow::unlimited <predefined_concurrency_limits>`.

source/elements/oneTBB/source/flow_graph/sequencer_node_cls.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ Requirements:
3636

3737
* The type ``T`` must meet the `CopyConstructible` requirements from [copyconstructible] and
3838
`CopyAssignable` requirements from [copyassignable] ISO C++ Standard sections.
39-
* The type ``Sequencer`` must meet the :doc:`Sequencer requirements <../named_requirements/flow_graph/sequencer>`
39+
* The type ``Sequencer`` must meet the :doc:`Sequencer requirements <../named_requirements/flow_graph/sequencer>`.
40+
Since C++17, ``Sequencer`` may also be a pointer to a const member function in ``T`` that returns ``size_t`` or
41+
a pointer to a data member in ``T`` of type ``size_t``.
4042
If ``Sequencer`` instance throws an exception, behavior is undefined.
4143

4244
``sequencer_node`` forwards messages in a sequence order to a single successor in its successor set.

source/elements/oneTBB/source/named_requirements/flow_graph/function_node_body.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A type `Body` satisfies `FunctionNodeBody` if it meets the following requirement
1414
**FunctionNodeBody Requirements: Pseudo-Signature, Semantics**
1515

1616
.. namespace:: FunctionNodeBody
17-
17+
1818
.. cpp:function:: Body::Body( const Body& )
1919

2020
Copy constructor.
@@ -26,8 +26,7 @@ A type `Body` satisfies `FunctionNodeBody` if it meets the following requirement
2626
.. cpp:function:: Output Body::operator()( const Input& v )
2727

2828
**Requirements:** The ``Input`` and ``Output`` types must be the same as the ``Input`` and ``Output``
29-
template type arguments of the ``fucntion_node`` instance in which the ``Body`` object is passed
29+
template type arguments of the ``function_node`` instance in which the ``Body`` object is passed
3030
during construction.
3131

3232
Performs operation on ``v`` and returns a value of type ``Output``.
33-

0 commit comments

Comments
 (0)