__gnu_parallel(3)

๐Ÿ’… __gnu_parallel โ€” GNU parallel code for public use ๐Ÿ’…

okay bestie, sit down, hydrate, and let me tell you about __gnu_parallel ๐Ÿ’– this is the page from section 3 of the Library Functions Manual, and it's literally the GNU parallel code for public use โ€” all the shared machinery that makes GNU's parallel algorithms go brrr โšก

it's giving "one header, a hundred little helper types, and every single one of them matters" ๐Ÿซถ so let's do this properly, no skimming, no skipping. iykyk ๐ŸŒธ


๐Ÿ’– NAME ๐Ÿ’–

__gnu_parallel โ€” GNU parallel code for public use.


โœจ SYNOPSIS โœจ

this is the cast list, bestie โ€” every class, typedef and enum that lives in here. buckle up, it's a big friend group ๐ŸŒˆ

๐ŸŽ€ Classes ๐ŸŽ€

  • struct __accumulate_binop_reduct โ€” general reduction, powered by a binary operator ๐Ÿงฎ
  • struct __accumulate_selector โ€” the selector for std::accumulate() โœจ
  • struct __adjacent_difference_selector โ€” hands you back the difference between two adjacent __elements ๐Ÿ’ซ
  • struct __adjacent_find_selector โ€” runs a predicate over two elements that are sitting right next to each other ๐Ÿ‘ฏ
  • class __binder1st โ€” basically std::binder1st, except it spells the argument types out loud, no guessing ๐ŸŽ€
  • class __binder2nd โ€” std::binder2nd's cousin, argument types stated explicitly ๐Ÿ’…
  • struct __count_if_selector โ€” the selector for std::count_if () ๐Ÿ”ข
  • struct __count_selector โ€” the selector for std::count() ๐Ÿ”ข
  • struct __fill_selector โ€” the selector for std::fill() ๐Ÿชฃ
  • struct __find_first_of_selector โ€” tests a predicate on several elements at once ๐Ÿ”
  • struct __find_if_selector โ€” tests a predicate on one single element; this is the one std::find() and std::find_if () roll with ๐Ÿ”
  • struct __for_each_selector โ€” the selector for std::for_each() ๐Ÿ”
  • struct __generate_selector โ€” the selector for std::generate() ๐ŸŒฑ
  • struct __generic_find_selector โ€” the base class of all __gnu_parallel::__find_template selectors, the founding mother ๐Ÿ‘‘
  • struct __generic_for_each_selector โ€” the generic __selector for embarrassingly parallel functions ๐Ÿ˜Œ
  • struct __identity_selector โ€” a selector that just returns the iterator you handed it, that's it, that's the whole job ๐Ÿชž
  • struct __inner_product_selector โ€” the selector for std::inner_product() โœ–๏ธ
  • struct __max_element_reduct โ€” reduction for finding the maximum element, using a comparator ๐Ÿ”
  • struct __min_element_reduct โ€” reduction for finding the maximum element, using a comparator ๐Ÿ”
  • struct __mismatch_selector โ€” tests an inverted predicate on a single element ๐Ÿ”„
  • struct __multiway_merge_3_variant_sentinel_switch โ€” the switch for 3-way merging with __sentinels turned off ๐Ÿ”€
  • struct __multiway_merge_3_variant_sentinel_switch< true, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare > โ€” the switch for 3-way merging with __sentinels turned on ๐Ÿ”€
  • struct __multiway_merge_4_variant_sentinel_switch โ€” the switch for 4-way merging with __sentinels turned off ๐Ÿ”€
  • struct __multiway_merge_4_variant_sentinel_switch< true, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare > โ€” the switch for 4-way merging with __sentinels turned on ๐Ÿ”€
  • struct __multiway_merge_k_variant_sentinel_switch โ€” the switch for k-way merging with __sentinels turned on ๐Ÿ”€
  • struct __multiway_merge_k_variant_sentinel_switch< false, __stable, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare > โ€” the switch for k-way merging with __sentinels turned off ๐Ÿ”€
  • struct __replace_if_selector โ€” the selector for std::replace() โ™ป๏ธ
  • struct __replace_selector โ€” the selector for std::replace() โ™ป๏ธ
  • struct __transform1_selector โ€” the std::transform() __selector, one-input-sequence flavour โœจ
  • struct __transform2_selector โ€” the std::transform() __selector, two-input-sequences flavour โœจ
  • class __unary_negate โ€” like std::unary_negate, but the argument types are given explicitly ๐Ÿ’ซ
  • struct _DRandomShufflingGlobalData โ€” data that every thread taking part in __gnu_parallel::__parallel_random_shuffle() knows about ๐Ÿƒ
  • struct _DRSSorterPU โ€” local data for one thread participating in __gnu_parallel::__parallel_random_shuffle() ๐Ÿƒ
  • struct _DummyReduct โ€” a reduction function that does absolutely nothing ๐Ÿ’€
  • class _EqualFromLess โ€” constructs a predicate for equality out of a strict weak ordering predicate ๐Ÿ”
  • struct _EqualTo โ€” like std::equal_to, except it's chill with two different types ๐Ÿ’ž
  • class _GuardedIterator โ€” an _Iterator wrapper that carries an implicit supremum at the end of the sequence, and that supremum dominates every single comparison ๐Ÿ‘‘
  • class _IteratorPair โ€” a pair of iterators; the usual iterator operations get applied to both child iterators ๐Ÿ‘ฏ
  • class _IteratorTriple โ€” a triple of iterators; the usual iterator operations get applied to all three child iterators ๐Ÿ‘ฏ๐Ÿ‘ฏ
  • struct _Job โ€” one __job for a certain thread ๐Ÿงพ
  • struct _Less โ€” like std::less, except it allows two different types ๐Ÿค
  • class _Lexicographic โ€” compares __a pair of types lexicographically, ascending ๐Ÿ”ค
  • class _LexicographicReverse โ€” compares __a pair of types lexicographically, descending ๐Ÿ”ค
  • class _LoserTree โ€” the stable _LoserTree variant ๐ŸŒณ
  • class _LoserTree< false, _Tp, _Compare > โ€” the unstable _LoserTree variant ๐ŸŒณ
  • class _LoserTreeBase โ€” guarded loser/tournament tree ๐ŸŒณ
  • class _LoserTreePointer โ€” stable _LoserTree implementation ๐ŸŒณ
  • class _LoserTreePointer< false, _Tp, _Compare > โ€” unstable _LoserTree implementation ๐ŸŒณ
  • class _LoserTreePointerBase โ€” base class of the _Loser Tree implementation that uses pointers ๐Ÿ‘‰
  • class _LoserTreePointerUnguarded โ€” stable unguarded _LoserTree variant that stores pointers ๐ŸŽฏ
  • class _LoserTreePointerUnguarded< false, _Tp, _Compare > โ€” unstable unguarded _LoserTree variant that stores pointers ๐ŸŽฏ
  • class _LoserTreePointerUnguardedBase โ€” unguarded loser tree that keeps only pointers to the elements in the tree structure ๐ŸŽฏ
  • struct _LoserTreeTraits โ€” traits that figure out whether the loser tree should be using pointers or copies ๐Ÿค”
  • class _LoserTreeUnguarded โ€” stable implementation of the unguarded _LoserTree ๐ŸŒณ
  • class _LoserTreeUnguarded< false, _Tp, _Compare > โ€” non-stable implementation of the unguarded _LoserTree ๐ŸŒณ
  • class _LoserTreeUnguardedBase โ€” base class for the unguarded _LoserTree implementation ๐ŸŒณ
  • struct _Multiplies โ€” like std::multiplies, except it allows two different types โœ–๏ธ
  • struct _Nothing โ€” a functor doing nothing ๐Ÿซฅ
  • struct _Piece โ€” subsequence description ๐Ÿงฉ
  • struct _Plus โ€” like std::plus, except it allows two different types โž•
  • struct _PMWMSSortingData โ€” data accessed by all threads ๐Ÿ—‚๏ธ
  • class _PseudoSequence โ€” a sequence that conceptually consists of multiple copies of the same element; the copies are not stored explicitly, of course ๐Ÿ˜Œ
  • class _PseudoSequenceIterator โ€” the _Iterator associated with __gnu_parallel::_PseudoSequence; it features the usual random-access iterator functionality โœจ
  • struct _QSBThreadLocal โ€” information local to one thread in the parallel quicksort run ๐Ÿงต
  • class _RandomNumber โ€” random number generator, based on the Mersenne twister ๐ŸŽฒ
  • class _RestrictedBoundedConcurrentQueue โ€” a double-ended queue of bounded size that allows lock-free atomic access. push_front() and pop_front() must not be called concurrently with each other, while pop_back() can be called concurrently at all times. empty(), size(), and top() are intentionally not provided โ€” calling them would not make sense in a concurrent setting ๐Ÿšฆ
  • struct _SamplingSorter โ€” stable sorting functor ๐Ÿ“Š
  • struct _SamplingSorter< false, _RAIter, _StrictWeakOrdering > โ€” non-__stable sorting functor ๐Ÿ“Š
  • struct _Settings โ€” class _Settings run-time settings for the parallel mode, including all the tunable parameters โš™๏ธ
  • struct _SplitConsistently โ€” split consistently โœ‚๏ธ
  • struct _SplitConsistently< false, _RAIter, _Compare, _SortingPlacesIterator > โ€” split by sampling โœ‚๏ธ
  • struct _SplitConsistently< true, _RAIter, _Compare, _SortingPlacesIterator > โ€” split by exact splitting โœ‚๏ธ
  • struct balanced_quicksort_tag โ€” forces parallel sorting using balanced quicksort at compile time โš–๏ธ
  • struct balanced_tag โ€” recommends parallel execution using dynamic load-balancing at compile time โš–๏ธ
  • struct constant_size_blocks_tag โ€” selects the constant block size variant for std::find() ๐Ÿงฑ
  • struct default_parallel_tag โ€” recommends parallel execution using the default parallel algorithm ๐ŸŽฏ
  • struct equal_split_tag โ€” selects the equal splitting variant for std::find() โœ‚๏ธ
  • struct exact_tag โ€” forces parallel merging with exact splitting, at compile time ๐ŸŽฏ
  • struct find_tag โ€” base class for the std::find() variants ๐Ÿงฌ
  • struct growing_blocks_tag โ€” selects the growing block size variant for std::find() ๐ŸŒฑ
  • struct multiway_mergesort_exact_tag โ€” forces parallel sorting using multiway mergesort with exact splitting at compile time ๐Ÿ”€
  • struct multiway_mergesort_sampling_tag โ€” forces parallel sorting using multiway mergesort with splitting by sampling at compile time ๐Ÿ”€
  • struct multiway_mergesort_tag โ€” forces parallel sorting using multiway mergesort at compile time ๐Ÿ”€
  • struct omp_loop_static_tag โ€” recommends parallel execution using OpenMP static load-balancing at compile time ๐ŸŒ€
  • struct omp_loop_tag โ€” recommends parallel execution using OpenMP dynamic load-balancing at compile time ๐ŸŒ€
  • struct parallel_tag โ€” recommends parallel execution at compile time, optionally using a user-specified number of threads ๐Ÿงต
  • struct quicksort_tag โ€” forces parallel sorting using unbalanced quicksort at compile time โšก
  • struct sampling_tag โ€” forces parallel merging with exact splitting, at compile time ๐ŸŽฒ
  • struct sequential_tag โ€” forces sequential execution at compile time ๐Ÿข
  • struct unbalanced_tag โ€” recommends parallel execution using static load-balancing at compile time ๐ŸŽข

๐ŸŽ€ Typedefs ๐ŸŽ€

  • typedef unsigned short _BinIndex โ€” a type to hold the index of a bin ๐Ÿ—ƒ๏ธ
  • typedef int64_t _CASable โ€” the longest compare-and-swappable integer type on this platform ๐Ÿ”
  • typedef uint64_t _SequenceIndex โ€” unsigned integer for indexing __elements; the total number of elements for each algorithm has to fit into this type ๐Ÿ“
  • typedef uint16_t _ThreadIndex โ€” unsigned integer for indexing a thread number; the maximum thread number (for each processor) has to fit into this type ๐Ÿงต

๐ŸŽ€ Enumerations ๐ŸŽ€

  • enum _AlgorithmStrategy { heuristic, force_sequential, force_parallel } โ€” strategies for run-time algorithm selection ๐Ÿง 
  • enum _FindAlgorithm { GROWING_BLOCKS, CONSTANT_SIZE_BLOCKS, EQUAL_SPLIT } โ€” find algorithms ๐Ÿ”
  • enum _MultiwayMergeAlgorithm { LOSER_TREE } โ€” merging algorithms ๐Ÿ”€
  • enum _Parallelism { sequential, parallel_unbalanced, parallel_balanced, parallel_omp_loop, parallel_omp_loop_static, parallel_taskqueue } โ€” the run-time equivalents for the compile-time tags โš™๏ธ
  • enum _PartialSumAlgorithm { RECURSIVE, LINEAR } โ€” partial sum algorithms: recursive, linear โž•
  • enum _SortAlgorithm { MWMS, QS, QS_BALANCED } โ€” sorting algorithms ๐Ÿ“Š
  • enum _SplittingAlgorithm { SAMPLING, EXACT } โ€” sorting/merging algorithms: sampling, __exact โœ‚๏ธ

bestie this is literally part one of ten, so don't you dare think we're done ๐Ÿ’– there is so much more of this page coming โœจ

โœจ Functions โœจ

the function lineup, exact signatures only, no skips. every option and detail stays, only the vibe is upgraded. ๐Ÿ’…

  • __add_omp โ€” no description in the source, just this exact signature:
template<typename _Tp> _Tp __add_omp (volatile _Tp *__ptr, _Tp __addend)
  • __calc_borders โ€” precalculates __advances for the Knuth-Morris-Pratt algorithm. string-matching prep fr fr.
template<typename _RAIter, typename _DifferenceTp> void __calc_borders
    (_RAIter __elements, _DifferenceTp __length, _DifferenceTp *__off)
  • __cas_omp โ€” no description, exact signature:
template<typename _Tp> bool __cas_omp (volatile _Tp *__ptr, _Tp
    __comparand, _Tp __replacement)
  • __compare_and_swap โ€” compare-and-swap. that's the whole vibe.
template<typename _Tp> bool __compare_and_swap (volatile _Tp *__ptr, _Tp
    __comparand, _Tp __replacement)
  • __copy_tail โ€” no description, exact signature:
