Difference between revisions of "cpp/experimental/parallelism"
(→Execution policies: +hidden comment; split exception_list out) |
Andreas Krug (Talk | contribs) m (fmt, {{sup}}) |
||
(15 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
{{cpp/experimental/parallelism/navbar}} | {{cpp/experimental/parallelism/navbar}} | ||
− | The C++ Extensions for Parallelism, ISO/IEC TS 19570: | + | {{fmbox|class=noprint|style=font-size: 0.8em|text='''Merged into ISO C++''' The functionality described on this page was merged into the mainline ISO C++ standard (except for dynamic execution policy and {{tt|exception_list}}) as of 3/2016; see [[cpp/algorithm|the algorithm library]] {{mark since c++17}}}} |
+ | |||
+ | The C++ Extensions for Parallelism, ISO/IEC TS 19570:2015 defines the following new components for the C++ standard library: | ||
===Execution policies=== | ===Execution policies=== | ||
− | + | The parallelism TS describes three execution policies: [[cpp/experimental/parallelism/execution policy#sequential|sequential]], [[cpp/experimental/parallelism/execution policy#parallel|parallel]], and [[cpp/experimental/parallelism/execution policy#parallel vector|parallel+vector]], and provides corresponding execution policy types and objects. Users may select an execution policy statically by invoking a parallel algorithm with the an execution policy object of the corresponding type, or dynamically by using the type-erasing {{tt|execution_policy}} class. | |
+ | |||
+ | Implementations may define additional execution policies as an extension. The semantics of parallel algorithms invoked with an execution policy object of implementation-defined type is implementation-defined. | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | experimental/execution_policy }} | + | {{dsc header|experimental/execution_policy}} |
− | + | {{dsc class|cpp/experimental/execution_policy_tag_t|title=sequential_execution_policy<br/>parallel_execution_policy<br/>parallel_vector_execution_policy|execution policy types}} | |
− | {{dsc class | cpp/experimental/sequential_execution_policy | | + | {{dsc const|cpp/experimental/execution_policy_tag|title=seq<br/>par<br/>par_vec|global execution policy objects}} |
− | + | {{dsc class|cpp/experimental/execution_policy|dynamic execution policy}} | |
− | {{dsc class | cpp/experimental/ | + | {{dsc tclass|cpp/experimental/is_execution_policy|test whether a class represents an execution policy}} |
− | + | ||
− | {{dsc | + | |
− | + | ||
{{dsc end}} | {{dsc end}} | ||
− | === Exception lists === | + | ===Exception lists=== |
{{dsc begin}} | {{dsc begin}} | ||
− | + | {{dsc header|experimental/exception_list}} | |
− | {{dsc header | experimental/exception_list }} | + | {{dsc class|cpp/experimental/exception_list|exceptions raised during parallel executions}} |
− | {{dsc class | cpp/experimental/exception_list | exceptions raised during parallel executions}} | + | |
{{dsc end}} | {{dsc end}} | ||
===Parallelized versions of existing algorithms=== | ===Parallelized versions of existing algorithms=== | ||
− | + | The TS provides [[cpp/experimental/parallelism/existing|parallelized versions]] of the following 69 algorithms from <algorithm>, <numeric> and <memory>: | |
− | {{ | + | {{collapse top|Standard library algorithms for which parallelized versions are provided}} |
− | + | {{div col|3}} | |
− | adjacent_difference | + | * {{lc|std::adjacent_difference}} |
− | adjacent_find | + | * {{lc|std::adjacent_find}} |
− | all_of | + | * {{lc|std::all_of}} |
− | any_of | + | * {{lc|std::any_of}} |
− | copy | + | * {{lc|std::copy}} |
− | copy_if | + | * {{lc|std::copy_if}} |
− | copy_n | + | * {{lc|std::copy_n}} |
− | count | + | * {{lc|std::count}} |
− | count_if | + | * {{lc|std::count_if}} |
− | equal | + | * {{lc|std::equal}} |
− | fill | + | * {{lc|std::fill}} |
− | fill_n | + | * {{lc|std::fill_n}} |
− | find | + | * {{lc|std::find}} |
− | find_end | + | * {{lc|std::find_end}} |
− | find_first_of | + | * {{lc|std::find_first_of}} |
− | find_if | + | * {{lc|std::find_if}} |
− | find_if_not | + | * {{lc|std::find_if_not}} |
− | generate | + | * {{lc|std::generate}} |
− | generate_n | + | * {{lc|std::generate_n}} |
− | includes | + | * {{lc|std::includes}} |
− | inner_product | + | * {{lc|std::inner_product}} |
− | inplace_merge | + | * {{lc|std::inplace_merge}} |
− | is_heap | + | * {{lc|std::is_heap}} |
− | is_heap_until | + | * {{lc|std::is_heap_until}} |
− | is_partitioned | + | * {{lc|std::is_partitioned}} |
− | is_sorted | + | * {{lc|std::is_sorted}} |
− | is_sorted_until | + | * {{lc|std::is_sorted_until}} |
− | lexicographical_compare | + | * {{lc|std::lexicographical_compare}} |
− | max_element | + | * {{lc|std::max_element}} |
− | merge | + | * {{lc|std::merge}} |
− | min_element | + | * {{lc|std::min_element}} |
− | minmax_element | + | * {{lc|std::minmax_element}} |
− | mismatch | + | * {{lc|std::mismatch}} |
− | move | + | * {{ltt|cpp/algorithm/move|std::move}} |
− | none_of | + | * {{lc|std::none_of}} |
− | nth_element | + | * {{lc|std::nth_element}} |
− | partial_sort | + | * {{lc|std::partial_sort}} |
− | partial_sort_copy | + | * {{lc|std::partial_sort_copy}} |
− | partition | + | * {{lc|std::partition}} |
− | partition_copy | + | * {{lc|std::partition_copy}} |
− | remove | + | * {{ltt|cpp/algorithm/remove|std::remove}} |
− | remove_copy | + | * {{lc|std::remove_copy}} |
− | remove_copy_if | + | * {{lc|std::remove_copy_if}} |
− | remove_if | + | * {{lc|std::remove_if}} |
− | replace | + | * {{lc|std::replace}} |
− | replace_copy | + | * {{lc|std::replace_copy}} |
− | replace_copy_if | + | * {{lc|std::replace_copy_if}} |
− | replace_if | + | * {{lc|std::replace_if}} |
− | reverse | + | * {{lc|std::reverse}} |
− | reverse_copy | + | * {{lc|std::reverse_copy}} |
− | rotate | + | * {{lc|std::rotate}} |
− | rotate_copy | + | * {{lc|std::rotate_copy}} |
− | search | + | * {{lc|std::search}} |
− | search_n | + | * {{lc|std::search_n}} |
− | set_difference | + | * {{lc|std::set_difference}} |
− | set_intersection | + | * {{lc|std::set_intersection}} |
− | set_symmetric_difference | + | * {{lc|std::set_symmetric_difference}} |
− | set_union | + | * {{lc|std::set_union}} |
− | sort | + | * {{lc|std::sort}} |
− | stable_partition | + | * {{lc|std::stable_partition}} |
− | stable_sort | + | * {{lc|std::stable_sort}} |
− | swap_ranges | + | * {{lc|std::swap_ranges}} |
− | transform | + | * {{lc|std::transform}} |
− | uninitialized_copy | + | * {{lc|std::uninitialized_copy}} |
− | uninitialized_copy_n | + | * {{lc|std::uninitialized_copy_n}} |
− | uninitialized_fill | + | * {{lc|std::uninitialized_fill}} |
− | uninitialized_fill_n | + | * {{lc|std::uninitialized_fill_n}} |
− | unique | + | * {{lc|std::unique}} |
− | unique_copy | + | * {{lc|std::unique_copy}} |
− | + | {{div col end}} | |
+ | {{collapse bottom}} | ||
===New algorithms=== | ===New algorithms=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | experimental/algorithm }} | + | {{dsc header|experimental/algorithm}} |
− | {{dsc tfun | cpp/experimental/for_each | similar to {{lc|std::for_each}} except returns void}} | + | {{dsc tfun|cpp/experimental/for_each|similar to {{lc|std::for_each}} except returns void}} |
− | {{dsc tfun | cpp/experimental/for_each_n | applies a function object to the first n elements of a sequence }} | + | {{dsc tfun|cpp/experimental/for_each_n|applies a function object to the first n elements of a sequence}} |
− | {{dsc header | experimental/numeric }} | + | {{dsc header|experimental/numeric}} |
− | {{dsc | + | {{dsc inc|cpp/experimental/parallelism/dsc reduce}} |
− | {{dsc tfun | cpp/experimental/exclusive_scan | similar to {{lc|std::partial_sum}}, excludes the | + | {{dsc tfun|cpp/experimental/exclusive_scan|similar to {{lc|std::partial_sum}}, excludes the i{{sup|th}} input element from the i{{sup|th}} sum}} |
− | {{dsc tfun | cpp/experimental/inclusive_scan | similar to {{lc|std::partial_sum}}, includes the | + | {{dsc tfun|cpp/experimental/inclusive_scan|similar to {{lc|std::partial_sum}}, includes the i{{sup|th}} input element in the i{{sup|th}} sum}} |
− | {{dsc | + | {{dsc inc|cpp/experimental/parallelism/dsc transform_reduce}} |
− | {{dsc tfun | cpp/experimental/transform_exclusive_scan | applies a functor, then calculates exclusive scan }} | + | {{dsc tfun|cpp/experimental/transform_exclusive_scan|applies a functor, then calculates exclusive scan}} |
− | {{dsc tfun | cpp/experimental/transform_inclusive_scan | applies a functor, then calculates inclusive scan}} | + | {{dsc tfun|cpp/experimental/transform_inclusive_scan|applies a functor, then calculates inclusive scan}} |
{{dsc end}} | {{dsc end}} | ||
+ | |||
+ | {{langlinks|zh}} |
Latest revision as of 02:11, 28 November 2023
The C++ Extensions for Parallelism, ISO/IEC TS 19570:2015 defines the following new components for the C++ standard library:
Contents |
[edit] Execution policies
The parallelism TS describes three execution policies: sequential, parallel, and parallel+vector, and provides corresponding execution policy types and objects. Users may select an execution policy statically by invoking a parallel algorithm with the an execution policy object of the corresponding type, or dynamically by using the type-erasing execution_policy
class.
Implementations may define additional execution policies as an extension. The semantics of parallel algorithms invoked with an execution policy object of implementation-defined type is implementation-defined.
Defined in header
<experimental/execution_policy> | |
execution policy types (class) | |
global execution policy objects (constant) | |
dynamic execution policy (class) | |
test whether a class represents an execution policy (class template) |
[edit] Exception lists
Defined in header
<experimental/exception_list> | |
exceptions raised during parallel executions (class) |
[edit] Parallelized versions of existing algorithms
The TS provides parallelized versions of the following 69 algorithms from <algorithm>, <numeric> and <memory>:
[edit] New algorithms
Defined in header
<experimental/algorithm> | |
similar to std::for_each except returns void (function template) | |
applies a function object to the first n elements of a sequence (function template) | |
Defined in header
<experimental/numeric> | |
(parallelism TS) |
similar to std::accumulate, except out of order (function template) |
similar to std::partial_sum, excludes the ith input element from the ith sum (function template) | |
similar to std::partial_sum, includes the ith input element in the ith sum (function template) | |
(parallelism TS) |
applies a functor, then reduces out of order (function template) |
applies a functor, then calculates exclusive scan (function template) | |
applies a functor, then calculates inclusive scan (function template) |