libstdc++
|
00001 // -*- C++ -*- 00002 00003 // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the terms 00007 // of the GNU General Public License as published by the Free Software 00008 // Foundation; either version 3, or (at your option) any later 00009 // version. 00010 00011 // This library is distributed in the hope that it will be useful, but 00012 // WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file parallel/types.h 00026 * @brief Basic types and typedefs. 00027 * This file is a GNU parallel extension to the Standard C++ Library. 00028 */ 00029 00030 // Written by Johannes Singler and Felix Putze. 00031 00032 #ifndef _GLIBCXX_PARALLEL_TYPES_H 00033 #define _GLIBCXX_PARALLEL_TYPES_H 1 00034 00035 #include <cstdlib> 00036 #include <limits> 00037 #include <tr1/cstdint> 00038 00039 namespace __gnu_parallel 00040 { 00041 // Enumerated types. 00042 00043 /// Run-time equivalents for the compile-time tags. 00044 enum _Parallelism 00045 { 00046 /// Not parallel. 00047 sequential, 00048 00049 /// Parallel unbalanced (equal-sized chunks). 00050 parallel_unbalanced, 00051 00052 /// Parallel balanced (work-stealing). 00053 parallel_balanced, 00054 00055 /// Parallel with OpenMP dynamic load-balancing. 00056 parallel_omp_loop, 00057 00058 /// Parallel with OpenMP static load-balancing. 00059 parallel_omp_loop_static, 00060 00061 /// Parallel with OpenMP taskqueue construct. 00062 parallel_taskqueue 00063 }; 00064 00065 /// Strategies for run-time algorithm selection: 00066 // force_sequential, force_parallel, heuristic. 00067 enum _AlgorithmStrategy 00068 { 00069 heuristic, 00070 force_sequential, 00071 force_parallel 00072 }; 00073 00074 /// Sorting algorithms: 00075 // multi-way mergesort, quicksort, load-balanced quicksort. 00076 enum _SortAlgorithm 00077 { 00078 MWMS, 00079 QS, 00080 QS_BALANCED 00081 }; 00082 00083 /// Merging algorithms: 00084 // bubblesort-alike, loser-tree variants, enum __sentinel. 00085 enum _MultiwayMergeAlgorithm 00086 { 00087 LOSER_TREE 00088 }; 00089 00090 /// Partial sum algorithms: recursive, linear. 00091 enum _PartialSumAlgorithm 00092 { 00093 RECURSIVE, 00094 LINEAR 00095 }; 00096 00097 /// Sorting/merging algorithms: sampling, __exact. 00098 enum _SplittingAlgorithm 00099 { 00100 SAMPLING, 00101 EXACT 00102 }; 00103 00104 /// Find algorithms: 00105 // growing blocks, equal-sized blocks, equal splitting. 00106 enum _FindAlgorithm 00107 { 00108 GROWING_BLOCKS, 00109 CONSTANT_SIZE_BLOCKS, 00110 EQUAL_SPLIT 00111 }; 00112 00113 /** 00114 * @brief Unsigned integer to index __elements. 00115 * The total number of elements for each algorithm must fit into this type. 00116 */ 00117 typedef uint64_t _SequenceIndex; 00118 00119 /** 00120 * @brief Unsigned integer to index a thread number. 00121 * The maximum thread number (for each processor) must fit into this type. 00122 */ 00123 typedef uint16_t _ThreadIndex; 00124 00125 // XXX atomics interface? 00126 /// Longest compare-and-swappable integer type on this platform. 00127 typedef int64_t _CASable; 00128 00129 /// Number of bits of _CASable. 00130 static const int _CASable_bits = std::numeric_limits<_CASable>::digits; 00131 00132 /// ::_CASable with the right half of bits set to 1. 00133 static const _CASable _CASable_mask = 00134 ((_CASable(1) << (_CASable_bits / 2)) - 1); 00135 } 00136 00137 #endif /* _GLIBCXX_PARALLEL_TYPES_H */