template<typename _IIter, typename _OutputIterator> _OutputIterator
    __copy_tail (std::pair< _IIter, _IIter > __b, std::pair< _IIter,
    _IIter > __e, _OutputIterator __r)
  • __decode2 โ€” decodes two integers from one gnu_parallel::_CASable. cute.
void __decode2 (_CASable __x, int &__a, int &__b)
  • __determine_samples โ€” selects _M_samples from a sequence. periodt.
template<typename _RAIter, typename _DifferenceTp> void
    __determine_samples (_PMWMSSortingData< _RAIter > *__sd,
    _DifferenceTp __num_samples)
  • __encode2 โ€” encodes two integers into one gnu_parallel::_CASable. the reverse of decode, slay.
_CASable __encode2 (int __a, int __b)
  • __equally_split โ€” function to split a sequence into parts of almost equal size. lowkey the group project splitter.
template<typename _DifferenceType, typename _OutputIterator>
    _OutputIterator __equally_split (_DifferenceType __n, _ThreadIndex
    __num_threads, _OutputIterator __s)
  • __equally_split_point โ€” function to split a sequence into parts of almost equal size. same energy, different return.
template<typename _DifferenceType> _DifferenceType __equally_split_point
    (_DifferenceType __n, _ThreadIndex __num_threads, _ThreadIndex
    __thread_no)
  • __fetch_and_add โ€” add a value to a variable, atomically. no cap, atomicity is the moment.
template<typename _Tp> _Tp __fetch_and_add (volatile _Tp *__ptr, _Tp
    __addend)
  • __find_template โ€” parallel std::find, switch for different algorithms. the main character of find.
template<typename _RAIter1, typename _RAIter2, typename _Pred, typename
    _Selector> std::pair< _RAIter1, _RAIter2 > __find_template (_RAIter1
    __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred,
    _Selector __selector)
  • __find_template (constant_size_blocks_tag) โ€” parallel std::find, constant block size variant. blocks stay same size, consistency queen.
template<typename _RAIter1, typename _RAIter2, typename _Pred, typename
    _Selector> std::pair< _RAIter1, _RAIter2 > __find_template (_RAIter1
    __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred,
    _Selector __selector, constant_size_blocks_tag)
  • __find_template (equal_split_tag) โ€” parallel std::find, equal splitting variant. everyone gets a fair slice.
template<typename _RAIter1, typename _RAIter2, typename _Pred, typename
    _Selector> std::pair< _RAIter1, _RAIter2 > __find_template (_RAIter1
    __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred,
    _Selector __selector, equal_split_tag)
  • __find_template (growing_blocks_tag) โ€” parallel std::find, growing block size variant. blocks start small and grow, it's giving adaptive.
template<typename _RAIter1, typename _RAIter2, typename _Pred, typename
    _Selector> std::pair< _RAIter1, _RAIter2 > __find_template (_RAIter1
    __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred,
    _Selector __selector, growing_blocks_tag)
  • __for_each_template_random_access โ€” chose the desired algorithm by evaluating __parallelism_tag. it's the picker.
template<typename _IIter, typename _UserOp, typename _Functionality,
    typename _Red, typename _Result> _UserOp
    __for_each_template_random_access (_IIter __begin, _IIter __end,
    _UserOp __user_op, _Functionality &__functionality, _Red
    __reduction, _Result __reduction_start, _Result &__output, typename
    std::iterator_traits< _IIter >::difference_type __bound,
    _Parallelism __parallelism_tag)
  • __for_each_template_random_access_ed โ€” embarrassingly parallel algorithm for random access iterators, using hand-crafted parallelization by equal splitting the work. hand-crafted? we love a bespoke moment.
template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op __for_each_template_random_access_ed (_RAIter
    __begin, _RAIter __end, _Op __o, _Fu &__f, _Red __r, _Result __base,
    _Result &__output, typename std::iterator_traits< _RAIter
    >::difference_type __bound)
  • __for_each_template_random_access_omp_loop โ€” embarrassingly parallel algorithm for random access iterators, using an OpenMP for loop. OpenMP said let me handle this.
template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op __for_each_template_random_access_omp_loop
    (_RAIter __begin, _RAIter __end, _Op __o, _Fu &__f, _Red __r,
    _Result __base, _Result &__output, typename std::iterator_traits<
    _RAIter >::difference_type __bound)
  • __for_each_template_random_access_omp_loop_static โ€” embarrassingly parallel algorithm for random access iterators, using an OpenMP for loop with static scheduling. static scheduling, she's stable.
template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op
    __for_each_template_random_access_omp_loop_static (_RAIter __begin,
    _RAIter __end, _Op __o, _Fu &__f, _Red __r, _Result __base, _Result
    &__output, typename std::iterator_traits< _RAIter >::difference_type
    __bound)
  • __for_each_template_random_access_workstealing โ€” work stealing algorithm for random access iterators. stealing work but make it collaborative. ๐Ÿ’…
template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op __for_each_template_random_access_workstealing
    (_RAIter __begin, _RAIter __end, _Op __op, _Fu &__f, _Red __r,
    _Result __base, _Result &__output, typename std::iterator_traits<
    _RAIter >::difference_type __bound)
  • __get_max_threads โ€” no description, exact signature:
_ThreadIndex __get_max_threads ()
  • __is_parallel โ€” no description, exact signature:
bool __is_parallel (const _Parallelism __p)
  • __is_sorted โ€” check whether [__begin, __end) is sorted according to __comp. the vibe check for order.
template<typename _IIter, typename _Compare> bool __is_sorted (_IIter
    __begin, _IIter __end, _Compare __comp)
  • __median_of_three_iterators โ€” compute the median of three referenced elements, according to __comp. middle child energy.
template<typename _RAIter, typename _Compare> _RAIter
    __median_of_three_iterators (_RAIter __a, _RAIter __b, _RAIter __c,
    _Compare __comp)
  • __merge_advance โ€” merge routine being able to merge only the __max_length smallest elements. only the smallest, we're selective.
template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __merge_advance (_RAIter1 &__begin1, _RAIter1 __end1, _RAIter2
    &__begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp
    __max_length, _Compare __comp)
  • __merge_advance_movc โ€” merge routine being able to merge only the __max_length smallest elements. same brief, different implementation.
template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __merge_advance_movc (_RAIter1 &__begin1, _RAIter1 __end1, _RAIter2
    &__begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp
    __max_length, _Compare __comp)
  • __merge_advance_usual โ€” merge routine being able to merge only the __max_length smallest elements. the usual, as the name says.
template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __merge_advance_usual (_RAIter1 &__begin1, _RAIter1 __end1, _RAIter2
    &__begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp
    __max_length, _Compare __comp)
  • __parallel_merge_advance โ€” parallel merge routine being able to merge only the __max_length smallest elements. parallel merge, slay.
template<typename _RAIter1, typename _RAIter3, typename _Compare>
    _RAIter3 __parallel_merge_advance (_RAIter1 &__begin1, _RAIter1
    __end1, _RAIter1 &__begin2, _RAIter1 __end2, _RAIter3 __target,
    typename std::iterator_traits< _RAIter1 >::difference_type
    __max_length, _Compare __comp)
  • __parallel_merge_advance โ€” merge routine fallback to sequential in case the iterators of the two input sequences are of different type. when types don't match, it falls back, no drama.
template<typename _RAIter1, typename _RAIter2, typename _RAIter3,
    typename _Compare> _RAIter3 __parallel_merge_advance (_RAIter1
    &__begin1, _RAIter1 __end1, _RAIter2 &__begin2, _RAIter2 __end2,
    _RAIter3 __target, typename std::iterator_traits< _RAIter1
    >::difference_type __max_length, _Compare __comp)
  • __parallel_nth_element โ€” parallel implementation of std::nth_element(). nth element but make it parallel.
template<typename _RAIter, typename _Compare> void
    __parallel_nth_element (_RAIter __begin, _RAIter __nth, _RAIter
    __end, _Compare __comp)
  • __parallel_partial_sort โ€” parallel implementation of std::partial_sort(). partial sort, full parallel energy.
template<typename _RAIter, typename _Compare> void
    __parallel_partial_sort (_RAIter __begin, _RAIter __middle, _RAIter
    __end, _Compare __comp)
  • __parallel_partial_sum โ€” parallel partial sum front-__end. front to end, parallel.
template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator __parallel_partial_sum (_IIter
    __begin, _IIter __end, _OutputIterator __result, _BinaryOperation
    __bin_op)
  • __parallel_partial_sum_basecase โ€” base case prefix sum routine. the base case, holding it down.
template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator __parallel_partial_sum_basecase
    (_IIter __begin, _IIter __end, _OutputIterator __result,
    _BinaryOperation __bin_op, typename std::iterator_traits< _IIter
    >::value_type __value)
  • __parallel_partial_sum_linear โ€” parallel partial sum implementation, two-phase approach, no recursion. two-phase, no recursion, clean.
template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator __parallel_partial_sum_linear
    (_IIter __begin, _IIter __end, _OutputIterator __result,
    _BinaryOperation __bin_op, typename std::iterator_traits< _IIter
    >::difference_type __n)
  • __parallel_partition โ€” parallel implementation of std::partition. partition but parallel.
template<typename _RAIter, typename _Predicate> std::iterator_traits<
    _RAIter >::difference_type __parallel_partition (_RAIter __begin,
    _RAIter __end, _Predicate __pred, _ThreadIndex __num_threads)
  • __parallel_random_shuffle โ€” parallel random public call. public call, random shuffle.
template<typename _RAIter, typename _RandomNumberGenerator> void
    __parallel_random_shuffle (_RAIter __begin, _RAIter __end,
    _RandomNumberGenerator __rng=_RandomNumber())
  • __parallel_random_shuffle_drs โ€” main parallel random shuffle step. the main step, main character.
template<typename _RAIter, typename _RandomNumberGenerator> void
    __parallel_random_shuffle_drs (_RAIter __begin, _RAIter __end,
    typename std::iterator_traits< _RAIter >::difference_type __n,
    _ThreadIndex __num_threads, _RandomNumberGenerator &__rng)
  • __parallel_random_shuffle_drs_pu โ€” random shuffle code executed by each thread. each thread gets a turn.
template<typename _RAIter, typename _RandomNumberGenerator> void
    __parallel_random_shuffle_drs_pu (_DRSSorterPU< _RAIter,
    _RandomNumberGenerator > *__pus)
  • __parallel_set_difference โ€” no description, exact signature:
template<typename _IIter, typename _OutputIterator, typename _Compare>
    _OutputIterator __parallel_set_difference (_IIter __begin1, _IIter
    __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result,
    _Compare __comp)
  • __parallel_set_intersection โ€” no description, exact signature:
template<typename _IIter, typename _OutputIterator, typename _Compare>
    _OutputIterator __parallel_set_intersection (_IIter __begin1, _IIter
    __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result,
    _Compare __comp)
  • __parallel_set_operation โ€” no description, exact signature:
template<typename _IIter, typename _OutputIterator, typename _Operation>
    _OutputIterator __parallel_set_operation (_IIter __begin1, _IIter
    __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result,
    _Operation __op)
  • and the source cuts off mid-signature here:
template<typename _IIter, typename _OutputIterator, typename _Compare>
template<typename _IIter, typename _OutputIterator, typename _Compare>
    _OutputIterator __parallel_set_symmetric_difference (_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp)

no little blurb in the docs for this one bestie, she's just here, existing, looking gorgeous ๐Ÿ’œ

template<typename _IIter, typename _OutputIterator, typename _Compare>
    _OutputIterator __parallel_set_union (_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp)

same energy โ€” signature only, no commentary, and honestly? iconic for that ๐ŸŒˆ


template<bool __stable, typename _RAIter, typename _Compare, typename _Parallelism>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp, _Parallelism __parallelism)

the generic sort-y one, no blurb attached, take the signature and go ๐Ÿ’–


โœจ okay but now we get to the __parallel_sort overloads and they ALL have opinions โœจ

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    balanced_quicksort_tag __parallelism)

Choose balanced quicksort for parallel sorting. like, when you want your parallel sort to be balanced quicksort specifically ๐ŸŽ€

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    default_parallel_tag __parallelism)

Choose multiway mergesort with exact splitting, for parallel sorting. yep, exact splitting, that's the whole vibe โœจ

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    multiway_mergesort_exact_tag __parallelism)

Choose multiway mergesort with exact splitting, for parallel sorting. twins with the one above fr fr ๐Ÿ‘ฏ

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    multiway_mergesort_sampling_tag __parallelism)

Choose multiway mergesort with splitting by sampling, for parallel sorting. different splitting, still mergesort, still parallel, still slaying ๐ŸŒธ

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    multiway_mergesort_tag __parallelism)

Choose multiway mergesort, splitting variant at run-time, for parallel sorting. she picks her splitting variant at run-time, she's flexible like that ๐Ÿ’…

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    parallel_tag __parallelism)

Choose a parallel sorting algorithm. just. a parallel sorting algorithm. dealer's choice, bestie ๐Ÿ‘‘

template<bool __stable, typename _RAIter, typename _Compare>
    void __parallel_sort (_RAIter __begin, _RAIter __end, _Compare __comp,
    quicksort_tag __parallelism)

Choose quicksort for parallel sorting. quicksort, parallel, periodt ๐Ÿ”ฅ


๐ŸŽ€ the unbalanced quicksort girlies ๐ŸŽ€

template<typename _RAIter, typename _Compare>
    void __parallel_sort_qs (_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads)

Unbalanced quicksort main call. the main character of the unbalanced quicksort situation ๐Ÿ’ซ

template<typename _RAIter, typename _Compare>
    void __parallel_sort_qs_conquer (_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads)

Unbalanced quicksort conquer step. she conquers. literally. ๐Ÿ—ก๏ธ

template<typename _RAIter, typename _Compare>
    std::iterator_traits<_RAIter>::difference_type __parallel_sort_qs_divide (_RAIter __begin, _RAIter __end, _Compare __comp, typename std::iterator_traits<_RAIter>::difference_type __pivot_rank, typename std::iterator_traits<_RAIter>::difference_type __num_samples, _ThreadIndex __num_threads)

Unbalanced quicksort divide step. divide, then conquer, that's the order, don't @ me โœจ

template<typename _RAIter, typename _Compare>
    void __parallel_sort_qsb (_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads)

Top-level quicksort routine. top level, top tier, top everything ๐ŸŒŸ


๐Ÿฆ‹ unique_copy but make it parallel ๐Ÿฆ‹

template<typename _IIter, class _OutputIterator>
    _OutputIterator __parallel_unique_copy (_IIter __first, _IIter __last, _OutputIterator __result)

