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 00037 namespace __gnu_parallel 00038 { 00039 // Enumerated types. 00040 00041 /// Run-time equivalents for the compile-time tags. 00042 enum _Parallelism 00043 { 00044 /// Not parallel. 00045 sequential, 00046 00047 /// Parallel unbalanced (equal-sized chunks). 00048 parallel_unbalanced, 00049 00050 /// Parallel balanced (work-stealing). 00051 parallel_balanced, 00052 00053 /// Parallel with OpenMP dynamic load-balancing. 00054 parallel_omp_loop, 00055 00056 /// Parallel with OpenMP static load-balancing. 00057 parallel_omp_loop_static, 00058 00059 /// Parallel with OpenMP taskqueue construct. 00060 parallel_taskqueue 00061 }; 00062 00063 /// Strategies for run-time algorithm selection: 00064 // force_sequential, force_parallel, heuristic. 00065 enum _AlgorithmStrategy 00066 { 00067 heuristic, 00068 force_sequential, 00069 force_parallel 00070 }; 00071 00072 /// Sorting algorithms: 00073 // multi-way mergesort, quicksort, load-balanced quicksort. 00074 enum _SortAlgorithm 00075 { 00076 MWMS, 00077 QS, 00078 QS_BALANCED 00079 }; 00080 00081 /// Merging algorithms: 00082 // bubblesort-alike, loser-tree variants, enum sentinel. 00083 enum _MultiwayMergeAlgorithm 00084 { 00085 LOSER_TREE 00086 }; 00087 00088 /// Partial sum algorithms: recursive, linear. 00089 enum _PartialSumAlgorithm 00090 { 00091 RECURSIVE, 00092 LINEAR 00093 }; 00094 00095 /// Sorting/merging algorithms: sampling, exact. 00096 enum _SplittingAlgorithm 00097 { 00098 SAMPLING, 00099 EXACT 00100 }; 00101 00102 /// Find algorithms: 00103 // growing blocks, equal-sized blocks, equal splitting. 00104 enum _FindAlgorithm 00105 { 00106 GROWING_BLOCKS, 00107 CONSTANT_SIZE_BLOCKS, 00108 EQUAL_SPLIT 00109 }; 00110 00111 /// Integer Types. 00112 // XXX need to use <cstdint> 00113 /** @brief 16-bit signed integer. */ 00114 typedef short int16; 00115 00116 /** @brief 16-bit unsigned integer. */ 00117 typedef unsigned short uint16; 00118 00119 /** @brief 32-bit signed integer. */ 00120 typedef int int32; 00121 00122 /** @brief 32-bit unsigned integer. */ 00123 typedef unsigned int uint32; 00124 00125 /** @brief 64-bit signed integer. */ 00126 typedef long long int64; 00127 00128 /** @brief 64-bit unsigned integer. */ 00129 typedef unsigned long long uint64; 00130 00131 /** 00132 * @brief Unsigned integer to index elements. 00133 * The total number of elements for each algorithm must fit into this type. 00134 */ 00135 typedef uint64 sequence_index_t; 00136 00137 /** 00138 * @brief Unsigned integer to index a thread number. 00139 * The maximum thread number (for each processor) must fit into this type. 00140 */ 00141 typedef uint16 thread_index_t; 00142 00143 // XXX atomics interface? 00144 /// Longest compare-and-swappable integer type on this platform. 00145 typedef int64 lcas_t; 00146 00147 // XXX numeric_limits::digits? 00148 /// Number of bits of ::lcas_t. 00149 static const int lcas_t_bits = sizeof(lcas_t) * 8; 00150 00151 /// ::lcas_t with the right half of bits set to 1. 00152 static const lcas_t lcas_t_mask = ((lcas_t(1) << (lcas_t_bits / 2)) - 1); 00153 } 00154 00155 #endif /* _GLIBCXX_PARALLEL_TYPES_H */