33 #ifndef _GLIBCXX_PARALLEL_SEARCH_H
34 #define _GLIBCXX_PARALLEL_SEARCH_H 1
41 namespace __gnu_parallel
49 template<
typename _RAIter,
typename _DifferenceTp>
54 typedef _DifferenceTp _DifferenceType;
59 _DifferenceType __k = 0;
60 for (_DifferenceType __j = 2; __j <= __length; __j++)
62 while ((__k >= 0) && !(__elements[__k] == __elements[__j-1]))
77 template<
typename __RAIter1,
82 __RAIter2 __begin2, __RAIter2 __end2,
85 typedef std::iterator_traits<__RAIter1> _TraitsType;
86 typedef typename _TraitsType::difference_type _DifferenceType;
90 _DifferenceType __pattern_length = __end2 - __begin2;
93 if(__pattern_length <= 0)
97 _DifferenceType __input_length = (__end1 - __begin1) - __pattern_length;
100 _DifferenceType __result = (__end1 - __begin1);
101 _DifferenceType *__splitters;
104 if (__input_length < 0)
111 (1, std::min<_DifferenceType>(__input_length,
114 _DifferenceType __advances[__pattern_length];
117 # pragma omp parallel num_threads(__num_threads)
122 __splitters =
new _DifferenceType[__num_threads + 1];
128 _DifferenceType __start = __splitters[__iam],
129 __stop = __splitters[__iam + 1];
131 _DifferenceType __pos_in_pattern = 0;
132 bool __found_pattern =
false;
134 while (__start <= __stop && !__found_pattern)
137 #pragma omp flush(__result)
139 if (__result < __start)
141 while (__pred(__begin1[__start + __pos_in_pattern],
142 __begin2[__pos_in_pattern]))
145 if (__pos_in_pattern == __pattern_length)
149 __result =
std::min(__result, __start);
152 __found_pattern =
true;
157 __start += (__pos_in_pattern - __advances[__pos_in_pattern]);
158 __pos_in_pattern = (__advances[__pos_in_pattern] < 0
159 ? 0 : __advances[__pos_in_pattern]);
165 delete[] __splitters;
168 return (__begin1 + __result);
uint16_t _ThreadIndex
Unsigned integer to index a thread number. The maximum thread number (for each processor) must fit in...
Definition: types.h:123
#define _GLIBCXX_CALL(__n)
Macro to produce log message when entering a function.
Definition: compiletime_settings.h:44
int omp_get_num_threads(void) __GOMP_NOTHROW
__RAIter1 __search_template(__RAIter1 __begin1, __RAIter1 __end1, __RAIter2 __begin2, __RAIter2 __end2, _Pred __pred)
Parallel std::search.
Definition: search.h:81
const _Tp & min(const _Tp &__a, const _Tp &__b)
Equivalent to std::min.
Definition: base.h:144
void omp_destroy_lock(omp_lock_t *) __GOMP_NOTHROW
_OutputIterator __equally_split(_DifferenceType __n, _ThreadIndex __num_threads, _OutputIterator __s)
function to split a sequence into parts of almost equal size.
Definition: equally_split.h:48
void __calc_borders(_RAIter __elements, _DifferenceTp __length, _DifferenceTp *__off)
Precalculate __advances for Knuth-Morris-Pratt algorithm.
Definition: search.h:51
End-user include file. Provides advanced settings and tuning options. This file is a GNU parallel ext...
void omp_unset_lock(omp_lock_t *) __GOMP_NOTHROW
void omp_set_lock(omp_lock_t *) __GOMP_NOTHROW
int omp_get_thread_num(void) __GOMP_NOTHROW
void omp_init_lock(omp_lock_t *) __GOMP_NOTHROW
_ThreadIndex __get_max_threads()
Definition: base.h:85