Parallel std::unique_copy(), without explicit equality predicate. no predicate, she just knows ๐Ÿซถ

template<typename _IIter, class _OutputIterator, class _BinaryPredicate>
    _OutputIterator __parallel_unique_copy (_IIter __first, _IIter __last, _OutputIterator __result, _BinaryPredicate __binary_pred)

Parallel std::unique_copy(), w/__o explicit equality predicate. yes, the docs literally say w/__o, we are NOT fixing it, it's part of her charm ๐Ÿ˜ญ


๐Ÿ’œ balanced quicksort internals, the backstage pass ๐Ÿ’œ

template<typename _RAIter, typename _Compare>
    void __qsb_conquer (_QSBThreadLocal<_RAIter> **__tls, _RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __iam, _ThreadIndex __num_threads, bool __parent_wait)

Quicksort conquer step. (the b stands for balanced, iykyk) ๐Ÿ’œ

template<typename _RAIter, typename _Compare>
    std::iterator_traits<_RAIter>::difference_type __qsb_divide (_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads)

Balanced quicksort divide step. balanced this time, not like her chaotic cousin up there โš–๏ธ

template<typename _RAIter, typename _Compare>
    void __qsb_local_sort_with_helping (_QSBThreadLocal<_RAIter> **__tls, _Compare &__comp, _ThreadIndex __iam, bool __wait)

Quicksort step doing load-balanced local sort. she does a local sort AND balances the load AND helps?? she's literally the whole team ๐Ÿซถ


โญ lil math besties, they're so cute โญ

template<typename _RandomNumberGenerator>
    int __random_number_pow2 (int __logp, _RandomNumberGenerator &__rng)

Generate a random number in [0,2^__logp). note the half-open interval bestie, it does NOT include 2^__logp ๐ŸŒธ

template<typename _Size>
    _Size __rd_log2 (_Size __n)

Calculates the rounded-down logarithm of __n for base 2. rounded DOWN. not up. down. ๐Ÿ“

template<typename _Tp>
    _Tp __round_up_to_pow2 (_Tp __x)

Round up to the next greater power of 2. and this one rounds UP, see, they're a matched set ๐ŸŽ€


๐Ÿ” search, but parallel ๐Ÿ”

template<typename __RAIter1, typename __RAIter2, typename _Pred>
    __RAIter1 __search_template (__RAIter1 __begin1, __RAIter1 __end1, __RAIter2 __begin2, __RAIter2 __end2, _Pred __pred)

Parallel std::search. parallel search, parallel vibes, parallel everything ๐ŸŒŠ


๐Ÿงš sequential things that are quietly doing the most ๐Ÿงš

template<bool __stable, bool __sentinels, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
    _RAIter3 __sequential_multiway_merge (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits<typename std::iterator_traits<_RAIterIterator>::value_type::first_type>::value_type &__sentinel, _DifferenceTp __length, _Compare __comp)

Sequential multi-way merging switch. she's a switch, and she's sequential, and she merges multiple ways, that's three whole things ๐Ÿ”€

template<typename _RAIter, typename _RandomNumberGenerator>
    void __sequential_random_shuffle (_RAIter __begin, _RAIter __end, _RandomNumberGenerator &__rng)

Sequential cache-efficient random shuffle. sequential AND cache-efficient AND random, she contains multitudes โœจ


๐ŸŽ€ the range-shrinking situation (this is such a serve) ๐ŸŽ€

template<typename _IIter>
    void __shrink (std::vector<_IIter> &__os_starts, size_t &__count_to_two, size_t &__range_length)

Combines two ranges into one and thus halves the number of ranges. two become one, math is beautiful actually ๐Ÿ’–

template<typename _IIter>
    void __shrink_and_double (std::vector<_IIter> &__os_starts, size_t &__count_to_two, size_t &__range_length, const bool __make_twice)

Shrinks and doubles the ranges. shrink AND double, she's doing both, she's unhinged, we love her ๐Ÿ˜ญ

void __yield ()

Yield control to another thread, without waiting for the end of the time slice. no arguments, no waiting, she just yields and dips immediately ๐Ÿ’…


template<typename _IIter, typename _FunctorType>
    size_t list_partition (const _IIter __begin, const _IIter __end, _IIter *__starts, size_t *__lengths, const int __num_parts, _FunctorType &__f, int __oversampling=0)

Splits a sequence given by input iterators into parts of almost equal size. almost equal bestie, not exactly equal, don't come for her. also hi __oversampling=0, the default ๐Ÿ’™

template<typename _Tp>
    const _Tp & max (const _Tp &__a, const _Tp &__b)

Equivalent to std::max. just std::max. that's it. that's the description ๐ŸŒฟ

template<typename _Tp>
    const _Tp & min (const _Tp &__a, const _Tp &__b)

Equivalent to std::min. and here's std::min's twin, standing right next to her ๐Ÿ’š


๐ŸŒˆ multiseq time, and these descriptions EAT ๐ŸŒˆ

template<typename _RanSeqs, typename _RankType, typename _RankIterator, typename _Compare>
    void multiseq_partition (_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankIterator __begin_offsets, _Compare __comp=std::less<typename std::iterator_traits<typename std::iterator_traits<_RanSeqs>::value_type::first_type>::value_type>())

Splits several sorted sequences at a certain global __rank, resulting in a splitting point for each sequence. The sequences are passed via a sequence of random-access iterator pairs, none of the sequences may be empty. If there are several equal elements across the split, the ones on the __left side will be chosen from sequences with smaller number.

okay that was a lot, let me translate: sequences come in as pairs of random-access iterators, none of them may be empty (rule is a rule), and if there's a tie across the split, the left side wins and it's picked from the sequence with the smaller number. also yes, the __comp default is that whole std::less<...> monster, we're keeping every character of it ๐Ÿ’–

template<typename _Tp, typename _RanSeqs, typename _RankType, typename _Compare>
    _Tp multiseq_selection (_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankType &__offset, _Compare __comp=std::less<_Tp>())

Selects the element at a certain global __rank from several sorted sequences.

and she's got a __comp defaulted to std::less<_Tp>(), plus a __offset she fills in for you ๐Ÿซถ


๐Ÿ’ซ multiway_merge overload family portrait ๐Ÿ’ซ

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
    _RAIterOut multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag)

no blurb for the exact_tag one, bestie โ€” she's just out here taking an __gnu_parallel::exact_tag and being mysterious ๐Ÿ”ต

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
    _RAIterOut multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sampling_tag __tag)

same deal for sampling_tag โ€” no description in the docs, just the signature, and she's serving anyway ๐ŸŒŠ

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
    _RAIterOut multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag)

Multiway Merge Frontend. the frontend!! she's the face of the operation ๐Ÿ’…

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
    _RAIterOut multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag)

no blurb for the default_parallel_tag overload either โ€” signature only, she's lowkey about it ๐Ÿ™ˆ

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
    _RAIterOut multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag=parallel_tag(0))

and the parallel_tag one has no description either, but she DOES have a default: __tag=parallel_tag(0). keep that, it matters โญ


๐Ÿ”ฅ the 3-way and 4-way girlies ๐Ÿ”ฅ

template<template<typename _RAI, typename _Cp> class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
    _RAIter3 multiway_merge_3_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp)

Highly efficient 3-way merging procedure. highly efficient. the docs said highly. they meant it ๐Ÿ”ฅ

template<template<typename _RAI, typename _Cp> class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
    _RAIter3 multiway_merge_4_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp)

Highly efficient 4-way merging procedure. four ways this time, equally highly efficient, equally iconic ๐Ÿ‘‘

template<bool __stable, typename _RAIterIterator, typename _Compare, typename _DifferenceType>
    void multiway_merge_exact_splitting (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector<std::pair<_DifferenceType, _DifferenceType> > *__pieces)

Exact splitting for parallel multiway-merge routine. exact, not approximate, she does not do approximate โœจ


template<typename _LT, typename _RAIterIterator, typename _RAIter3,

bestie this one got cut off mid-signature in the source ๐Ÿ˜ญ โ€” she's literally still being written, we'll pick her back up in the next part, don't panic ๐Ÿซถ

typename _DifferenceTp, typename _Compare> _RAIter3
multiway_merge_loser_tree (_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp
__length, _Compare __comp)

Multi-way merging procedure for a high branching factor, guarded case. ๐Ÿ’… It's giving guarded merging realness, no cap.

  • multiway_merge_loser_tree_sentinel โ€” Multi-way merging procedure for a high branching factor, requiring sentinels to exist. ๐Ÿ›ก๏ธ
template<typename _UnguardedLoserTree, typename _RAIterIterator,
    typename _RAIter3, typename _DifferenceTp, typename _Compare>
    _RAIter3 multiway_merge_loser_tree_sentinel (_RAIterIterator
    __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const
    typename std::iterator_traits< typename std::iterator_traits<
    _RAIterIterator >::value_type::first_type >::value_type &__sentinel,
    _DifferenceTp __length, _Compare __comp)
  • multiway_merge_loser_tree_unguarded โ€” Multi-way merging procedure for a high branching factor, unguarded case. ๐Ÿ˜ˆ
template<typename _LT, typename _RAIterIterator, typename _RAIter3,
    typename _DifferenceTp, typename _Compare> _RAIter3
    multiway_merge_loser_tree_unguarded (_RAIterIterator __seqs_begin,
    _RAIterIterator __seqs_end, _RAIter3 __target, const typename
    std::iterator_traits< typename std::iterator_traits< _RAIterIterator
    >::value_type::first_type >::value_type &__sentinel, _DifferenceTp
    __length, _Compare __comp)
  • multiway_merge_sampling_splitting โ€” Sampling based splitting for parallel multiway-merge routine. ๐ŸŽฒ
template<bool __stable, typename _RAIterIterator, typename _Compare,
    typename _DifferenceType> void multiway_merge_sampling_splitting
    (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end,
    _DifferenceType __length, _DifferenceType __total_length, _Compare
    __comp, std::vector< std::pair< _DifferenceType, _DifferenceType > >
    *__pieces)
  • multiway_merge_sentinels (with __gnu_parallel::exact_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, __gnu_parallel::exact_tag __tag)
  • multiway_merge_sentinels (with __gnu_parallel::sequential_tag) โ€” Multiway Merge Frontend. ๐Ÿš€
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, __gnu_parallel::sequential_tag)
  • multiway_merge_sentinels (with default_parallel_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, default_parallel_tag __tag)
  • multiway_merge_sentinels (with parallel_tag __tag=parallel_tag(0))
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, parallel_tag __tag=parallel_tag(0))
  • multiway_merge_sentinels (with sampling_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, sampling_tag __tag)
  • parallel_multiway_merge โ€” Parallel multi-way merge routine. ๐Ÿ”ฅ
template<bool __stable, bool __sentinels, typename _RAIterIterator,
    typename _RAIter3, typename _DifferenceTp, typename _Splitter,
    typename _Compare> _RAIter3 parallel_multiway_merge (_RAIterIterator
    __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target,
    _Splitter __splitter, _DifferenceTp __length, _Compare __comp,
    _ThreadIndex __num_threads)
  • parallel_sort_mwms โ€” PMWMS main call. ๐Ÿ‘‘
template<bool __stable, bool __exact, typename _RAIter, typename
    _Compare> void parallel_sort_mwms (_RAIter __begin, _RAIter __end,
    _Compare __comp, _ThreadIndex __num_threads)
  • parallel_sort_mwms_pu โ€” PMWMS code executed by each thread. ๐Ÿงต
