base.h (__gnu_parallel::less<Tp>): Add partial specialization for one argument.

2007-09-14  Benjamin Kosnik  <bkoz@redhat.com>
        
	* include/parallel/base.h (__gnu_parallel::less<Tp>): Add partial
        specialization for one argument. 
	(__gnu_parallel::less): Add operator.

	* include/parallel/multiway_merge.h: Use __builtin_alloca. 
	* include/parallel/partial_sum.h: Same.
	* include/parallel/find.h: Same.

From-SVN: r128505
This commit is contained in:
Benjamin Kosnik 2007-09-14 20:37:25 +00:00
parent 3f225aabc7
commit c5654e49f0
5 changed files with 38 additions and 9 deletions

View File

@ -1,4 +1,14 @@
2007-09-10 Jonathan Wakely <jwakely.gcc@gmail.com>
2007-09-14 Benjamin Kosnik <bkoz@redhat.com>
* include/parallel/base.h (__gnu_parallel::less<Tp>): Add partial
specialization for one argument.
(__gnu_parallel::less): Add operator.
* include/parallel/multiway_merge.h: Use __builtin_alloca.
* include/parallel/partial_sum.h: Same.
* include/parallel/find.h: Same.
2007-09-14 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/tr1_impl/boost_shared_ptr.h: (__weak_ptr::lock()): Add
missing template argument.

View File

@ -163,7 +163,10 @@ namespace __gnu_parallel
{ return op(value, __x); }
};
/** @brief Similar to std::binder2nd, but giving the argument types explicitly. */
/**
* @brief Similar to std::binder2nd, but giving the argument types
* explicitly.
*/
template<typename _Operation, typename first_argument_type, typename second_argument_type, typename result_type>
class binder2nd
: public std::unary_function<first_argument_type, result_type>
@ -192,10 +195,23 @@ namespace __gnu_parallel
template<typename T1, typename T2>
struct less : std::binary_function<T1, T2, bool>
{
bool operator()(const T1& t1, const T2& t2) const
bool
operator()(const T1& t1, const T2& t2) const
{ return t1 < t2; }
bool
operator()(const T2& t2, const T1& t1) const
{ return t2 < t1; }
};
// Partial specialization for one type. Same as std::less.
template<typename _Tp>
struct less<_Tp, _Tp> : public std::binary_function<_Tp, _Tp, bool>
{
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
};
template<typename T, typename _DifferenceTp>
class pseudo_sequence;
@ -268,7 +284,9 @@ namespace __gnu_parallel
public:
typedef _DifferenceTp difference_type;
typedef pseudo_sequence_iterator<T, uint64> iterator; //better case down to uint64, than up to _DifferenceTp
// Better case down to uint64, than up to _DifferenceTp.
typedef pseudo_sequence_iterator<T, uint64> iterator;
/** @brief Constructor.
* @param val Element of the sequence.

View File

@ -105,8 +105,8 @@ namespace __gnu_parallel
const thread_index_t num_threads = get_max_threads();
// XXX VLA error.
difference_type borders[num_threads + 1];
difference_type* borders = static_cast<difference_type*>(__builtin_alloca(sizeof(difference_type) * (num_threads + 1)));
equally_split(length, num_threads, borders);
#pragma omp parallel shared(result) num_threads(num_threads)

View File

@ -1457,7 +1457,7 @@ namespace __gnu_parallel
copy(seqs_begin, seqs_end, se.begin());
difference_type borders[num_threads + 1];
difference_type* borders = static_cast<difference_type*>(__builtin_alloca(sizeof(difference_type) * (num_threads + 1)));
equally_split(length, num_threads, borders);
for (int s = 0; s < (num_threads - 1); s++)
@ -1470,7 +1470,8 @@ namespace __gnu_parallel
if (!tight)
{
offsets[num_threads - 1].resize(k);
multiseq_partition(se.begin(), se.end(), (difference_type)length,
multiseq_partition(se.begin(), se.end(),
difference_type(length),
offsets[num_threads - 1].begin(), comp);
}
}

View File

@ -103,7 +103,7 @@ namespace __gnu_parallel
return parallel_partial_sum_basecase(begin + 1, end, result + 1, bin_op, *begin);
}
difference_type* borders = __builtin_alloca(sizeof(difference_type) * (num_threads + 2));
difference_type* borders = static_cast<difference_type*>(__builtin_alloca(sizeof(difference_type) * (num_threads + 2)));
if (Settings::partial_sum_dilatation == 1.0f)
equally_split(n, num_threads + 1, borders);