Runtime settings and tuning parameters, heuristics to decide whether to use parallelized algorithms. More...
#include <parallel/types.h>
Classes | |
struct | __gnu_parallel::_Settings |
class _Settings Run-time settings for the parallel mode including all tunable parameters. More... | |
Namespaces | |
__gnu_parallel | |
GNU parallel code for public use. | |
Macros | |
#define | _GLIBCXX_PARALLEL_CONDITION(__c) |
Determine at compile(?)-time if the parallel variant of an algorithm should be called. More... | |
Runtime settings and tuning parameters, heuristics to decide whether to use parallelized algorithms.
This file is a GNU parallel extension to the Standard C++ Library.
The decision whether to run an algorithm in parallel.
There are several ways the user can switch on and __off the parallel execution of an algorithm, both at compile- and run-time.
Only sequential execution can be forced at compile-time. This reduces code size and protects code parts that have non-thread-safe side effects.
Ultimately, forcing parallel execution at compile-time makes sense. Often, the sequential algorithm implementation is used as a subroutine, so no reduction in code size can be achieved. Also, the machine the program is run on might have only one processor core, so to avoid overhead, the algorithm is executed sequentially.
To force sequential execution of an algorithm ultimately at compile-time, the user must add the tag gnu_parallel::sequential_tag() to the end of the parameter list, e. g.
This is compatible with all overloaded algorithm variants. No additional code will be instantiated, at all. The same holds for most algorithm calls with iterators not providing random access.
If the algorithm call is not forced to be executed sequentially at compile-time, the decision is made at run-time. The global variable __gnu_parallel::_Settings::algorithm_strategy is checked. _It is a tristate variable corresponding to:
a. force_sequential, meaning the sequential algorithm is executed. b. force_parallel, meaning the parallel algorithm is executed. c. heuristic
For heuristic, the parallel algorithm implementation is called only if the input size is sufficiently large. For most algorithms, the input size is the (combined) length of the input sequence(__s). The threshold can be set by the user, individually for each algorithm. The according variables are called gnu_parallel::_Settings::[algorithm]_minimal_n .
For some of the algorithms, there are even more tuning options, e. g. the ability to choose from multiple algorithm variants. See below for details.
#define _GLIBCXX_PARALLEL_CONDITION | ( | __c | ) |
Determine at compile(?)-time if the parallel variant of an algorithm should be called.
__c | A condition that is convertible to bool that is overruled by __gnu_parallel::_Settings::algorithm_strategy. Usually a decision based on the input size. |
Referenced by _GLIBCXX_VISIBILITY(), __gnu_parallel::multiway_merge(), __gnu_parallel::multiway_merge_sentinels(), __gnu_parallel::stable_multiway_merge(), and __gnu_parallel::stable_multiway_merge_sentinels().