template<bool __stable, bool __exact, typename _RAIter, typename
    _Compare> void parallel_sort_mwms_pu (_PMWMSSortingData< _RAIter >
    *__sd, _Compare &__comp)
  • stable_multiway_merge (with __gnu_parallel::exact_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut stable_multiway_merge
    (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end,
    _RAIterOut __target, _DifferenceTp __length, _Compare __comp,
    __gnu_parallel::exact_tag __tag)
  • stable_multiway_merge (with __gnu_parallel::sequential_tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut stable_multiway_merge
    (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end,
    _RAIterOut __target, _DifferenceTp __length, _Compare __comp,
    __gnu_parallel::sequential_tag)
  • stable_multiway_merge (with default_parallel_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut stable_multiway_merge
    (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end,
    _RAIterOut __target, _DifferenceTp __length, _Compare __comp,
    default_parallel_tag __tag)
  • stable_multiway_merge (with parallel_tag __tag=parallel_tag(0))
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut stable_multiway_merge
    (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end,
    _RAIterOut __target, _DifferenceTp __length, _Compare __comp,
    parallel_tag __tag=parallel_tag(0))
  • stable_multiway_merge (with sampling_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut stable_multiway_merge
    (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end,
    _RAIterOut __target, _DifferenceTp __length, _Compare __comp,
    sampling_tag __tag)
  • stable_multiway_merge_sentinels (with __gnu_parallel::exact_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, __gnu_parallel::exact_tag __tag)
  • stable_multiway_merge_sentinels (with __gnu_parallel::sequential_tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, __gnu_parallel::sequential_tag)
  • stable_multiway_merge_sentinels (with default_parallel_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, default_parallel_tag __tag)
  • stable_multiway_merge_sentinels (with parallel_tag __tag=parallel_tag(0))
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, parallel_tag __tag=parallel_tag(0))
  • stable_multiway_merge_sentinels (with sampling_tag __tag)
template<typename _RAIterPairIterator, typename _RAIterOut, typename
    _DifferenceTp, typename _Compare> _RAIterOut
    stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin,
    _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp
    __length, _Compare __comp, sampling_tag __tag)

โœจ Variables โœจ

  • static const int _CASable_bits โ€” Number of bits of _CASable. ๐Ÿ”ข
  • static const _CASable _CASable_mask โ€” _CASable with the right half of bits set to 1. ๐ŸŽญ

๐Ÿ’… Detailed Description ๐Ÿ’…

GNU parallel code for public use. ๐Ÿ’– It's giving open-source, bestie. No cap.

๐ŸŽ€ Typedef Documentation ๐ŸŽ€

  • typedef unsigned short __gnu_parallel::_BinIndex โ€” Type to hold the index of a bin. Since many variables of this type are allocated, it should be chosen as small as possible. ๐Ÿ“ฆ
  • typedef int64_t __gnu_parallel::_CASable โ€” Longest compare-and-swappable integer type on this platform. ๐Ÿ”„
  • typedef uint64_t __gnu_parallel::_SequenceIndex โ€” Unsigned integer to index __elements. The total number of elements for each algorithm must fit into this type. ๐Ÿ”ข
  • typedef uint16_t __gnu_parallel::_ThreadIndex โ€” Unsigned integer to index a thread number. The maximum thread number (for each processor) must fit into this type. ๐Ÿงต

๐ŸŒˆ Enumeration Type Documentation ๐ŸŒˆ

  • enum __gnu_parallel::_AlgorithmStrategy โ€” Strategies for run-time algorithm selection: ๐Ÿง 
  • enum __gnu_parallel::_FindAlgorithm โ€” Find algorithms: ๐Ÿ”
  • enum __gnu_parallel::_MultiwayMergeAlgorithm โ€” Merging algorithms: ๐Ÿ”€
  • enum __gnu_parallel::_Parallelism โ€” Run-time equivalents for the compile-time tags. ๐Ÿท๏ธ
    • sequential โ€” Not parallel. ๐Ÿข
    • parallel_unbalanced โ€” Parallel unbalanced (equal-sized chunks). โš–๏ธ
    • parallel_balanced โ€” Parallel balanced (work-stealing). ๐Ÿคน
    • parallel_omp_loop โ€” Parallel with OpenMP dynamic load-balancing. ๐Ÿ”„
    • parallel_omp_loop_static โ€” Parallel with OpenMP static load-balancing. ๐Ÿ“Š
    • parallel_taskqueue โ€” Parallel with OpenMP taskqueue construct. ๐Ÿ“‹
  • enum __gnu_parallel::_PartialSumAlgorithm โ€” Partial sum algorithms: recursive, linear. โž•
  • enum __gnu_parallel::_SortAlgorithm โ€” Sorting algorithms: ๐Ÿ”ค
  • enum __gnu_parallel::_SplittingAlgorithm โ€” Sorting/merging algorithms: sampling, __exact. ๐ŸŽฏ

๐Ÿ”ฅ Function Documentation ๐Ÿ”ฅ

  • __calc_borders
template<typename _RAIter, typename _DifferenceTp> void
    __gnu_parallel::__calc_borders (_RAIter __elements, _DifferenceTp
    __length, _DifferenceTp * __off)

Precalculate __advances for Knuth-Morris-Pratt algorithm. ๐Ÿงฎ

Parameters

  • __elements โ€” Begin iterator of sequence to search for.
  • __length โ€” Length of sequence to search for.
  • __off โ€” Returned __offsets.

Referenced by __search_template().

  • __compare_and_swap
template<typename _Tp> bool __gnu_parallel::__compare_and_swap (volatile _Tp
    * __ptr, _Tp __comparand, _Tp __replacement) [inline]

Compare-and-swap. Compare *__ptr and __comparand. If equal, let *__ptr=__replacement and return true, return false otherwise. ๐Ÿ”„

Parameters

  • __ptr โ€” Pointer to signed integer.
  • __comparand โ€” Compare value.
  • __replacement โ€” Replacement value.

Referenced by __parallel_partition(), __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_back(), and __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_front().

  • __decode2
void __gnu_parallel::__decode2 (_CASable __x, int & __a, int & __b) [inline]

Decode two integers from one gnu_parallel::_CASable. ๐Ÿ”“

Parameters

  • __x โ€” __gnu_parallel::_CASable to decode integers from.
  • __a โ€” First integer, to be decoded from the most-significant _CASable_bits/2 bits of __x.
  • __b โ€” Second integer, to be encoded in the least-significant _CASable_bits/2 bits of __x.

See also __encode2

References _CASable_bits, and _CASable_mask.

Referenced by __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_back(), __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_front(), and __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::push_front().


๐ŸŒธ __determine_samples

template<typename _RAIter, typename _DifferenceTp>
void __gnu_parallel::__determine_samples(_PMWMSSortingData< _RAIter > * __sd, _DifferenceTp __num_samples)

okay so this one's whole job is picking out _M_samples from a sequence ๐Ÿ’… like it goes shopping and comes back with the samples, no cap.

Parameters

  • __sd โ€” pointer to the algorithm data, bestie. The _Result gets parked right into __sd->_M_samples.
  • __num_samples โ€” how many _M_samples we're selecting. the count, the whole vibe.

References โ€” __equally_split(), __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_samples, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_source, and __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_starts.


๐ŸŽ€ __encode2

_CASable __gnu_parallel::__encode2(int __a, int __b) [inline]

packing two integers into ONE gnu_parallel::_CASable. two little guys, one container. iconic honestly โœจ

Parameters

  • __a โ€” first integer, and it gets encoded into the most-significant _CASable_bits/2 bits. front of the line, main character.
  • __b โ€” second integer, encoded into the least-significant _CASable_bits/2 bits. back of the bus but still slaying.

Returns โ€” a value that encodes __a and __b together. periodt.

See also โ€” __decode2

References โ€” _CASable_bits.

Referenced by โ€” __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::_RestrictedBoundedConcurrentQueue(), __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_back(), __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::pop_front(), and __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::push_front().


๐Ÿฆ‹ __equally_split

template<typename _DifferenceType, typename _OutputIterator>
_OutputIterator __gnu_parallel::__equally_split(_DifferenceType __n, _ThreadIndex __num_threads, _OutputIterator __s)

the function that splits a sequence into parts of almost equal size ๐Ÿซถ and yes, the word is almost, don't come for me. the resulting sequence __s of length __num_threads+1 holds all the splitting positions you get when you split the range [0,__n) into parts of almost equal size (plus minus 1, okay, it's giving approximate). the first entry is 0, the last one is n. and heads up โ€” you may end up with empty parts. it happens. no one's judging ๐Ÿ™ˆ

Parameters

  • __n โ€” number of elements.
  • __num_threads โ€” number of parts.
  • __s โ€” the splitters themselves.

Returns โ€” the end of the __splitter sequence, i.e. __s+__num_threads+1.

Referenced by โ€” __determine_samples(), __find_template(), __parallel_partial_sum_linear(), __parallel_unique_copy(), __search_template(), and multiway_merge_exact_splitting().


๐ŸŒธ __equally_split_point

template<typename _DifferenceType>
_DifferenceType __gnu_parallel::__equally_split_point(_DifferenceType __n, _ThreadIndex __num_threads, _ThreadIndex __thread_no)

another splitter function, bestie, but this one's a little different โ€” it hands you the position of the splitting point between thread number __thread_no (included) and thread number __thread_no+1 (excluded). so it's literally telling you where the line is drawn between those two threads ๐Ÿ’…

Parameters

  • __n โ€” number of elements.
  • __num_threads โ€” number of parts.
  • __thread_no โ€” number of threads.

Returns โ€” the splitting point. that's it, that's the whole thing.

Referenced by โ€” __for_each_template_random_access_ed().


โœจ __fetch_and_add

template<typename _Tp>
_Tp __gnu_parallel::__fetch_and_add(volatile _Tp * __ptr, _Tp __addend) [inline]

adds a value to a variable, and it does it atomically ๐Ÿ”ฅ no race conditions, no drama, no two threads fighting over the same number like it's the last croissant.

Parameters

  • __ptr โ€” pointer to a signed integer.
  • __addend โ€” the value to add.

Referenced by โ€” __find_template(), __for_each_template_random_access_workstealing(), __parallel_partition(), and __gnu_parallel::_RestrictedBoundedConcurrentQueue< _Tp >::push_front().


๐Ÿ’œ __find_template (the dispatcher)

template<typename _RAIter1, typename _RAIter2, typename _Pred, typename _Selector>
std::pair< _RAIter1, _RAIter2 >
__gnu_parallel::__find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector) [inline]

this is the parallel std::find, and it's basically the switchboard operator that picks between the different algorithms ๐ŸŽ€ one call, many vibes.

Parameters

  • __begin1 โ€” begin iterator of the first sequence.
  • __end1 โ€” end iterator of the first sequence.
  • __begin2 โ€” begin iterator of the second sequence. must have same length as the first sequence, no exceptions.
  • __pred โ€” the find predicate.
  • __selector โ€” the _Functionality (e. g. std::find_if(), std::equal(),...).

Returns โ€” the place of finding in both sequences.

References โ€” __find_template(), __gnu_parallel::_Settings::get(), and std::make_pair().

Referenced by โ€” __find_template().


๐ŸŒˆ __find_template (constant block size variant)

template<typename _RAIter1, typename _RAIter2, typename _Pred, typename _Selector>
std::pair< _RAIter1, _RAIter2 >
__gnu_parallel::__find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, constant_size_blocks_tag)

parallel std::find, but the constant block size flavour. the blocks stay the same size the entire time. consistency queen ๐Ÿ‘‘

Parameters

  • __begin1 โ€” begin iterator of the first sequence.
  • __end1 โ€” end iterator of the first sequence.
  • __begin2 โ€” begin iterator of the second sequence. the second __sequence must have same length as the first sequence.
  • __pred โ€” the find predicate.
  • __selector โ€” the _Functionality (e. g. std::find_if(), std::equal(),...).

Returns โ€” the place of finding in both sequences.

See also

  • __gnu_parallel::_Settings::find_sequential_search_size
  • __gnu_parallel::_Settings::find_block_size

There are two main differences between the growing blocks and the constant-size blocks variants, and I'm listing them because they matter:

  1. For GB, the block size grows; for CSB, the block size is fixed.
  2. For GB, the blocks are allocated dynamically; for CSB, the blocks are allocated in a predetermined manner, namely spacial round-robin.

References โ€” _GLIBCXX_CALL, __gnu_parallel::_Settings::find_initial_block_size, __gnu_parallel::_Settings::find_sequential_search_size, std::pair< _T1, _T2 >::first, __gnu_parallel::_Settings::get(), and std::min().


โญ __find_template (equal splitting variant)

template<typename _RAIter1, typename _RAIter2, typename _Pred, typename _Selector>
std::pair< _RAIter1, _RAIter2 >
__gnu_parallel::__find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, equal_split_tag)

parallel std::find, equal splitting variant. everyone gets their fair share, we love an even split ๐Ÿซถ

Parameters

  • __begin1 โ€” begin iterator of the first sequence.
  • __end1 โ€” end iterator of the first sequence.
  • __begin2 โ€” begin iterator of the second sequence. the second __sequence must have same length as the first sequence.
  • __pred โ€” the find predicate.
  • __selector โ€” the _Functionality (e. g. std::find_if(), std::equal(),...).

Returns โ€” the place of finding in both sequences.

References โ€” __equally_split(), and _GLIBCXX_CALL.


๐Ÿ”ฅ __find_template (growing blocks variant)

template<typename _RAIter1, typename _RAIter2, typename _Pred, typename _Selector>
std::pair< _RAIter1, _RAIter2 >
__gnu_parallel::__find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, growing_blocks_tag)

parallel std::find, growing block size variant. the blocks literally start small and grow up. glow-up arc ๐ŸŒฑโžก๏ธ๐ŸŒณ

Parameters

  • __begin1 โ€” begin iterator of the first sequence.
  • __end1 โ€” end iterator of the first sequence.
  • __begin2 โ€” begin iterator of the second sequence. the second __sequence must have same length as the first sequence.
  • __pred โ€” the find predicate.
  • __selector โ€” the _Functionality (e. g. std::find_if(), std::equal(),...).

Returns โ€” the place of finding in both sequences.

See also

  • __gnu_parallel::_Settings::find_sequential_search_size
  • __gnu_parallel::_Settings::find_scale_factor

There are two main differences between the growing blocks and the constant-size blocks variants โ€” same list, because it's the same comparison:

  1. For GB, the block size grows; for CSB, the block size is fixed.
  2. For GB, the blocks are allocated dynamically; for CSB, the blocks are allocated in a predetermined manner, namely spacial round-robin.

References โ€” __fetch_and_add(), _GLIBCXX_CALL, __gnu_parallel::_Settings::find_scale_factor, __gnu_parallel::_Settings::find_sequential_search_size, std::pair< _T1, _T2 >::first, __gnu_parallel::_Settings::get(), std::max(), and std::min().


๐Ÿ’– __for_each_template_random_access

template<typename _IIter, typename _UserOp, typename _Functionality, typename _Red, typename _Result>
_UserOp
__gnu_parallel::__for_each_template_random_access(_IIter __begin, _IIter __end, _UserOp __user_op, _Functionality & __functionality, _Red __reduction, _Result __reduction_start, _Result & __output, typename std::iterator_traits< _IIter >::difference_type __bound, _Parallelism __parallelism_tag)

this one chooses the desired algorithm by evaluating __parallelism_tag. it's the group-chat admin deciding which plan we're going with based on the tag ๐Ÿ’…

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __user_op โ€” a user-specified functor (comparator, predicate, associative operator,...).
  • __functionality โ€” functor to process an element with __user_op (depends on desired functionality, e. g. accumulate, for_each,...).
  • __reduction โ€” reduction functor.
  • __reduction_start โ€” initial value for reduction.
  • __output โ€” output iterator.
  • __bound โ€” maximum number of elements processed.
  • __parallelism_tag โ€” the parallelization method.

References โ€” __for_each_template_random_access_ed(), __for_each_template_random_access_omp_loop(), __for_each_template_random_access_workstealing(), parallel_omp_loop, parallel_omp_loop_static, and parallel_unbalanced.


๐ŸŽ€ __for_each_template_random_access_ed

template<typename _RAIter, typename _Op, typename _Fu, typename _Red, typename _Result>
_Op
__gnu_parallel::__for_each_template_random_access_ed(_RAIter __begin, _RAIter __end, _Op __o, _Fu & __f, _Red __r, _Result __base, _Result & __output, typename std::iterator_traits< _RAIter >::difference_type __bound)

the embarrassingly parallel algorithm for random access iterators, doing hand-crafted parallelization by equal splitting the work โœจ hand-crafted!! artisanal!! no cap.

Parameters

  • __begin โ€” begin iterator of element sequence.
  • __end โ€” end iterator of element sequence.
  • __o โ€” user-supplied functor (comparator, predicate, adding functor, ...).
  • __f โ€” functor to "process" an element with __op (depends on desired functionality, e. g. for std::for_each(), ...).
  • __r โ€” functor to "add" a single __result to the already processed elements (depends on functionality).
  • __base โ€” base value for reduction.
  • __output โ€” pointer to position where final result is written to.
  • __bound โ€” maximum number of elements processed (e. g. for std::count_n()).

Returns โ€” the user-supplied functor (that may contain a part of the result). yeah, it hands the functor back to you, and it might be carrying some of the result inside. sneaky but iconic.

References โ€” __equally_split_point(), and min().

Referenced by โ€” __for_each_template_random_access().


