]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/parallel/types.h
types.h: Remove enum parallelism.
[thirdparty/gcc.git] / libstdc++-v3 / include / parallel / types.h
1 // -*- C++ -*-
2
3 // Copyright (C) 2007, 2008 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 2, 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 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
20
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
29 // Public License.
30
31 /** @file parallel/types.h
32 * @brief Basic types and typedefs.
33 * This file is a GNU parallel extension to the Standard C++ Library.
34 */
35
36 // Written by Johannes Singler and Felix Putze.
37
38 #ifndef _GLIBCXX_PARALLEL_TYPES_H
39 #define _GLIBCXX_PARALLEL_TYPES_H 1
40
41 #include <cstdlib>
42 #include <tr1/cstdint>
43
44 namespace __gnu_parallel
45 {
46 // Enumerated types.
47
48 /// @brief Run-time equivalents for the compile-time tags.
49 enum parallelism
50 {
51 /// Not parallel.
52 sequential,
53
54 /// Parallel unbalanced (equal-sized chunks).
55 parallel_unbalanced,
56
57 /// Parallel balanced (work-stealing).
58 parallel_balanced,
59
60 /// Parallel with OpenMP dynamic load-balancing.
61 parallel_omp_loop,
62
63 /// Parallel with OpenMP static load-balancing.
64 parallel_omp_loop_static,
65
66 /// Parallel with OpenMP taskqueue construct.
67 parallel_taskqueue
68 };
69
70 inline bool
71 is_parallel(const parallelism __p) { return __p != sequential; }
72
73 /// Integer Types.
74 using std::tr1::int16_t;
75 using std::tr1::uint16_t;
76
77 using std::tr1::int32_t;
78 using std::tr1::uint32_t;
79
80 using std::tr1::int64_t;
81 using std::tr1::uint64_t;
82
83 /**
84 * @brief Unsigned integer to index elements.
85 * The total number of elements for each algorithm must fit into this type.
86 */
87 typedef uint64_t sequence_index_t;
88
89 /**
90 * @brief Unsigned integer to index a thread number.
91 * The maximum thread number (for each processor) must fit into this type.
92 */
93 typedef uint16_t thread_index_t;
94
95 // XXX atomics interface?
96 /**
97 * @brief Longest compare-and-swappable integer type on this platform.
98 */
99 typedef int64_t lcas_t;
100
101 // XXX numeric_limits::digits?
102 /**
103 * @brief Number of bits of ::lcas_t.
104 */
105 static const int lcas_t_bits = sizeof(lcas_t) * 8;
106
107 /**
108 * @brief ::lcas_t with the right half of bits set to 1.
109 */
110 static const lcas_t lcas_t_mask = ((lcas_t(1) << (lcas_t_bits / 2)) - 1);
111 }
112
113 #endif /* _GLIBCXX_TYPES_H */