Make arm_feature_set agree with type of FL_* macros
[official-gcc.git] / libstdc++-v3 / include / parallel / tags.h
blob376f36cd7e1fff7d62bb6fa7d4a4226b1cfe539a
1 // -*- C++ -*-
3 // Copyright (C) 2007-2016 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.
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.
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.
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/>.
25 /**
26 * @file parallel/tags.h
27 * @brief Tags for compile-time selection.
28 * This file is a GNU parallel extension to the Standard C++ Library.
31 // Written by Johannes Singler and Felix Putze.
33 #ifndef _GLIBCXX_PARALLEL_TAGS_H
34 #define _GLIBCXX_PARALLEL_TAGS_H 1
36 #include <omp.h>
37 #include <parallel/types.h>
39 namespace __gnu_parallel
41 /** @brief Forces sequential execution at compile time. */
42 struct sequential_tag { };
44 /** @brief Recommends parallel execution at compile time,
45 * optionally using a user-specified number of threads. */
46 struct parallel_tag
48 private:
49 _ThreadIndex _M_num_threads;
51 public:
52 /** @brief Default constructor. Use default number of threads. */
53 parallel_tag()
54 { _M_num_threads = 0; }
56 /** @brief Default constructor. Recommend number of threads to use.
57 * @param __num_threads Desired number of threads. */
58 parallel_tag(_ThreadIndex __num_threads)
59 { _M_num_threads = __num_threads; }
61 /** @brief Find out desired number of threads.
62 * @return Desired number of threads. */
63 _ThreadIndex __get_num_threads()
65 if(_M_num_threads == 0)
66 return omp_get_max_threads();
67 else
68 return _M_num_threads;
71 /** @brief Set the desired number of threads.
72 * @param __num_threads Desired number of threads. */
73 void set_num_threads(_ThreadIndex __num_threads)
74 { _M_num_threads = __num_threads; }
77 /** @brief Recommends parallel execution using the
78 default parallel algorithm. */
79 struct default_parallel_tag : public parallel_tag
81 default_parallel_tag() { }
82 default_parallel_tag(_ThreadIndex __num_threads)
83 : parallel_tag(__num_threads) { }
86 /** @brief Recommends parallel execution using dynamic
87 load-balancing at compile time. */
88 struct balanced_tag : public parallel_tag { };
90 /** @brief Recommends parallel execution using static
91 load-balancing at compile time. */
92 struct unbalanced_tag : public parallel_tag { };
94 /** @brief Recommends parallel execution using OpenMP dynamic
95 load-balancing at compile time. */
96 struct omp_loop_tag : public parallel_tag { };
98 /** @brief Recommends parallel execution using OpenMP static
99 load-balancing at compile time. */
100 struct omp_loop_static_tag : public parallel_tag { };
103 /** @brief Base class for for std::find() variants. */
104 struct find_tag { };
107 /** @brief Forces parallel merging
108 * with exact splitting, at compile time. */
109 struct exact_tag : public parallel_tag
111 exact_tag() { }
112 exact_tag(_ThreadIndex __num_threads)
113 : parallel_tag(__num_threads) { }
116 /** @brief Forces parallel merging
117 * with exact splitting, at compile time. */
118 struct sampling_tag : public parallel_tag
120 sampling_tag() { }
121 sampling_tag(_ThreadIndex __num_threads)
122 : parallel_tag(__num_threads) { }
126 /** @brief Forces parallel sorting using multiway mergesort
127 * at compile time. */
128 struct multiway_mergesort_tag : public parallel_tag
130 multiway_mergesort_tag() { }
131 multiway_mergesort_tag(_ThreadIndex __num_threads)
132 : parallel_tag(__num_threads) { }
135 /** @brief Forces parallel sorting using multiway mergesort
136 * with exact splitting at compile time. */
137 struct multiway_mergesort_exact_tag : public parallel_tag
139 multiway_mergesort_exact_tag() { }
140 multiway_mergesort_exact_tag(_ThreadIndex __num_threads)
141 : parallel_tag(__num_threads) { }
144 /** @brief Forces parallel sorting using multiway mergesort
145 * with splitting by sampling at compile time. */
146 struct multiway_mergesort_sampling_tag : public parallel_tag
148 multiway_mergesort_sampling_tag() { }
149 multiway_mergesort_sampling_tag(_ThreadIndex __num_threads)
150 : parallel_tag(__num_threads) { }
153 /** @brief Forces parallel sorting using unbalanced quicksort
154 * at compile time. */
155 struct quicksort_tag : public parallel_tag
157 quicksort_tag() { }
158 quicksort_tag(_ThreadIndex __num_threads)
159 : parallel_tag(__num_threads) { }
162 /** @brief Forces parallel sorting using balanced quicksort
163 * at compile time. */
164 struct balanced_quicksort_tag : public parallel_tag
166 balanced_quicksort_tag() { }
167 balanced_quicksort_tag(_ThreadIndex __num_threads)
168 : parallel_tag(__num_threads) { }
172 /** @brief Selects the growing block size variant for std::find().
173 @see _GLIBCXX_FIND_GROWING_BLOCKS */
174 struct growing_blocks_tag : public find_tag { };
176 /** @brief Selects the constant block size variant for std::find().
177 @see _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS */
178 struct constant_size_blocks_tag : public find_tag { };
180 /** @brief Selects the equal splitting variant for std::find().
181 @see _GLIBCXX_FIND_EQUAL_SPLIT */
182 struct equal_split_tag : public find_tag { };
185 #endif /* _GLIBCXX_PARALLEL_TAGS_H */