๐Ÿงš __for_each_template_random_access_omp_loop

template<typename _RAIter, typename _Op, typename _Fu, typename _Red, typename _Result>
_Op
__gnu_parallel::__for_each_template_random_access_omp_loop(_RAIter __begin, _RAIter __end, _Op __o, _Fu & __f, _Red __r, _Result __base, _Result & __output, typename std::iterator_traits< _RAIter >::difference_type __bound)

embarrassingly parallel algorithm for random access iterators, but this time it's using an OpenMP for loop ๐ŸŒธ same energy, different engine.

โœจ Parameters โœจ

  • __begin โ€” begin iterator of the element sequence, bestie. where it all starts ๐Ÿซถ
  • __end โ€” end iterator of the element sequence. the finish line, we don't touch it.
  • __o โ€” the user-supplied functor (comparator, predicate, adding functor, whatever flavour of the above you're on today).
  • __f โ€” the functor that processes an element together with __op. what exactly it does depends on what you're trying to do, e.g. for std::for_each(), ...
  • __r โ€” the functor that adds a single __result onto the elements that have already been processed (again, depends on the functionality).
  • __base โ€” the base value for the reduction. the lil seed everything grows from ๐ŸŒฑ
  • __output โ€” pointer to the position where the final result gets written. the final destination, no cap.
  • __bound โ€” the maximum number of elements processed (e.g. for std::count_n()).

๐Ÿ’– Returns

The user-supplied functor (which may contain a part of the result). yes it hands you back your own functor, possibly holding onto some of the work it did.

References min().

Referenced by __for_each_template_random_access().


template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op
    __gnu_parallel::__for_each_template_random_access_omp_loop_static
    (_RAIter __begin, _RAIter __end, _Op __o, _Fu & __f, _Red __r, _Result
    __base, _Result & __output, typename std::iterator_traits< _RAIter
    >::difference_type __bound)

Embarrassingly parallel algorithm for random access iterators, and it does it with an OpenMP for loop on static scheduling. set it and forget it energy ๐Ÿ’…

๐ŸŒธ Parameters

  • __begin โ€” begin iterator of element sequence.
  • __end โ€” end iterator of element sequence.
  • __o โ€” user-supplied functor (comparator, predicate, adding functor, ...).
  • __f โ€” functor to process an element with __op (depends on desired functionality, e. g. for std::for_each(), ...).
  • __r โ€” functor to add a single __result to the already processed __elements (depends on functionality).
  • __base โ€” base value for reduction.
  • __output โ€” pointer to position where final result is written to
  • __bound โ€” maximum number of elements processed (e. g. for std::count_n()).

๐Ÿฆ‹ Returns

User-supplied functor (that may contain a part of the result).

References std::min().


template<typename _RAIter, typename _Op, typename _Fu, typename _Red,
    typename _Result> _Op
    __gnu_parallel::__for_each_template_random_access_workstealing (_RAIter
    __begin, _RAIter __end, _Op __op, _Fu & __f, _Red __r, _Result __base,
    _Result & __output, typename std::iterator_traits< _RAIter
    >::difference_type __bound)

Work stealing algorithm for random access iterators. this one is so iconic โ€” it uses O(1) additional memory, and the synchronization at the job lists is done with atomic operations. no locks, just vibes and atomics โœจ

๐Ÿ’œ Parameters

  • __begin โ€” begin iterator of element sequence.
  • __end โ€” end iterator of element sequence.
  • __op โ€” user-supplied functor (comparator, predicate, adding functor, ...).
  • __f โ€” functor to process an element with __op (depends on desired functionality, e. g. for std::for_each(), ...).
  • __r โ€” functor to add a single __result to the already processed elements (depends on functionality).
  • __base โ€” base value for reduction.
  • __output โ€” pointer to position where final result is written to
  • __bound โ€” maximum number of elements processed (e. g. for std::count_n()).

โญ Returns

User-supplied functor (that may contain a part of the result).

References __fetch_and_add(), __yield(), _GLIBCXX_CALL, __gnu_parallel::_Job< _DifferenceTp >::_M_first, __gnu_parallel::_Job< _DifferenceTp >::_M_last, __gnu_parallel::_Job< _DifferenceTp >::_M_load, __gnu_parallel::_Settings::cache_line_size, __gnu_parallel::_Settings::get(), max(), and min().

Referenced by __for_each_template_random_access().


template<typename _IIter, typename _Compare> bool
    __gnu_parallel::__is_sorted (_IIter __begin, _IIter __end, _Compare
    __comp)

Check whether [__begin, __end) is sorted according to __comp. vibe check but for ordering, honestly ๐ŸŽ€

๐Ÿ“ Parameters

  • __begin โ€” begin iterator of sequence.
  • __end โ€” end iterator of sequence.
  • __comp โ€” comparator.

๐Ÿ’ซ Returns

true if sorted, false otherwise. that's it, that's the answer.

Referenced by __sequential_multiway_merge(), multiway_merge_loser_tree_sentinel(), and parallel_multiway_merge().


template<typename _RAIter, typename _Compare> _RAIter
    __gnu_parallel::__median_of_three_iterators (_RAIter __a, _RAIter __b,
    _RAIter __c, _Compare __comp)

Compute the median of three referenced elements, according to __comp. three little iterators walk into a bar and one of them is the median ๐Ÿ’…

๐ŸŒˆ Parameters

  • __a โ€” first iterator.
  • __b โ€” second iterator.
  • __c โ€” third iterator.
  • __comp โ€” comparator.

Referenced by __qsb_divide().


template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __gnu_parallel::__merge_advance (_RAIter1 & __begin1, _RAIter1 __end1,
    _RAIter2 & __begin2, _RAIter2 __end2, _OutputIterator __target,
    _DifferenceTp __max_length, _Compare __comp) [inline]

Merge routine being able to merge only the __max_length smallest elements. The __begin iterators are advanced accordingly, and heads up โ€” they might not reach __end, in contrast to the usual variant. Also there's a static switch on whether to use the conditional-move variant. fancy ๐Ÿ˜Œ

๐ŸŒธ Parameters

  • __begin1 โ€” begin iterator of first sequence.
  • __end1 โ€” end iterator of first sequence.
  • __begin2 โ€” begin iterator of second sequence.
  • __end2 โ€” end iterator of second sequence.
  • __target โ€” target begin iterator.
  • __max_length โ€” maximum number of elements to merge.
  • __comp โ€” comparator.

๐Ÿ‘‘ Returns

Output end iterator.

References __merge_advance_movc(), and _GLIBCXX_CALL.

Referenced by __parallel_merge_advance(), and __sequential_multiway_merge().


template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __gnu_parallel::__merge_advance_movc (_RAIter1 & __begin1, _RAIter1
    __end1, _RAIter2 & __begin2, _RAIter2 __end2, _OutputIterator __target,
    _DifferenceTp __max_length, _Compare __comp)

Merge routine being able to merge only the __max_length smallest elements. The __begin iterators are advanced accordingly, and they might not reach __end, in contrast to the usual variant. This one has specially designed code so the compiler can generate conditional moves instead of branches. branchless bestie behaviour fr fr ๐Ÿงš

๐Ÿ’– Parameters

  • __begin1 โ€” begin iterator of first sequence.
  • __end1 โ€” end iterator of first sequence.
  • __begin2 โ€” begin iterator of second sequence.
  • __end2 โ€” end iterator of second sequence.
  • __target โ€” target begin iterator.
  • __max_length โ€” maximum number of elements to merge.
  • __comp โ€” comparator.

โœจ Returns

Output end iterator.

Referenced by __merge_advance().


template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
    typename _DifferenceTp, typename _Compare> _OutputIterator
    __gnu_parallel::__merge_advance_usual (_RAIter1 & __begin1, _RAIter1
    __end1, _RAIter2 & __begin2, _RAIter2 __end2, _OutputIterator __target,
    _DifferenceTp __max_length, _Compare __comp)

Merge routine being able to merge only the __max_length smallest elements. The __begin iterators are advanced accordingly, they might not reach __end, in contrast to the usual variant. no conditional-move tricks here, just the plain version doing its thing ๐Ÿซถ

๐ŸŒธ Parameters

  • __begin1 โ€” begin iterator of first sequence.
  • __end1 โ€” end iterator of first sequence.
  • __begin2 โ€” begin iterator of second sequence.
  • __end2 โ€” end iterator of second sequence.
  • __target โ€” target begin iterator.
  • __max_length โ€” maximum number of elements to merge.
  • __comp โ€” comparator.

๐Ÿฆ‹ Returns

Output end iterator.


template<typename _RAIter1, typename _RAIter3, typename _Compare> _RAIter3
    __gnu_parallel::__parallel_merge_advance (_RAIter1 & __begin1, _RAIter1
    __end1, _RAIter1 & __begin2, _RAIter1 __end2, _RAIter3 __target,
    typename std::iterator_traits< _RAIter1 >::difference_type __max_length,
    _Compare __comp) [inline]

Parallel merge routine being able to merge only the __max_length smallest elements. The __begin iterators are advanced accordingly, they might not reach __end, in contrast to the usual variant. The functionality is projected onto parallel_multiway_merge. glow up ๐Ÿ’…

๐Ÿ’œ Parameters

  • __begin1 โ€” begin iterator of first sequence.
  • __end1 โ€” end iterator of first sequence.
  • __begin2 โ€” begin iterator of second sequence.
  • __end2 โ€” end iterator of second sequence.
  • __target โ€” target begin iterator.
  • __max_length โ€” maximum number of elements to merge.
  • __comp โ€” comparator.

๐ŸŒˆ Returns

Output end iterator.

References std::make_pair(), multiway_merge_exact_splitting(), and parallel_multiway_merge().


template<typename _RAIter1, typename _RAIter2, typename _RAIter3, typename
    _Compare> _RAIter3 __gnu_parallel::__parallel_merge_advance (_RAIter1 &
    __begin1, _RAIter1 __end1, _RAIter2 & __begin2, _RAIter2 __end2,
    _RAIter3 __target, typename std::iterator_traits< _RAIter1
    >::difference_type __max_length, _Compare __comp) [inline]

Merge routine fallback to sequential in case the iterators of the two input sequences are of different type. sometimes you just gotta walk it yourself, and that's okay ๐Ÿ˜ญ

๐ŸŒธ Parameters

  • __begin1 โ€” begin iterator of first sequence.
  • __end1 โ€” end iterator of first sequence.
  • __begin2 โ€” begin iterator of second sequence.
  • __end2 โ€” end iterator of second sequence.
  • __target โ€” target begin iterator.
  • __max_length โ€” maximum number of elements to merge.
  • __comp โ€” comparator.

โญ Returns

Output end iterator.

References __merge_advance().


template<typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_nth_element (_RAIter __begin, _RAIter __nth,
    _RAIter __end, _Compare __comp)

Parallel implementation of std::nth_element(). same energy, more threads ๐Ÿ”ฅ

๐ŸŽ€ Parameters

  • __begin โ€” begin iterator of input sequence.
  • __nth โ€” _Iterator of element that must be in position afterwards.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

References __parallel_partition(), _GLIBCXX_CALL, __gnu_parallel::_Settings::get(), std::max(), __gnu_parallel::_Settings::nth_element_minimal_n, and __gnu_parallel::_Settings::partition_minimal_n.

Referenced by __parallel_partial_sort().


template<typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_partial_sort (_RAIter __begin, _RAIter
    __middle, _RAIter __end, _Compare __comp)

Parallel implementation of std::partial_sort(). partially sorted, fully slaying ๐Ÿ’…

๐Ÿฆ‹ Parameters

  • __begin โ€” begin iterator of input sequence.
  • __middle โ€” sort until this position.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

References __parallel_nth_element().


template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator __gnu_parallel::__parallel_partial_sum
    (_IIter __begin, _IIter __end, _OutputIterator __result,
    _BinaryOperation __bin_op)

Parallel partial sum front-__end. running total but make it multithreaded โœจ

๐Ÿ’– Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __result โ€” begin iterator of output sequence.
  • __bin_op โ€” associative binary function.

๐Ÿ‘‘ Returns

End iterator of output sequence.

References for the previous entry: __parallel_partial_sum_linear(), _GLIBCXX_CALL, and __gnu_parallel::_Settings::get(). ๐Ÿ’–


__gnu_parallel::__parallel_partial_sum_basecase ๐ŸŒธ

template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator
    __gnu_parallel::__parallel_partial_sum_basecase (_IIter __begin, _IIter
    __end, _OutputIterator __result, _BinaryOperation __bin_op, typename
    std::iterator_traits< _IIter >::value_type __value)

Okay bestie, this one is the base case prefix sum routine. ๐Ÿ’…

Parameters

  • __begin โ€” begin iterator of input sequence. ๐ŸŒŸ
  • __end โ€” end iterator of input sequence. โœจ
  • __result โ€” begin iterator of output sequence. ๐Ÿ’–
  • __bin_op โ€” associative binary function. ๐Ÿงš
  • __value โ€” start value. Must be passed since the neutral element is unknown in general. (no cap, itโ€™s required!) ๐Ÿ˜ญ

Returns

End iterator of output sequence. ๐Ÿซถ

Referenced by

  • __parallel_partial_sum_linear() ๐Ÿ’œ

__gnu_parallel::__parallel_partial_sum_linear ๐ŸŒˆ

template<typename _IIter, typename _OutputIterator, typename
    _BinaryOperation> _OutputIterator
    __gnu_parallel::__parallel_partial_sum_linear (_IIter __begin, _IIter
    __end, _OutputIterator __result, _BinaryOperation __bin_op, typename
    std::iterator_traits< _IIter >::difference_type __n)

This is the parallel partial sum implementation, two-phase approach, no recursion. Itโ€™s giving efficient. ๐Ÿ”ฅ

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __result โ€” begin iterator of output sequence.
  • __bin_op โ€” associative binary function.
  • __n โ€” length of sequence.

Returns

End iterator of output sequence. ๐Ÿ’–

References

  • __equally_split()
  • __parallel_partial_sum_basecase()
  • __gnu_parallel::_Settings::get()
  • std::max()
  • std::min()
  • __gnu_parallel::_Settings::partial_sum_dilation

Referenced by

  • __parallel_partial_sum()

__gnu_parallel::__parallel_partition ๐Ÿ’…

template<typename _RAIter, typename _Predicate> std::iterator_traits<
    _RAIter >::difference_type __gnu_parallel::__parallel_partition (_RAIter
    __begin, _RAIter __end, _Predicate __pred, _ThreadIndex __num_threads)

Parallel implementation of std::partition. Periodt. ๐ŸŽ€

Parameters

  • __begin โ€” begin iterator of input sequence to split.
  • __end โ€” end iterator of input sequence to split.
  • __pred โ€” partition predicate, possibly including some kind of pivot.
  • __num_threads โ€” maximum number of threads to use for this task.

Returns

Number of elements not fulfilling the predicate. ๐Ÿ˜ญ

References

  • __compare_and_swap()
  • __fetch_and_add()
  • _GLIBCXX_CALL
  • _GLIBCXX_VOLATILE
  • __gnu_parallel::_Settings::get()
  • std::max()
  • __gnu_parallel::_Settings::partition_chunk_share
  • __gnu_parallel::_Settings::partition_chunk_size

Referenced by

  • __parallel_nth_element()
  • __parallel_sort_qs_divide()
  • __qsb_divide()

__gnu_parallel::__parallel_random_shuffle ๐Ÿฆ‹

template<typename _RAIter, typename _RandomNumberGenerator> void
    __gnu_parallel::__parallel_random_shuffle (_RAIter __begin, _RAIter
    __end, _RandomNumberGenerator __rng = _RandomNumber()) [inline]

Parallel random public call. Itโ€™s the public vibe. โœจ

Parameters

  • __begin โ€” begin iterator of sequence.
  • __end โ€” end iterator of sequence.
  • __rng โ€” random number generator to use.

References

  • __parallel_random_shuffle_drs()

__gnu_parallel::__parallel_random_shuffle_drs ๐ŸŒธ

template<typename _RAIter, typename _RandomNumberGenerator> void
    __gnu_parallel::__parallel_random_shuffle_drs (_RAIter __begin, _RAIter
    __end, typename std::iterator_traits< _RAIter >::difference_type __n,
    _ThreadIndex __num_threads, _RandomNumberGenerator & __rng)

Main parallel random shuffle step. The main character of shuffling. ๐Ÿ‘‘

Parameters

  • __begin โ€” begin iterator of sequence.
  • __end โ€” end iterator of sequence.
  • __n โ€” length of sequence.
  • __num_threads โ€” number of threads to use.
  • __rng โ€” random number generator to use.

References

  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::__bins_end
  • __parallel_random_shuffle_drs_pu()
  • __rd_log2()
  • __round_up_to_pow2()
  • __sequential_random_shuffle()
  • _GLIBCXX_CALL
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_bin_proc
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_bins_begin
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_dist
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_num_bins
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_num_bits
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_num_threads
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_sd
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_seed
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_starts
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_temporaries
  • __gnu_parallel::_Settings::get()
  • __gnu_parallel::_Settings::L2_cache_size
  • std::max()
  • std::numeric_limits< _Tp >::max()
  • std::min()
  • __gnu_parallel::_Settings::TLB_size

Referenced by

  • __parallel_random_shuffle()

__gnu_parallel::__parallel_random_shuffle_drs_pu ๐Ÿงš

template<typename _RAIter, typename _RandomNumberGenerator> void
    __gnu_parallel::__parallel_random_shuffle_drs_pu (_DRSSorterPU< _RAIter,
    _RandomNumberGenerator > * __pus)

Random shuffle code executed by each thread. Itโ€™s giving teamwork. ๐Ÿซถ

Parameters

  • __pus โ€” array of thread-local data records.

References

  • __random_number_pow2()
  • __sequential_random_shuffle()
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_bin_proc
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_bins_begin
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_dist
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_num_bins
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_num_bits
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_num_threads
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_sd
  • __gnu_parallel::_DRSSorterPU< _RAIter, _RandomNumberGenerator >::_M_seed
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_source
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_starts
  • __gnu_parallel::_DRandomShufflingGlobalData< _RAIter >::_M_temporaries
  • std::partial_sum()

Referenced by

  • __parallel_random_shuffle_drs()

__gnu_parallel::__parallel_sort โ€” balanced_quicksort_tag ๐ŸŽ€

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, balanced_quicksort_tag __parallelism) [inline]

