libstdc++: types.h Source File

libstdc++

types.h
Go to the documentation of this file.
1// -*- C++ -*-
2
3// Copyright (C) 2007-2026 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the terms
7// of the GNU General Public License as published by the Free Software
8// Foundation; either version 3, or (at your option) any later
9// version.
10
11// This library is distributed in the hope that it will be useful, but
12// WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file parallel/types.h
26 * @brief Basic types and typedefs.
27 * This file is a GNU parallel extension to the Standard C++ Library.
28 */
29
30// Written by Johannes Singler and Felix Putze.
31
32#ifndef _GLIBCXX_PARALLEL_TYPES_H
33#define _GLIBCXX_PARALLEL_TYPES_H 1
34
35#include <cstdlib>
36#include <limits>
37#include <tr1/cstdint>
38
39namespace __gnu_parallel
40{
41 // Enumerated types.
42
43 /// Run-time equivalents for the compile-time tags.
44 enum _Parallelism
45 {
46 /// Not parallel.
47 sequential,
48
49 /// Parallel unbalanced (equal-sized chunks).
50 parallel_unbalanced,
51
52 /// Parallel balanced (work-stealing).
53 parallel_balanced,
54
55 /// Parallel with OpenMP dynamic load-balancing.
56 parallel_omp_loop,
57
58 /// Parallel with OpenMP static load-balancing.
59 parallel_omp_loop_static,
60
61 /// Parallel with OpenMP taskqueue construct.
62 parallel_taskqueue
63 };
64
65 /// Strategies for run-time algorithm selection:
66 // force_sequential, force_parallel, heuristic.
67 enum _AlgorithmStrategy
68 {
69 heuristic,
70 force_sequential,
71 force_parallel
72 };
73
74 /// Sorting algorithms:
75 // multi-way mergesort, quicksort, load-balanced quicksort.
76 enum _SortAlgorithm
77 {
78 MWMS,
79 QS,
80 QS_BALANCED
81 };
82
83 /// Merging algorithms:
84 // bubblesort-alike, loser-tree variants, enum __sentinel.
85 enum _MultiwayMergeAlgorithm
86 {
87 LOSER_TREE
88 };
89
90 /// Partial sum algorithms: recursive, linear.
91 enum _PartialSumAlgorithm
92 {
93 RECURSIVE,
94 LINEAR
95 };
96
97 /// Sorting/merging algorithms: sampling, __exact.
98 enum _SplittingAlgorithm
99 {
100 SAMPLING,
101 EXACT
102 };
103
104 /// Find algorithms:
105 // growing blocks, equal-sized blocks, equal splitting.
106 enum _FindAlgorithm
107 {
108 GROWING_BLOCKS,
109 CONSTANT_SIZE_BLOCKS,
110 EQUAL_SPLIT
111 };
112
113 /**
114 * @brief Unsigned integer to index __elements.
115 * The total number of elements for each algorithm must fit into this type.
116 */
117 typedef uint64_t _SequenceIndex;
118
119 /**
120 * @brief Unsigned integer to index a thread number.
121 * The maximum thread number (for each processor) must fit into this type.
122 */
123 typedef uint16_t _ThreadIndex;
124
125 // XXX atomics interface?
126 /// Longest compare-and-swappable integer type on this platform.
127 typedef int64_t _CASable;
128
129 /// Number of bits of _CASable.
130 static const int _CASable_bits = std::numeric_limits<_CASable>::digits;
131
132 /// ::_CASable with the right half of bits set to 1.
133 static const _CASable _CASable_mask =
134 ((_CASable(1) << (_CASable_bits / 2)) - 1);
135}
136
137#endif /* _GLIBCXX_PARALLEL_TYPES_H */
limits
cstdlib
__gnu_parallel
GNU parallel code for public use.
Definition balanced_quicksort.h:62
__gnu_parallel::_ThreadIndex
uint16_t _ThreadIndex
Unsigned integer to index a thread number. The maximum thread number (for each processor) must fit in...
Definition types.h:123
__gnu_parallel::_FindAlgorithm
_FindAlgorithm
Find algorithms:
Definition types.h:107
__gnu_parallel::_SequenceIndex
uint64_t _SequenceIndex
Unsigned integer to index __elements. The total number of elements for each algorithm must fit into t...
Definition types.h:117
__gnu_parallel::_SortAlgorithm
_SortAlgorithm
Sorting algorithms:
Definition types.h:77
__gnu_parallel::_PartialSumAlgorithm
_PartialSumAlgorithm
Partial sum algorithms: recursive, linear.
Definition types.h:92
__gnu_parallel::_Parallelism
_Parallelism
Run-time equivalents for the compile-time tags.
Definition types.h:45
__gnu_parallel::parallel_balanced
@ parallel_balanced
Parallel balanced (work-stealing).
Definition types.h:53
__gnu_parallel::sequential
@ sequential
Not parallel.
Definition types.h:47
__gnu_parallel::parallel_omp_loop_static
@ parallel_omp_loop_static
Parallel with OpenMP static load-balancing.
Definition types.h:59
__gnu_parallel::parallel_unbalanced
@ parallel_unbalanced
Parallel unbalanced (equal-sized chunks).
Definition types.h:50
__gnu_parallel::parallel_omp_loop
@ parallel_omp_loop
Parallel with OpenMP dynamic load-balancing.
Definition types.h:56
__gnu_parallel::parallel_taskqueue
@ parallel_taskqueue
Parallel with OpenMP taskqueue construct.
Definition types.h:62
__gnu_parallel::_CASable
int64_t _CASable
Longest compare-and-swappable integer type on this platform.
Definition types.h:127
__gnu_parallel::_MultiwayMergeAlgorithm
_MultiwayMergeAlgorithm
Merging algorithms:
Definition types.h:86
__gnu_parallel::_AlgorithmStrategy
_AlgorithmStrategy
Strategies for run-time algorithm selection:
Definition types.h:68
__gnu_parallel::_SplittingAlgorithm
_SplittingAlgorithm
Sorting/merging algorithms: sampling, __exact.
Definition types.h:99
__gnu_parallel::_CASable_mask
static const _CASable _CASable_mask
_CASable with the right half of bits set to 1.
Definition types.h:133
__gnu_parallel::_CASable_bits
static const int _CASable_bits
Number of bits of _CASable.
Definition types.h:130
std::__numeric_limits_base::digits
static constexpr int digits
Definition limits:218
cstdint