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 LOSER_TREE 00092 }; 00093 00094 /// Partial sum algorithms: recursive, linear. 00095 enum _PartialSumAlgorithm 00096 { 00097 RECURSIVE, 00098 LINEAR 00099 }; 00100 00101 /// Sorting/merging algorithms: sampling, exact. 00102 enum _SplittingAlgorithm 00103 { 00104 SAMPLING, 00105 EXACT 00106 }; 00107 00108 /// Find algorithms: 00109 // growing blocks, equal-sized blocks, equal splitting. 00110 enum _FindAlgorithm 00111 { 00112 GROWING_BLOCKS, 00113 CONSTANT_SIZE_BLOCKS, 00114 EQUAL_SPLIT 00115 }; 00116 00117 /// Integer Types. 00118 // XXX need to use <cstdint> 00119 /** @brief 16-bit signed integer. */ 00120 typedef short int16; 00121 00122 /** @brief 16-bit unsigned integer. */ 00123 typedef unsigned short uint16; 00124 00125 /** @brief 32-bit signed integer. */ 00126 typedef int int32; 00127 00128 /** @brief 32-bit unsigned integer. */ 00129 typedef unsigned int uint32; 00130 00131 /** @brief 64-bit signed integer. */ 00132 typedef long long int64; 00133 00134 /** @brief 64-bit unsigned integer. */ 00135 typedef unsigned long long uint64; 00136 00137 /** 00138 * @brief Unsigned integer to index elements. 00139 * The total number of elements for each algorithm must fit into this type. 00140 */ 00141 typedef uint64 sequence_index_t; 00142 00143 /** 00144 * @brief Unsigned integer to index a thread number. 00145 * The maximum thread number (for each processor) must fit into this type. 00146 */ 00147 typedef uint16 thread_index_t; 00148 00149 // XXX atomics interface? 00150 /// Longest compare-and-swappable integer type on this platform. 00151 typedef int64 lcas_t; 00152 00153 // XXX numeric_limits::digits? 00154 /// Number of bits of ::lcas_t. 00155 static const int lcas_t_bits = sizeof(lcas_t) * 8; 00156 00157 /// ::lcas_t with the right half of bits set to 1. 00158 static const lcas_t lcas_t_mask = ((lcas_t(1) << (lcas_t_bits / 2)) - 1); 00159 } 00160 00161 #endif /* _GLIBCXX_TYPES_H */