Choose balanced quicksort for parallel sorting. Slay. ๐Ÿ’…

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • __parallel_sort_qsb()
  • _GLIBCXX_CALL

__gnu_parallel::__parallel_sort โ€” default_parallel_tag โœจ

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, default_parallel_tag __parallelism) [inline]

Choose multiway mergesort with exact splitting, for parallel sorting. Itโ€™s giving exact. ๐Ÿ’–

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • _GLIBCXX_CALL

__gnu_parallel::__parallel_sort โ€” multiway_mergesort_exact_tag ๐ŸŒˆ

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, multiway_mergesort_exact_tag __parallelism) [inline]

Choose multiway mergesort with exact splitting, for parallel sorting. Same vibe, different tag. ๐Ÿ”ฅ

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • _GLIBCXX_CALL
  • parallel_sort_mwms()

__gnu_parallel::__parallel_sort โ€” multiway_mergesort_sampling_tag ๐Ÿฆ‹

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, multiway_mergesort_sampling_tag __parallelism) [inline]

Choose multiway mergesort with splitting by sampling, for parallel sorting. Sampling? We love a good sample. ๐Ÿ“

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • _GLIBCXX_CALL
  • parallel_sort_mwms()

__gnu_parallel::__parallel_sort โ€” multiway_mergesort_tag ๐Ÿ‘‘

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, multiway_mergesort_tag __parallelism) [inline]

Choose multiway mergesort, splitting variant at run-time, for parallel sorting. Run-time decisions? Main character energy. ๐Ÿ’…

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • _GLIBCXX_CALL
  • __gnu_parallel::_Settings::get()
  • parallel_sort_mwms()

__gnu_parallel::__parallel_sort โ€” parallel_tag ๐ŸŒŸ

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, parallel_tag __parallelism) [inline]

Choose a parallel sorting algorithm. The generic baddie. โœจ

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • __parallel_sort_qs()
  • __parallel_sort_qsb()
  • _GLIBCXX_CALL
  • __gnu_parallel::_Settings::get()
  • parallel_sort_mwms()

__gnu_parallel::__parallel_sort โ€” quicksort_tag ๐Ÿ’–

template<bool __stable, typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort (_RAIter __begin, _RAIter __end,
    _Compare __comp, quicksort_tag __parallelism) [inline]

Choose quicksort for parallel sorting. Quick like a bunny. ๐Ÿฆ‹

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator of input sequence.
  • __comp โ€” comparator.

Template Parameters

  • __stable โ€” sort stable.

References

  • __gnu_parallel::parallel_tag::__get_num_threads()
  • __parallel_sort_qs()
  • _GLIBCXX_CALL

__gnu_parallel::__parallel_sort_qs ๐Ÿ”ฅ

template<typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort_qs (_RAIter __begin, _RAIter __end,
    _Compare __comp, _ThreadIndex __num_threads)

Unbalanced quicksort main call. Itโ€™s unbalanced but thatโ€™s the vibe. ๐Ÿ’…

Parameters

  • __begin โ€” begin iterator of input sequence.
  • __end โ€” end iterator input sequence, ignored.
  • __comp โ€” comparator.
  • __num_threads โ€” number of threads that are allowed to work on this part.

References

  • __parallel_sort_qs_conquer()
  • _GLIBCXX_CALL

Referenced by

  • __parallel_sort()
  • __parallel_sort()

__gnu_parallel::__parallel_sort_qs_conquer ๐ŸŒธ

template<typename _RAIter, typename _Compare> void
    __gnu_parallel::__parallel_sort_qs_conquer (_RAIter __begin, _RAIter
    __end, _Compare __comp, _ThreadIndex __num_threads)

Unbalanced quicksort conquer step.

okay so the parameters for that last one are:

  • __begin โ€” Begin iterator of subsequence. ๐Ÿฆ‹
  • __end โ€” End iterator of subsequence. ๐Ÿฆ‹
  • __comp โ€” Comparator. ๐Ÿ’…
  • __num_threads โ€” Number of threads that are allowed to work on this part. ๐Ÿ‘‘

References: __parallel_sort_qs_conquer(), __parallel_sort_qs_divide(), and __gnu_parallel::_Settings::get(). โœจ

Referenced by: __parallel_sort_qs(), and __parallel_sort_qs_conquer(). ๐Ÿ’–


__gnu_parallel::__parallel_sort_qs_divide โ€” unbalanced quicksort divide step ๐Ÿ’…

template<typename _RAIter, typename _Compare>
std::iterator_traits< _RAIter >::difference_type
__gnu_parallel::__parallel_sort_qs_divide (_RAIter __begin, _RAIter __end,
    _Compare __comp,
    typename std::iterator_traits< _RAIter >::difference_type __pivot_rank,
    typename std::iterator_traits< _RAIter >::difference_type __num_samples,
    _ThreadIndex __num_threads)

Bestie, this is the unbalanced quicksort divide step. It's giving divide and conquer, but make it unbalanced. ๐Ÿ˜Œ

Parameters:

  • __begin โ€” Begin iterator of subsequence. ๐ŸŒธ
  • __end โ€” End iterator of subsequence. ๐ŸŒธ
  • __comp โ€” Comparator. ๐Ÿ’…
  • __pivot_rank โ€” Desired __rank of the pivot. ๐Ÿ‘‘
  • __num_samples โ€” Choose pivot from that many samples. ๐ŸŽฒ
  • __num_threads โ€” Number of threads that are allowed to work on this part. ๐Ÿ‘‘

References: __parallel_partition(), and std::min(). โœจ

Referenced by: __parallel_sort_qs_conquer(). ๐Ÿ’–


__gnu_parallel::__parallel_sort_qsb โ€” top-level quicksort routine ๐Ÿ‘‘

template<typename _RAIter, typename _Compare>
void
__gnu_parallel::__parallel_sort_qsb (_RAIter __begin, _RAIter __end,
    _Compare __comp, _ThreadIndex __num_threads)

This is the top-level quicksort routine. Main character energy fr fr. ๐Ÿ’…

Parameters:

  • __begin โ€” Begin iterator of sequence. ๐ŸŒˆ
  • __end โ€” End iterator of sequence. ๐ŸŒˆ
  • __comp โ€” Comparator. ๐Ÿ’…
  • __num_threads โ€” Number of threads that are allowed to work on this part. ๐Ÿ‘‘

References: __qsb_conquer(), __rd_log2(), _GLIBCXX_CALL, and std::make_pair(). โœจ

Referenced by: __parallel_sort(), and __parallel_sort(). ๐Ÿ’–


__gnu_parallel::__parallel_unique_copy โ€” parallel std::unique_copy() without explicit equality predicate ๐Ÿฆ‹

template<typename _IIter, class _OutputIterator>
_OutputIterator
__gnu_parallel::__parallel_unique_copy (_IIter __first, _IIter __last,
    _OutputIterator __result) [inline]

It's std::unique_copy() but parallel, and no explicit equality predicate. Iconic. โœจ

Parameters:

  • __first โ€” Begin iterator of input sequence. ๐Ÿ“
  • __last โ€” End iterator of input sequence. ๐Ÿ“
  • __result โ€” Begin iterator of result __sequence. ๐ŸŽ€

Returns: End iterator of result __sequence. ๐Ÿซถ

References: __parallel_unique_copy(). ๐Ÿ”ฅ


__gnu_parallel::__parallel_unique_copy โ€” parallel std::unique_copy() with explicit equality predicate ๐Ÿ’…

template<typename _IIter, class _OutputIterator, class _BinaryPredicate>
_OutputIterator
__gnu_parallel::__parallel_unique_copy (_IIter __first, _IIter __last,
    _OutputIterator __result, _BinaryPredicate __binary_pred)

Parallel std::unique_copy(), w/__o explicit equality predicate. (Yes, the original says w/__o โ€” we keep it exactly, no cap.) ๐Ÿ˜ญ

Parameters:

  • __first โ€” Begin iterator of input sequence. ๐Ÿ“
  • __last โ€” End iterator of input sequence. ๐Ÿ“
  • __result โ€” Begin iterator of result __sequence. ๐ŸŽ€
  • __binary_pred โ€” Equality predicate. ๐Ÿ’…

Returns: End iterator of result __sequence. ๐Ÿซถ

References: __equally_split(), and _GLIBCXX_CALL. โœจ

Referenced by: __parallel_unique_copy(). ๐Ÿ’–


__gnu_parallel::__qsb_conquer โ€” quicksort conquer step ๐Ÿ‘‘

template<typename _RAIter, typename _Compare>
void
__gnu_parallel::__qsb_conquer (_QSBThreadLocal< _RAIter > ** __tls,
    _RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __iam,
    _ThreadIndex __num_threads, bool __parent_wait)

Quicksort conquer step. It's giving conquer, not divide. ๐Ÿ˜Œ

Parameters:

  • __tls โ€” Array of thread-local storages. ๐Ÿงš
  • __begin โ€” Begin iterator of subsequence. ๐ŸŒธ
  • __end โ€” End iterator of subsequence. ๐ŸŒธ
  • __comp โ€” Comparator. ๐Ÿ’…
  • __iam โ€” Number of the thread processing this function. ๐Ÿ‘‘
  • __num_threads โ€” Number of threads that are allowed to work on this part. ๐Ÿ‘‘

References: __qsb_conquer(), __qsb_divide(), __qsb_local_sort_with_helping(), __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_elements_leftover, __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_initial, std::max(), and std::min(). โœจ

Referenced by: __parallel_sort_qsb(), and __qsb_conquer(). ๐Ÿ’–


__gnu_parallel::__qsb_divide โ€” balanced quicksort divide step โš–๏ธ

template<typename _RAIter, typename _Compare>
std::iterator_traits< _RAIter >::difference_type
__gnu_parallel::__qsb_divide (_RAIter __begin, _RAIter __end,
    _Compare __comp, _ThreadIndex __num_threads)

Balanced quicksort divide step. Balance is key, bestie. ๐Ÿ’…

Parameters:

  • __begin โ€” Begin iterator of subsequence. ๐ŸŒธ
  • __end โ€” End iterator of subsequence. ๐ŸŒธ
  • __comp โ€” Comparator. ๐Ÿ’…
  • __num_threads โ€” Number of threads that are allowed to work on this part. ๐Ÿ‘‘

Precondition: (__end-__begin)>=1 ๐Ÿšจ

You better have at least one element in there, fr fr.

References: __median_of_three_iterators(), and __parallel_partition(). โœจ

Referenced by: __qsb_conquer(). ๐Ÿ’–


__gnu_parallel::__qsb_local_sort_with_helping โ€” quicksort step doing load-balanced local sort ๐Ÿงš

