STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
settings.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 // Copyright (C) 2007-2013 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 
81 // Written by Johannes Singler and Felix Putze.
82 
83 #ifndef _GLIBCXX_PARALLEL_SETTINGS_H
84 #define _GLIBCXX_PARALLEL_SETTINGS_H 1
85 
86 #include <parallel/types.h>
87 
95 #define _GLIBCXX_PARALLEL_CONDITION(__c) \
96  (__gnu_parallel::_Settings::get().algorithm_strategy \
97  != __gnu_parallel::force_sequential \
98  && ((__gnu_parallel::__get_max_threads() > 1 && (__c)) \
99  || __gnu_parallel::_Settings::get().algorithm_strategy \
100  == __gnu_parallel::force_parallel))
101 
102 /*
103 inline bool
104 parallel_condition(bool __c)
105 {
106  bool ret = false;
107  const _Settings& __s = _Settings::get();
108  if (__s.algorithm_strategy != force_seqential)
109  {
110  if (__s.algorithm_strategy == force_parallel)
111  ret = true;
112  else
113  ret = __get_max_threads() > 1 && __c;
114  }
115  return ret;
116 }
117 */
118 
119 namespace __gnu_parallel
120 {
123  struct _Settings
124  {
126 
131 
135 
136  // Per-algorithm settings.
137 
140 
143 
146 
149 
152 
155 
158 
161 
164 
167 
170 
173 
175  unsigned int merge_oversampling;
176 
179 
182 
185 
188 
191 
194 
198 
201 
204 
208 
210  unsigned int partial_sum_minimal_n;
211 
214 
217 
220 
223 
226 
229 
232 
235 
238 
242 
245 
248 
250 
251  // Hardware dependent tuning parameters.
252 
254  unsigned long long L1_cache_size;
255 
257  unsigned long long L2_cache_size;
258 
260  unsigned int TLB_size;
261 
265  unsigned int cache_line_size;
266 
267  // Statistics.
268 
271 
274 
277 
279  _GLIBCXX_CONST static const _Settings&
280  get() throw();
281 
283  static void
284  set(_Settings&) throw();
285 
286  explicit
294  merge_splitting(EXACT),
296  accumulate_minimal_n(1000),
298  count_minimal_n(1000),
299  fill_minimal_n(1000),
304  for_each_minimal_n(1000),
305  generate_minimal_n(1000),
306  max_element_minimal_n(1000),
307  merge_minimal_n(1000),
308  merge_oversampling(10),
309  min_element_minimal_n(1000),
312  nth_element_minimal_n(1000),
313  partition_chunk_size(1000),
315  partition_minimal_n(1000),
317  partial_sum_dilation(1.0f),
318  partial_sum_minimal_n(1000),
320  replace_minimal_n(1000),
324  set_union_minimal_n(1000),
325  sort_minimal_n(1000),
329  transform_minimal_n(1000),
330  unique_copy_minimal_n(10000),
332  L1_cache_size(16 << 10),
333  L2_cache_size(256 << 10),
334  TLB_size(128),
335  cache_line_size(64),
336  qsb_steals(0),
337  search_minimal_n(1000),
338  find_scale_factor(0.01f)
339  { }
340  };
341 }
342 
343 #endif /* _GLIBCXX_PARALLEL_SETTINGS_H */
unsigned int cache_line_size
Definition: settings.h:265
_PartialSumAlgorithm
Partial sum algorithms: recursive, linear.
Definition: types.h:91
_SplittingAlgorithm sort_splitting
Definition: settings.h:132
_SequenceIndex search_minimal_n
Minimal input size for search and search_n.
Definition: settings.h:273
Basic types and typedefs. This file is a GNU parallel extension to the Standard C++ Library...
Definition: settings.h:123
_SequenceIndex find_sequential_search_size
Start with looking for this many elements sequentially, for find.
Definition: settings.h:160
_SequenceIndex partition_chunk_size
Chunk size for partition.
Definition: settings.h:193
_SequenceIndex count_minimal_n
Minimal input size for count and count_if.
Definition: settings.h:145
_SequenceIndex set_difference_minimal_n
Minimal input size for set_difference.
Definition: settings.h:219
_SequenceIndex set_symmetric_difference_minimal_n
Minimal input size for set_symmetric_difference.
Definition: settings.h:225
_SequenceIndex multiway_merge_minimal_n
Minimal input size for multiway_merge.
Definition: settings.h:181
_SequenceIndex find_initial_block_size
Initial block size for find.
Definition: settings.h:154
static void set(_Settings &)
Set the global settings.
_SequenceIndex workstealing_chunk_size
Definition: settings.h:249
_AlgorithmStrategy algorithm_strategy
Definition: settings.h:125
_MultiwayMergeAlgorithm
Merging algorithms:
Definition: types.h:85
unsigned int TLB_size
size of the Translation Lookaside Buffer (underestimation).
Definition: settings.h:260
_SequenceIndex accumulate_minimal_n
Minimal input size for accumulate.
Definition: settings.h:139
_SequenceIndex fill_minimal_n
Minimal input size for fill.
Definition: settings.h:148
_SequenceIndex merge_minimal_n
Minimal input size for merge.
Definition: settings.h:172
_SplittingAlgorithm multiway_merge_splitting
Definition: settings.h:134
unsigned int random_shuffle_minimal_n
Minimal input size for random_shuffle.
Definition: settings.h:213
unsigned long long L1_cache_size
size of the L1 cache in bytes (underestimation).
Definition: settings.h:254
_SequenceIndex sort_qsb_base_case_maximal_n
Definition: settings.h:241
_SequenceIndex transform_minimal_n
Minimal input size for parallel std::transform.
Definition: settings.h:244
_SplittingAlgorithm
Sorting/merging algorithms: sampling, __exact.
Definition: types.h:98
double partition_chunk_share
Definition: settings.h:197
_SequenceIndex replace_minimal_n
Minimal input size for replace and replace_if.
Definition: settings.h:216
_FindAlgorithm find_algorithm
Definition: settings.h:130
unsigned long long L2_cache_size
size of the L2 cache in bytes (underestimation).
Definition: settings.h:257
unsigned int multiway_merge_oversampling
Oversampling factor for multiway_merge.
Definition: settings.h:187
_MultiwayMergeAlgorithm multiway_merge_algorithm
Definition: settings.h:129
Definition: types.h:87
_FindAlgorithm
Find algorithms:
Definition: types.h:106
_SequenceIndex set_union_minimal_n
Minimal input size for set_union.
Definition: settings.h:228
_SequenceIndex nth_element_minimal_n
Minimal input size for nth_element.
Definition: settings.h:190
unsigned int adjacent_difference_minimal_n
Minimal input size for adjacent_difference.
Definition: settings.h:142
_SequenceIndex sort_minimal_n
Minimal input size for parallel sorting.
Definition: settings.h:231
Definition: types.h:78
_PartialSumAlgorithm partial_sum_algorithm
Definition: settings.h:128
_SequenceIndex for_each_minimal_n
Minimal input size for for_each.
Definition: settings.h:163
unsigned int merge_oversampling
Oversampling factor for merge.
Definition: settings.h:175
unsigned int sort_qs_num_samples_preset
Such many samples to take to find a good pivot (quicksort).
Definition: settings.h:237
_SortAlgorithm
Sorting algorithms:
Definition: types.h:76
Definition: types.h:69
unsigned int sort_mwms_oversampling
Oversampling factor for parallel std::sort (MWMS).
Definition: settings.h:234
_SequenceIndex qsb_steals
The number of stolen ranges in load-balanced quicksort.
Definition: settings.h:270
_SequenceIndex min_element_minimal_n
Minimal input size for min_element.
Definition: settings.h:178
_SequenceIndex generate_minimal_n
Minimal input size for generate.
Definition: settings.h:166
uint64_t _SequenceIndex
Unsigned integer to index __elements. The total number of elements for each algorithm must fit into t...
Definition: types.h:117
_SequenceIndex partition_minimal_n
Minimal input size for partition.
Definition: settings.h:200
_SequenceIndex unique_copy_minimal_n
Minimal input size for unique_copy.
Definition: settings.h:247
float find_scale_factor
Block size scale-down factor with respect to current position.
Definition: settings.h:276
float partial_sum_dilation
Definition: settings.h:207
Definition: types.h:94
Definition: types.h:101
unsigned int partial_sum_minimal_n
Minimal input size for partial_sum.
Definition: settings.h:210
double find_increasing_factor
Block size increase factor for find.
Definition: settings.h:151
_SequenceIndex find_maximum_block_size
Maximal block size for find.
Definition: settings.h:157
_SequenceIndex partial_sort_minimal_n
Minimal input size for partial_sort.
Definition: settings.h:203
_SequenceIndex set_intersection_minimal_n
Minimal input size for set_intersection.
Definition: settings.h:222
_AlgorithmStrategy
Strategies for run-time algorithm selection:
Definition: types.h:67
int multiway_merge_minimal_k
Oversampling factor for multiway_merge.
Definition: settings.h:184
_SortAlgorithm sort_algorithm
Definition: settings.h:127
_SequenceIndex max_element_minimal_n
Minimal input size for max_element.
Definition: settings.h:169
_SplittingAlgorithm merge_splitting
Definition: settings.h:133