00001 // -*- C++ -*- 00002 00003 // Copyright (C) 2007, 2008 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 2, 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 // You should have received a copy of the GNU General Public License 00017 // along with this library; see the file COPYING. If not, write to 00018 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, 00019 // MA 02111-1307, USA. 00020 00021 // As a special exception, you may use this file as part of a free 00022 // software library without restriction. Specifically, if other files 00023 // instantiate templates or use macros or inline functions from this 00024 // file, or you compile this file and link it with other files to 00025 // produce an executable, this file does not by itself cause the 00026 // resulting executable to be covered by the GNU General Public 00027 // License. This exception does not however invalidate any other 00028 // reasons why the executable file might be covered by the GNU General 00029 // Public License. 00030 00031 /** @file parallel/types.h 00032 * @brief Basic types and typedefs. 00033 * This file is a GNU parallel extension to the Standard C++ Library. 00034 */ 00035 00036 // Written by Johannes Singler and Felix Putze. 00037 00038 #ifndef _GLIBCXX_PARALLEL_TYPES_H 00039 #define _GLIBCXX_PARALLEL_TYPES_H 1 00040 00041 #include <cstdlib> 00042 00043 namespace __gnu_parallel 00044 { 00045 // Enumerated types. 00046 00047 /// Run-time equivalents for the compile-time tags. 00048 enum _Parallelism 00049 { 00050 /// Not parallel. 00051 sequential, 00052 00053 /// Parallel unbalanced (equal-sized chunks). 00054 parallel_unbalanced, 00055 00056 /// Parallel balanced (work-stealing). 00057 parallel_balanced, 00058 00059 /// Parallel with OpenMP dynamic load-balancing. 00060 parallel_omp_loop, 00061 00062 /// Parallel with OpenMP static load-balancing. 00063 parallel_omp_loop_static, 00064 00065 /// Parallel with OpenMP taskqueue construct. 00066 parallel_taskqueue 00067 }; 00068 00069 /// Strategies for run-time algorithm selection: 00070 // force_sequential, force_parallel, heuristic. 00071 enum _AlgorithmStrategy 00072 { 00073 heuristic, 00074 force_sequential, 00075 force_parallel 00076 }; 00077 00078 /// Sorting algorithms: 00079 // multi-way mergesort, quicksort, load-balanced quicksort. 00080 enum _SortAlgorithm 00081 { 00082 MWMS, 00083 QS, 00084 QS_BALANCED 00085 }; 00086 00087 /// Merging algorithms: 00088 // bubblesort-alike, loser-tree variants, enum sentinel. 00089 enum _MultiwayMergeAlgorithm 00090 { 00091 BUBBLE, 00092 LOSER_TREE_EXPLICIT, 00093 LOSER_TREE, 00094 LOSER_TREE_COMBINED, 00095 LOSER_TREE_SENTINEL, 00096 ENUM_SENTINEL 00097 }; 00098 00099 /// Partial sum algorithms: recursive, linear. 00100 enum _PartialSumAlgorithm 00101 { 00102 RECURSIVE, 00103 LINEAR 00104 }; 00105 00106 /// Sorting/merging algorithms: sampling, exact. 00107 enum _SplittingAlgorithm 00108 { 00109 SAMPLING, 00110 EXACT 00111 }; 00112 00113 /// Find algorithms: 00114 // growing blocks, equal-sized blocks, equal splitting. 00115 enum _FindAlgorithm 00116 { 00117 GROWING_BLOCKS, 00118 CONSTANT_SIZE_BLOCKS, 00119 EQUAL_SPLIT 00120 }; 00121 00122 /// Integer Types. 00123 // XXX need to use <cstdint> 00124 /** @brief 16-bit signed integer. */ 00125 typedef short int16; 00126 00127 /** @brief 16-bit unsigned integer. */ 00128 typedef unsigned short uint16; 00129 00130 /** @brief 32-bit signed integer. */ 00131 typedef int int32; 00132 00133 /** @brief 32-bit unsigned integer. */ 00134 typedef unsigned int uint32; 00135 00136 /** @brief 64-bit signed integer. */ 00137 typedef long long int64; 00138 00139 /** @brief 64-bit unsigned integer. */ 00140 typedef unsigned long long uint64; 00141 00142 /** 00143 * @brief Unsigned integer to index elements. 00144 * The total number of elements for each algorithm must fit into this type. 00145 */ 00146 typedef uint64 sequence_index_t; 00147 00148 /** 00149 * @brief Unsigned integer to index a thread number. 00150 * The maximum thread number (for each processor) must fit into this type. 00151 */ 00152 typedef uint16 thread_index_t; 00153 00154 // XXX atomics interface? 00155 /// Longest compare-and-swappable integer type on this platform. 00156 typedef int64 lcas_t; 00157 00158 // XXX numeric_limits::digits? 00159 /// Number of bits of ::lcas_t. 00160 static const int lcas_t_bits = sizeof(lcas_t) * 8; 00161 00162 /// ::lcas_t with the right half of bits set to 1. 00163 static const lcas_t lcas_t_mask = ((lcas_t(1) << (lcas_t_bits / 2)) - 1); 00164 } 00165 00166 #endif /* _GLIBCXX_TYPES_H */