template<typename _RAIter, typename _Compare>
void
__gnu_parallel::__qsb_local_sort_with_helping (_QSBThreadLocal< _RAIter > ** __tls,
    _Compare & __comp, _ThreadIndex __iam, bool __wait)

Quicksort step doing load-balanced local sort. It's helping, it's local, it's balanced. We love. โœจ

Parameters:

  • __tls โ€” Array of thread-local storages. ๐Ÿงš
  • __comp โ€” Comparator. ๐Ÿ’…
  • __iam โ€” Number of the thread processing this function. ๐Ÿ‘‘

References: __yield(), _GLIBCXX_PARALLEL_ASSERTIONS, __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_elements_leftover, __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_initial, __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_leftover_parts, __gnu_parallel::_QSBThreadLocal< _RAIter >::_M_num_threads, __gnu_parallel::_Settings::get(), std::make_pair(), and __gnu_parallel::_Settings::sort_qsb_base_case_maximal_n. โœจ

Referenced by: __qsb_conquer(). ๐Ÿ’–


__gnu_parallel::__random_number_pow2 โ€” generate a random number in [0,2^__logp) ๐ŸŽฒ

template<typename _RandomNumberGenerator>
int
__gnu_parallel::__random_number_pow2 (int __logp, _RandomNumberGenerator & __rng) [inline]

Generate a random number in [0,2^__logp). Random but make it powers of two. ๐Ÿ’…

Parameters:

  • __logp โ€” Logarithm (basis 2) of the upper range __bound. ๐Ÿ“
  • __rng โ€” Random number generator to use. ๐ŸŽฒ

Referenced by: __parallel_random_shuffle_drs_pu(), and __sequential_random_shuffle(). ๐Ÿ’–


__gnu_parallel::__rd_log2 โ€” rounded-down logarithm of __n for base 2 ๐Ÿ“

template<typename _Size>
_Size
__gnu_parallel::__rd_log2 (_Size __n) [inline]

Calculates the rounded-down logarithm of __n for base 2. Math queen. ๐Ÿ‘‘

Parameters:

  • __n โ€” Argument. ๐Ÿ”ข

Returns: Returns 0 for any argument <1. ๐Ÿซถ

Referenced by: __gnu_parallel::_LoserTreeBase< _Tp, _Compare >::_LoserTreeBase(), __parallel_random_shuffle_drs(), __parallel_sort_qsb(), __round_up_to_pow2(), __sequential_random_shuffle(), multiseq_partition(), and multiseq_selection(). ๐Ÿ’–


__gnu_parallel::__round_up_to_pow2 โ€” round up to the next greater power of 2 ๐Ÿ”ผ

template<typename _Tp>
_Tp
__gnu_parallel::__round_up_to_pow2 (_Tp __x)

Round up to the next greater power of 2. It's giving upward mobility. โœจ

Parameters:

  • __x โ€” _Integer to round up. ๐Ÿ”ข

References: __rd_log2(). โœจ

Referenced by: __parallel_random_shuffle_drs(), __sequential_random_shuffle(), and multiseq_selection(). ๐Ÿ’–


template<typename __RAIter1, typename __RAIter2, typename _Pred>
__RAIter1
__gnu_parallel::__search_template (__RAIter1 __begin1, __RAIter1 __end1,
    __RAIter2 __begin2, __RAIter2 __end2, _Pred __pred)

Parallel std::search. It's searching, but make it parallel. ๐Ÿ”โœจ

Parameters:

  • __begin1 โ€” Begin iterator of first sequence. ๐ŸŒธ
  • __end1 โ€” End iterator of first sequence. ๐ŸŒธ
  • __begin2 โ€” Begin iterator of second sequence. ๐ŸŒบ
  • __end2 โ€” End iterator of second sequence. ๐ŸŒบ
  • __pred โ€” Find predicate. ๐Ÿ’…

Returns: Place of finding in first sequences. ๐Ÿซถ

References: __calc_borders(), __equally_split(), _GLIBCXX_CALL, std::max(), and std::min(). โœจ


__gnu_parallel::__sequential_multiway_merge โ€” sequential multi-way merging switch ๐Ÿ”€

template<bool __stable, bool __sentinels, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
_RAIter3
__gnu_parallel::__sequential_multiway_merge (_RAIterIterator __seqs_begin,
    _RAIterIterator __seqs_end, _RAIter3 __target,
    const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type & __sentinel,
    _DifferenceTp __length, _Compare __comp)

Sequential multi-way merging switch. The _GLIBCXX_PARALLEL_DECISION is based on the branching factor and runtime settings. It's giving decision energy. ๐Ÿ’…

Parameters:

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence. ๐ŸŒˆ
  • __seqs_end โ€” End iterator of iterator pair input sequence. ๐ŸŒˆ
  • __target โ€” Begin iterator of output sequence. ๐ŸŽฏ
  • __comp โ€” Comparator. ๐Ÿ’…
  • __length โ€” Maximum length to merge, possibly larger than the number of elements available. ๐Ÿ“
  • __sentinel โ€” The sequences have __a __sentinel element. ๐Ÿ›ก๏ธ

Returns: End iterator of output sequence. ๐Ÿซถ

References: __is_sorted(), __merge_advance(), _GLIBCXX_CALL, _GLIBCXX_PARALLEL_LENGTH, and std::min(). โœจ

Referenced by: multiway_merge(), multiway_merge_sentinels(), and parallel_multiway_merge(). ๐Ÿ’–


__gnu_parallel::__sequential_random_shuffle โ€” sequential cache-efficient random shuffle ๐ŸŽฒ

template<typename _RAIter, typename _RandomNumberGenerator>
void
__gnu_parallel::__sequential_random_shuffle (_RAIter __begin, _RAIter __end,
    _RandomNumberGenerator & __rng)

Sequential cache-efficient random shuffle. Cache-friendly and random? We love a multi-talented icon. โœจ

Parameters:

  • __begin โ€” Begin iterator of sequence. ๐ŸŒธ
  • __end โ€” End iterator of sequence. ๐ŸŒธ
  • __rng โ€” Random number generator to use. ๐ŸŽฒ

References: __random_number_pow2(), __rd_log2(), __round_up_to_pow2(), __sequential_random_shuffle(), __gnu_parallel::_Settings::get(), __gnu_parallel::_Settings::L2_cache_size, std::max(), std::min(), std::partial_sum(), and __gnu_parallel::_Settings::TLB_size. โœจ

Referenced by: __parallel_random_shuffle_drs(), __parallel_random_shuffle_drs_pu(), and __sequential_random_shuffle(). ๐Ÿ’–


__gnu_parallel::__shrink โ€” combines two ranges into one and halves the number of ranges ๐Ÿ—œ๏ธ

template<typename _IIter>
void
__gnu_parallel::__shrink (std::vector< _IIter > & __os_starts, size_t & __count_to_two, size_t & __range_length)

Combines two ranges into one and thus halves the number of ranges. Shrink it down, bestie. ๐Ÿ’…

Parameters:

  • __os_starts โ€” Start positions worked on (oversampled). ๐Ÿ“
  • __count_to_two โ€” Counts up to 2. ๐Ÿ”ข
  • __range_length โ€” Current length of a chunk. ๐Ÿ“

References: std::vector< _Tp, _Alloc >::size(). โœจ

Referenced by: __shrink_and_double(). ๐Ÿ’–


__gnu_parallel::__shrink_and_double โ€” shrinks and doubles the ranges ๐Ÿ”„

template<typename _IIter>
void
__gnu_parallel::__shrink_and_double (std::vector< _IIter > & __os_starts,
    size_t & __count_to_two, size_t & __range_length, const bool __make_twice)

Shrinks and doubles the ranges. Shrink, then double. It's giving reversible jacket. ๐Ÿ˜ญ

Parameters:

  • __os_starts โ€” Start positions worked on (oversampled). ๐Ÿ“
  • __count_to_two โ€” Counts up to 2. ๐Ÿ”ข
  • __range_length โ€” Current length of a chunk. ๐Ÿ“
  • __make_twice โ€” Whether the __os_starts is allowed to be grown or not. ๐ŸŒฑ

References: __shrink(), std::vector< _Tp, _Alloc >::resize(), and std::vector< _Tp, _Alloc >::size(). โœจ

Referenced by: list_partition(). ๐Ÿ’–


__gnu_parallel::__yield โ€” yield control to another thread ๐Ÿ’…

void
__gnu_parallel::__yield () [inline]

Yield control to another thread, without waiting for the end of the time slice. It's giving generous. ๐Ÿซถ

Referenced by: __for_each_template_random_access_workstealing(), and __qsb_local_sort_with_helping(). ๐Ÿ’–


__gnu_parallel::list_partition โ€” splits a sequence into parts of almost equal size โœ‚๏ธ

template<typename _IIter, typename _FunctorType>
size_t
__gnu_parallel::list_partition (const _IIter __begin, const _IIter __end,
    _IIter * __starts, size_t * __lengths, const int __num_parts,
    _FunctorType & __f, int __oversampling = 0)

Splits a sequence given by input iterators into parts of almost equal size. The function needs only one pass over the sequence. One pass? Efficient queen. ๐Ÿ‘‘

### ๐Ÿ’ซ Parameters ๐Ÿ’ซ

  • __begin โ€” begin iterator of the input sequence, the og starting point bestie ๐Ÿซถ
  • __end โ€” end iterator of the input sequence, where the vibes stop
  • __starts โ€” start iterators for the resulting parts, dimension __num_parts+1. and for convenience?? __starts [__num_parts] contains the end iterator of the sequence. it's giving thoughtful โœจ
  • __lengths โ€” length of the resulting parts
  • __num_parts โ€” number of parts to split the sequence into, the way it just divides everything up ๐Ÿ’…
  • __f โ€” functor to be applied to each element by traversing __it
  • __oversampling โ€” oversampling factor. if 0, then the partitions will differ in at most $t{thrm{end} - thrm{begin}}$ elements. otherwise, the ratio between the longest and the shortest part is bounded by $1/(thrm{oversampling}

### ๐Ÿ”™ Returns ๐Ÿ”™

Length of the whole sequence. that's the whole return, no notes ๐Ÿ’–

### ๐Ÿ”— References ๐Ÿ”—

__shrink_and_double(), and std::vector< _Tp, _Alloc >::size().


### ๐Ÿฆ‹ max ๐Ÿฆ‹

template<typename _Tp> const _Tp & __gnu_parallel::max (const _Tp & __a, const _Tp & __b) [inline]

Equivalent to std::max. literally that's it, no cap ๐Ÿ”ฅ

Referenced by __for_each_template_random_access_workstealing().


### ๐Ÿฆ‹ min ๐Ÿฆ‹

template<typename _Tp> const _Tp & __gnu_parallel::min (const _Tp & __a, const _Tp & __b) [inline]

Equivalent to std::min. twin of the one above, obsessed ๐Ÿ’œ

Referenced by __for_each_template_random_access_ed(), __for_each_template_random_access_omp_loop(), and __for_each_template_random_access_workstealing().


### ๐ŸŒˆ multiseq_partition ๐ŸŒˆ

template<typename _RanSeqs, typename _RankType, typename _RankIterator, typename _Compare>
void __gnu_parallel::multiseq_partition (_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankIterator __begin_offsets, _Compare __comp = std::less< typename std::iterator_traits<typename std::iterator_traits<_RanSeqs>::value_type:: first_type>::value_type>())

Splits several sorted sequences at a certain global __rank, resulting in a splitting point for each sequence. The sequences are passed via a sequence of random-access iterator pairs, none of the sequences may be empty. If there are several equal elements across the split, the ones on the __left side will be chosen from sequences with smaller number. okay so it's got opinions and we respect them ๐Ÿ’…

#### Parameters

  • __begin_seqs โ€” begin of the sequence of iterator pairs
  • __end_seqs โ€” end of the sequence of iterator pairs
  • __rank โ€” the global rank to partition at
  • __begin_offsets โ€” a random-access __sequence __begin where the __result will be stored in. Each element of the sequence is an iterator that points to the first element on the greater part of the respective __sequence.
  • __comp โ€” the ordering functor, defaults to std::less<_Tp>

#### References

__rd_log2(), _GLIBCXX_CALL, std::distance(), std::priority_queue< _Tp, _Sequence, _Compare >::empty(), std::make_pair(), std::max(), std::min(), std::priority_queue< _Tp, _Sequence, _Compare >::pop(), std::priority_queue< _Tp, _Sequence, _Compare >::push(), and std::priority_queue< _Tp, _Sequence, _Compare >::top().

Referenced by multiway_merge_exact_splitting().


### ๐ŸŒธ multiseq_selection ๐ŸŒธ

template<typename _Tp, typename _RanSeqs, typename _RankType, typename _Compare>
_Tp __gnu_parallel::multiseq_selection (_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankType & __offset, _Compare __comp = std::less<_Tp>())

Selects the element at a certain global __rank from several sorted sequences. The sequences are passed via a sequence of random-access iterator pairs, none of the sequences may be empty. same rule as above, don't test it ๐Ÿซถ

#### Parameters

  • __begin_seqs โ€” begin of the sequence of iterator pairs
  • __end_seqs โ€” end of the sequence of iterator pairs
  • __rank โ€” the global rank to partition at
  • __offset โ€” the rank of the selected element in the global subsequence of elements equal to the selected element. If the selected element is unique, this number is 0. it's giving the chosen one โœจ
  • __comp โ€” the ordering functor, defaults to std::less

#### References

__rd_log2(), __round_up_to_pow2(), _GLIBCXX_CALL, std::distance(), std::priority_queue< _Tp, _Sequence, _Compare >::empty(), std::make_pair(), std::max(), std::min(), std::priority_queue< _Tp, _Sequence, _Compare >::pop(), std::priority_queue< _Tp, _Sequence, _Compare >::push(), and std::priority_queue< _Tp, _Sequence, _Compare >::top().


### ๐Ÿ‘‘ multiway_merge ๐Ÿ‘‘

template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare>
_RAIterOut __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag )

Multiway Merge Frontend. Merge the sequences specified by seqs_begin and __seqs_end into __target. __seqs_begin and __seqs_end must point to a sequence of pairs. These pairs must contain an iterator to the beginning of a sequence in their first entry and an iterator the _M_end of the same sequence in their second entry. so it's pairs of (start, end) and honestly? iconic structure ๐Ÿ’…

Ties are broken arbitrarily. See stable_multiway_merge for a variant that breaks ties by sequence number but is slower. speed or fairness, bestie, you literally cannot have both ๐Ÿ˜ญ

