OSDN Git Service

2007-09-14 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Sep 2007 20:37:25 +0000 (20:37 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Sep 2007 20:37:25 +0000 (20:37 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128505 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/parallel/base.h
libstdc++-v3/include/parallel/find.h
libstdc++-v3/include/parallel/multiway_merge.h
libstdc++-v3/include/parallel/partial_sum.h

index ef0c0e1..575055e 100644 (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.
index 117292b..3074188 100644 (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.
index d3fd1bc..0dbf119 100644 (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)
index cdafacb..2a6c38a 100644 (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);
              }
          }
index 422f253..c5bc9c9 100644 (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);