summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>2007-09-14 20:37:25 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2007-09-14 20:37:25 +0000
commitc5654e49f04534bf73f90914a20c22f690d6d77c (patch)
tree26f05138b61e05ef2389f8db9262bc89b05296ec
parent3f225aabc78b0a112ba168254c7c498c5fcda25b (diff)
downloadgcc-c5654e49f04534bf73f90914a20c22f690d6d77c.tar.gz
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
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/parallel/base.h24
-rw-r--r--libstdc++-v3/include/parallel/find.h4
-rw-r--r--libstdc++-v3/include/parallel/multiway_merge.h5
-rw-r--r--libstdc++-v3/include/parallel/partial_sum.h2
5 files changed, 38 insertions, 9 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ef0c0e12e8a..575055ea692 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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.
diff --git a/libstdc++-v3/include/parallel/base.h b/libstdc++-v3/include/parallel/base.h
index 117292ba44b..3074188e232 100644
--- a/libstdc++-v3/include/parallel/base.h
+++ b/libstdc++-v3/include/parallel/base.h
@@ -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.
diff --git a/libstdc++-v3/include/parallel/find.h b/libstdc++-v3/include/parallel/find.h
index d3fd1bc2ea0..0dbf119c7bf 100644
--- a/libstdc++-v3/include/parallel/find.h
+++ b/libstdc++-v3/include/parallel/find.h
@@ -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)
diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h
index cdafacbd7a8..2a6c38a5a4f 100644
--- a/libstdc++-v3/include/parallel/multiway_merge.h
+++ b/libstdc++-v3/include/parallel/multiway_merge.h
@@ -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);
}
}
diff --git a/libstdc++-v3/include/parallel/partial_sum.h b/libstdc++-v3/include/parallel/partial_sum.h
index 422f2537e86..c5bc9c955a9 100644
--- a/libstdc++-v3/include/parallel/partial_sum.h
+++ b/libstdc++-v3/include/parallel/partial_sum.h
@@ -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);