The first entries of the pairs (i.e. the begin iterators) will be moved forward. yes it mutates them, don't be surprised

The output sequence has to provide enough space for all elements that are written to it. do not skip this part, it will not be cute ๐Ÿ’€

This function will merge the input sequences:

  • not stable
  • parallel, depending on the input size and Settings
  • using sampling for splitting
  • not using sentinels

Example:

int sequences[10][10];
for (int __i = 0; __i < 10; ++__i)
  for (int __j = 0; __i < 10; ++__j)
    sequences[__i][__j] = __j;

int __out[33];
std::vector<std::pair<int*> > seqs;
for (int __i = 0; __i < 10; ++__i)
  { seqs.push(std::make_pair<int*>(sequences[__i],
                                   sequences[__i] + 10)) }

multiway_merge(seqs.begin(), seqs.end(), __target, std::less<int>(), 33);

#### See also

stable_multiway_merge

#### Precondition

All input sequences must be sorted.

Target must provide enough space to merge out length elements or the number of elements in all sequences, whichever is smaller.

#### Postcondition

[__target, return __value) contains merged __elements from the input sequences.

return __value - __target = min(__length, number of elements in all sequences).

#### Template Parameters

  • _RAIterPairIterator โ€” iterator over sequence of pairs of iterators
  • _RAIterOut โ€” iterator over target sequence
  • _DifferenceTp โ€” difference type for the sequence
  • _Compare โ€” strict weak ordering type to compare elements in sequences

#### Parameters

  • __seqs_begin โ€” __begin of sequence __sequence
  • __seqs_end โ€” _M_end of sequence __sequence
  • __target โ€” target sequence to merge to.
  • __comp โ€” strict weak ordering to use for element comparison.
  • __length โ€” Maximum length to merge, possibly larger than the number of elements available.

#### Returns

_M_end iterator of output sequence

#### References

__sequential_multiway_merge(), and _GLIBCXX_CALL.


### ๐Ÿš€ multiway_merge_3_variant ๐Ÿš€

template<template< typename _RAI, typename _Cp > class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
_RAIter3 __gnu_parallel::multiway_merge_3_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp)

Highly efficient 3-way merging procedure. Merging is done with the algorithm implementation described by Peter Sanders. Basically, the idea is to minimize the number of necessary comparison after merging an element. The implementation trick that makes this fast is that the order of the sequences is stored in the instruction pointer (translated into labels in C++). ngl that is unhinged in the best way ๐Ÿ”ฅ

This works well for merging up to 4 sequences.

Note that making the merging stable does not come at a performance hit. free stability?? we love to see it โœจ

Whether the merging is done guarded or unguarded is selected by the used iterator class.

#### Parameters

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence.
  • __seqs_end โ€” End iterator of iterator pair input sequence.
  • __target โ€” Begin iterator of output sequence.
  • __comp โ€” Comparator.
  • __length โ€” Maximum length to merge, less equal than the total number of elements available.

#### Returns

End iterator of output sequence.

#### References

_GLIBCXX_CALL.


### ๐Ÿš€ multiway_merge_4_variant ๐Ÿš€

template<template< typename _RAI, typename _Cp > class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
_RAIter3 __gnu_parallel::multiway_merge_4_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp)

Highly efficient 4-way merging procedure. Merging is done with the algorithm implementation described by Peter Sanders. Basically, the idea is to minimize the number of necessary comparison after merging an element. The implementation trick that makes this fast is that the order of the sequences is stored in the instruction pointer (translated into goto labels in C++). four-way edition, same chaotic genius energy ๐Ÿ’…

This works well for merging up to 4 sequences.

Note that making the merging stable does not come at a performance hit.

Whether the merging is done guarded or unguarded is selected by the used iterator class.

#### Parameters

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence.
  • __seqs_end โ€” End iterator of iterator pair input sequence.
  • __target โ€” Begin iterator of output sequence.
  • __comp โ€” Comparator.
  • __length โ€” Maximum length to merge, less equal than the total number of elements available.

#### Returns

End iterator of output sequence.

#### References

_GLIBCXX_CALL.


### โœ‚๏ธ multiway_merge_exact_splitting โœ‚๏ธ

template<bool __stable, typename _RAIterIterator, typename _Compare, typename _DifferenceType>
void __gnu_parallel::multiway_merge_exact_splitting (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector< std::pair< _DifferenceType, _DifferenceType > > * __pieces)

Exact splitting for parallel multiway-merge routine. None of the passed sequences may be empty. for real for real ๐Ÿซถ

#### References

__equally_split(), _GLIBCXX_PARALLEL_LENGTH, std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), multiseq_partition(), and std::vector< _Tp, _Alloc >::resize().

Referenced by __parallel_merge_advance().


### ๐ŸŒณ multiway_merge_loser_tree ๐ŸŒณ

template<typename _LT, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare>
_RAIter3 __gnu_parallel::multiway_merge_loser_tree (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp)

Multi-way merging procedure for a high branching factor, guarded case. This merging variant uses a LoserTree class as selected by _LT. it's called a loser tree and it is honestly the main character here ๐Ÿ‘‘

Stability is selected through the used LoserTree class _LT.

At least one non-empty sequence is required.

Parameters ๐Ÿ’–

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence. ๐Ÿซถ
  • __seqs_end โ€” End iterator of iterator pair input sequence. ๐Ÿซถ
  • __target โ€” Begin iterator of output sequence. ๐Ÿซถ
  • __comp โ€” Comparator. ๐Ÿซถ
  • __length โ€” Maximum length to merge, less equal than the total number of elements available. ๐Ÿซถ

Returns โœจ

End iterator of output sequence. ๐Ÿ’…

References ๐Ÿ”ฅ

_GLIBCXX_CALL, and _GLIBCXX_PARALLEL_LENGTH. no cap.


okay bestie, next function coming at you:

template<typename _UnguardedLoserTree, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare> _RAIter3 __gnu_parallel::multiway_merge_loser_tree_sentinel (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type & __sentinel, _DifferenceTp __length, _Compare __comp)

Multi-way merging procedure for a high branching factor, requiring sentinels to exist. ๐Ÿ›ก๏ธ

Template Parameters

  • _UnguardedLoserTree โ€” Loser Tree variant to use for the unguarded merging.

Parameters

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence.
  • __seqs_end โ€” End iterator of iterator pair input sequence.
  • __target โ€” Begin iterator of output sequence.
  • __comp โ€” Comparator.
  • __length โ€” Maximum length to merge, less equal than the total number of elements available.

Returns

End iterator of output sequence.

References

__is_sorted(), _GLIBCXX_CALL, and multiway_merge_loser_tree_unguarded().


template<typename _LT, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare> _RAIter3 __gnu_parallel::multiway_merge_loser_tree_unguarded (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type & __sentinel, _DifferenceTp __length, _Compare __comp)

Multi-way merging procedure for a high branching factor, unguarded case. Merging is done using the LoserTree class _LT. ๐ŸŒณ

Stability is selected by the used LoserTrees. ๐Ÿ’…

Precondition

No input will run out of elements during the merge. โš ๏ธ

Parameters

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence.
  • __seqs_end โ€” End iterator of iterator pair input sequence.
  • __target โ€” Begin iterator of output sequence.
  • __comp โ€” Comparator.
  • __length โ€” Maximum length to merge, less equal than the total number of elements available.

Returns

End iterator of output sequence.

References

_GLIBCXX_CALL.

Referenced by

multiway_merge_loser_tree_sentinel().


template<bool __stable, typename _RAIterIterator, typename _Compare, typename _DifferenceType> void __gnu_parallel::multiway_merge_sampling_splitting (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector< std::pair< _DifferenceType, _DifferenceType > > * __pieces)

Sampling based splitting for parallel multiway-merge routine. ๐ŸŽฒ

References

_GLIBCXX_PARALLEL_LENGTH, __gnu_parallel::_Settings::get(), and __gnu_parallel::_Settings::merge_oversampling.


template<typename _RAIterPairIterator, typename _RAIterOut, typename _DifferenceTp, typename _Compare> _RAIterOut __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag)

Multiway Merge Frontend. Merge the sequences specified by seqs_begin and __seqs_end into __target. __seqs_begin and __seqs_end must point to a sequence of pairs. These pairs must contain an iterator to the beginning of a sequence in their first entry and an iterator the _M_end of the same sequence in their second entry. ๐Ÿงฉ

Ties are broken arbitrarily. See stable_multiway_merge for a variant that breaks ties by sequence number but is slower. ๐Ÿข

The first entries of the pairs (i.e. the begin iterators) will be moved forward accordingly. โžก๏ธ

The output sequence has to provide enough space for all elements that are written to it. ๐Ÿ“ฆ

This function will merge the input sequences:

  • not stable
  • parallel, depending on the input size and Settings
  • using sampling for splitting
  • using sentinels

You have to take care that the element the _M_end iterator points to is readable and contains a value that is greater than any other non-sentinel value in all sequences. ๐Ÿšจ

Example:

int sequences[10][11];
for (int __i = 0; __i < 10; ++__i)
  for (int __j = 0; __i < 11; ++__j)
    sequences[__i][__j] = __j; // __last one is sentinel!

int __out[33];
std::vector<std::pair<int*> > seqs;
for (int __i = 0; __i < 10; ++__i)
  { seqs.push(std::make_pair<int*>(sequences[__i],
                                   sequences[__i] + 10)) }

multiway_merge(seqs.begin(), seqs.end(), __target, std::less<int>(), 33);

Precondition

All input sequences must be sorted. ๐Ÿ“ˆ

Target must provide enough space to merge out length elements or the number of elements in all sequences, whichever is smaller. ๐Ÿ“

For each __i, __seqs_begin[__i].second must be the end marker of the sequence, but also reference the one more __sentinel element. ๐Ÿ›ก๏ธ

Postcondition

[__target, return __value) contains merged __elements from the input sequences. ๐ŸŽฏ

return __value - __target = min(__length, number of elements in all sequences). ๐Ÿงฎ

See also

stable_multiway_merge_sentinels

Template Parameters

  • _RAIterPairIterator โ€” iterator over sequence of pairs of iterators
  • _RAIterOut โ€” iterator over target sequence
  • _DifferenceTp โ€” difference type for the sequence
  • _Compare โ€” strict weak ordering type to compare elements in sequences

Parameters

  • __seqs_begin โ€” __begin of sequence __sequence
  • __seqs_end โ€” _M_end of sequence __sequence
  • __target โ€” target sequence to merge to.
  • __comp โ€” strict weak ordering to use for element comparison.
  • __length โ€” Maximum length to merge, possibly larger than the number of elements available.

Returns

_M_end iterator of output sequence

References

__sequential_multiway_merge(), and _GLIBCXX_CALL.


template<bool __stable, bool __sentinels, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Splitter, typename _Compare> _RAIter3 __gnu_parallel::parallel_multiway_merge (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _Splitter __splitter, _DifferenceTp __length, _Compare __comp, _ThreadIndex __num_threads)

Parallel multi-way merge routine. The _GLIBCXX_PARALLEL_DECISION is based on the branching factor and runtime settings. โš™๏ธ

Must not be called if the number of sequences is 1. ๐Ÿšซ

Template Parameters

  • _Splitter โ€” functor to split input (either __exact or sampling based)
  • __stable โ€” Stable merging incurs a performance penalty.
  • __sentinel โ€” Ignored.

Parameters

  • __seqs_begin โ€” Begin iterator of iterator pair input sequence.
  • __seqs_end โ€” End iterator of iterator pair input sequence.
  • __target โ€” Begin iterator of output sequence.
  • __comp โ€” Comparator.
  • __length โ€” Maximum length to merge, possibly larger than the number of elements available.

Returns

End iterator of output sequence.

References

__is_sorted(), __sequential_multiway_merge(), _GLIBCXX_CALL, _GLIBCXX_PARALLEL_LENGTH, __gnu_parallel::_Settings::get(), std::make_pair(), __gnu_parallel::_Settings::merge_oversampling, and std::min().

Referenced by

__parallel_merge_advance().


template<bool __stable, bool __exact, typename _RAIter, typename _Compare> void __gnu_parallel::parallel_sort_mwms (_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads)

PMWMS main call. ๐Ÿ

Parameters

  • __begin โ€” Begin iterator of sequence.
  • __end โ€” End iterator of sequence.
  • __comp โ€” Comparator.
  • __num_threads โ€” Number of threads to use.

References

_GLIBCXX_CALL, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_num_threads, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_offsets, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_pieces, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_samples, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_source, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_starts, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_temporary, __gnu_parallel::_Settings::get(), parallel_sort_mwms_pu(), and __gnu_parallel::_Settings::sort_mwms_oversampling.

Referenced by

__parallel_sort(), __parallel_sort(), __parallel_sort(), and __parallel_sort().


template<bool __stable, bool __exact, typename _RAIter, typename _Compare> void __gnu_parallel::parallel_sort_mwms_pu (_PMWMSSortingData< _RAIter > * __sd, _Compare & __comp)

PMWMS code executed by each thread. ๐Ÿงต

Parameters

  • __sd โ€” Pointer to algorithm data.
  • __comp โ€” Comparator.

References

__gnu_parallel::_PMWMSSortingData< _RAIter >::_M_num_threads, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_pieces, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_source, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_starts, __gnu_parallel::_PMWMSSortingData< _RAIter >::_M_temporary, __gnu_parallel::_Settings::get(), std::make_pair(), __gnu_parallel::_Settings::sort_mwms_oversampling, and std::uninitialized_copy().

Referenced by

parallel_sort_mwms().


Variable Documentation ๐Ÿ’–

const int __gnu_parallel::_CASable_bits [static]

Number of bits of _CASable. ๐Ÿ”ข

Referenced by __decode2(), and __encode2().

const _CASable __gnu_parallel::_CASable_mask [static]

_CASable with the right half of bits set to 1. ๐ŸŽญ

Referenced by __decode2().


Author โœ๏ธ

Generated automatically by Doxygen for libstdc++ from the source code. ๐Ÿค–


๐Ÿ’– and that's the whole __gnu_parallel(3) page, bestie! source/version: libstdc++ ยท __gnu_parallel(3) ยท date: (the footer didn't show one, but it's giving timeless โœจ). stay iconic, stay parallel. ๐Ÿ‘‘๐Ÿฆ‹
๐Ÿ“ฆ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 ยท GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • centos-stream 10: libstdc++-docs 14.4.1-4.el10 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 43: libstdc++-docs 15.2.1-2.fc43 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 43: libstdc++-docs 15.3.1-1.fc43 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms