This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][libstdc++-v3 parallel mode] Resolve namespace ambiguities


This patch fixes ambiguities between __gnu_parallel and std that occur
when the parallel algorithm are used selectively (i.e. without
_GLIBCXX_PARALLEL).

Tested x86_64-unknown-linux-gnu: No further regressions.

Please approve for mainline and gcc-4_4-branch.

2010-03-22  Johannes Singler  <singler@kit.edu>

        * include/parallel/numeric (inner_product, partial_sum):
        Precede subsequent call with _GLIBCXX_STD_P:: to avoid ambiguity
        between __gnu_parallel:: and std::
        * include/parallel/algobase.h (equal): Likewise.
        * include/parallel/algo.h (find_first_of, search_n, merge,
        nth_element, partial_sort, max_element, min_element): Likewise.
        * include/parallel/partial_sum.h
        (__parallel_partial_sum_linear):
        Qualify accumulate call with __gnu_parallel::.


Johannes


Index: include/parallel/numeric
===================================================================
--- include/parallel/numeric	(revision 157624)
+++ include/parallel/numeric	(working copy)
@@ -283,7 +283,7 @@
       typedef typename
         __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type
         _MultipliesResultType;
-      return inner_product(__first1, __last1, __first2, __init,
+      return _GLIBCXX_STD_P::inner_product(__first1, __last1, __first2, __init,
                            __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(),
                            __gnu_parallel::
                            _Multiplies<_ValueType1, _ValueType2>(),
@@ -303,7 +303,7 @@
       typedef typename
         __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type
         _MultipliesResultType;
-      return inner_product(__first1, __last1, __first2, __init,
+      return _GLIBCXX_STD_P::inner_product(__first1, __last1, __first2, __init,
                            __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(),
                            __gnu_parallel::
                            _Multiplies<_ValueType1, _ValueType2>());
@@ -359,7 +359,8 @@
     partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result)
     {
       typedef typename iterator_traits<_IIter>::value_type _ValueType;
-      return partial_sum(__begin, __end, __result, std::plus<_ValueType>());
+      return _GLIBCXX_STD_P::partial_sum(__begin, __end,
+                                         __result, std::plus<_ValueType>());
     }
 
   // Public interface
Index: include/parallel/algobase.h
===================================================================
--- include/parallel/algobase.h	(revision 157624)
+++ include/parallel/algobase.h	(working copy)
@@ -141,14 +141,20 @@
   template<typename _IIter1, typename _IIter2>
     inline bool
     equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
-    { return mismatch(__begin1, __end1, __begin2).first == __end1; }
+    {
+      return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2).first
+              == __end1;
+    }
 
   // Public interface
   template<typename _IIter1, typename _IIter2, typename _Predicate>
     inline bool
     equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, 
           _Predicate __pred)
-    { return mismatch(__begin1, __end1, __begin2, __pred).first == __end1; }
+    {
+      return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2, __pred).first
+              == __end1;
+    }
 
   // Sequential fallback
   template<typename _IIter1, typename _IIter2>
Index: include/parallel/partial_sum.h
===================================================================
--- include/parallel/partial_sum.h	(revision 157624)
+++ include/parallel/partial_sum.h	(working copy)
@@ -158,7 +158,8 @@
         else
           {
             ::new(&(__sums[__iam]))
-              _ValueType(std::accumulate(__begin + __borders[__iam] + 1,
+              _ValueType(__gnu_parallel::accumulate(
+                                         __begin + __borders[__iam] + 1,
                                          __begin + __borders[__iam + 1],
                                          *(__begin + __borders[__iam]),
                                          __bin_op,
Index: include/parallel/algo.h
===================================================================
--- include/parallel/algo.h	(revision 157624)
+++ include/parallel/algo.h	(working copy)
@@ -292,8 +292,8 @@
       typedef typename _IIterTraits::value_type _IValueType;
       typedef typename iteratorf_traits::value_type _FValueType;
 
-      return find_first_of(__begin1, __end1, __begin2, __end2, __gnu_parallel::
-                           _EqualTo<_IValueType, _FValueType>());
+      return _GLIBCXX_STD_P::find_first_of(__begin1, __end1, __begin2, __end2,
+                         __gnu_parallel::_EqualTo<_IValueType, _FValueType>());
     }
 
   // Sequential fallback
@@ -1160,7 +1160,7 @@
              const _Tp& __val)
     {
       typedef typename iterator_traits<_FIterator>::value_type _ValueType;
-      return search_n(__begin, __end, __count, __val,
+      return _GLIBCXX_STD_P::search_n(__begin, __end, __count, __val,
                       __gnu_parallel::_EqualTo<_ValueType, _Tp>());
     }
 
@@ -2086,8 +2086,8 @@
       typedef typename _Iterator1Traits::value_type _ValueType1;
       typedef typename _Iterator2Traits::value_type _ValueType2;
 
-      return merge(__begin1, __end1, __begin2, __end2, __result, 
-                   __gnu_parallel::_Less<_ValueType1, _ValueType2>());
+      return _GLIBCXX_STD_P::merge(__begin1, __end1, __begin2, __end2,
+                  __result, __gnu_parallel::_Less<_ValueType1, _ValueType2>());
     }
 
   // Sequential fallback
@@ -2128,7 +2128,8 @@
     {
       typedef iterator_traits<_RAIter> _TraitsType;
       typedef typename _TraitsType::value_type _ValueType;
-      nth_element(__begin, __nth, __end, std::less<_ValueType>());
+      _GLIBCXX_STD_P::nth_element(__begin, __nth, __end,
+                                  std::less<_ValueType>());
     }
 
   // Sequential fallback
@@ -2170,7 +2171,8 @@
     {
       typedef iterator_traits<_RAIter> _TraitsType;
       typedef typename _TraitsType::value_type _ValueType;
-      partial_sort(__begin, __middle, __end, std::less<_ValueType>());
+      _GLIBCXX_STD_P::partial_sort(__begin, __middle, __end,
+                                   std::less<_ValueType>());
     }
 
   // Sequential fallback
@@ -2239,7 +2241,8 @@
     max_element(_FIterator __begin, _FIterator __end)
     {
       typedef typename iterator_traits<_FIterator>::value_type _ValueType;
-      return max_element(__begin, __end, std::less<_ValueType>());
+      return _GLIBCXX_STD_P::max_element(__begin, __end,
+                                         std::less<_ValueType>());
     }
 
   // Public interface
@@ -2330,7 +2333,8 @@
     min_element(_FIterator __begin, _FIterator __end)
     {
       typedef typename iterator_traits<_FIterator>::value_type _ValueType;
-      return min_element(__begin, __end, std::less<_ValueType>());
+      return _GLIBCXX_STD_P::min_element(__begin, __end,
+                                         std::less<_ValueType>());
     }
 
   // Public interface
Index: include/parallel/numeric
===================================================================
--- include/parallel/numeric	(revision 157624)
+++ include/parallel/numeric	(working copy)
@@ -280,7 +280,7 @@
       typedef typename
 	__gnu_parallel::multiplies<value_type1, value_type2>::result
         multiplies_result_type;
-      return inner_product(first1, last1, first2, init,
+      return _GLIBCXX_STD_P::inner_product(first1, last1, first2, init,
                            __gnu_parallel::plus<T, multiplies_result_type>(),
                            __gnu_parallel::
 			   multiplies<value_type1, value_type2>(),
@@ -300,7 +300,7 @@
       typedef typename
 	__gnu_parallel::multiplies<value_type1, value_type2>::result
         multiplies_result_type;
-      return inner_product(first1, last1, first2, init,
+      return _GLIBCXX_STD_P::inner_product(first1, last1, first2, init,
                            __gnu_parallel::plus<T, multiplies_result_type>(),
                            __gnu_parallel::
 			   multiplies<value_type1, value_type2>());
@@ -355,7 +355,8 @@
     partial_sum(InputIterator begin, InputIterator end, OutputIterator result)
     {
       typedef typename iterator_traits<InputIterator>::value_type value_type;
-      return partial_sum(begin, end, result, std::plus<value_type>());
+      return _GLIBCXX_STD_P::partial_sum(begin, end, result,
+                                         std::plus<value_type>());
     }
 
   // Public interface
Index: include/parallel/algobase.h
===================================================================
--- include/parallel/algobase.h	(revision 157624)
+++ include/parallel/algobase.h	(working copy)
@@ -146,7 +146,7 @@
   template<typename InputIterator1, typename InputIterator2>
     inline bool
     equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2)
-    { return mismatch(begin1, end1, begin2).first == end1; }
+    { return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2).first == end1; }
 
   // Public interface
   template<typename InputIterator1, typename InputIterator2,
@@ -154,7 +154,10 @@
     inline bool
     equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, 
 	  Predicate pred)
-    { return mismatch(begin1, end1, begin2, pred).first == end1; }
+    {
+      return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2, pred).first
+                  == end1;
+    }
 
   // Sequential fallback
   template<typename InputIterator1, typename InputIterator2>
Index: include/parallel/partial_sum.h
===================================================================
--- include/parallel/partial_sum.h	(revision 157624)
+++ include/parallel/partial_sum.h	(working copy)
@@ -155,7 +155,7 @@
         else
           {
             ::new(&(sums[iam]))
-	      value_type(std::accumulate(begin + borders[iam] + 1,
+	      value_type(__gnu_parallel::accumulate(begin + borders[iam] + 1,
 					 begin + borders[iam + 1],
 					 *(begin + borders[iam]),
 					 bin_op,
Index: include/parallel/algo.h
===================================================================
--- include/parallel/algo.h	(revision 157624)
+++ include/parallel/algo.h	(working copy)
@@ -289,8 +289,8 @@
       typedef typename iteratori_traits::value_type valuei_type;
       typedef typename iteratorf_traits::value_type valuef_type;
 
-      return find_first_of(begin1, end1, begin2, end2, __gnu_parallel::
-                           equal_to<valuei_type, valuef_type>());
+      return _GLIBCXX_STD_P::find_first_of(begin1, end1, begin2, end2,
+                __gnu_parallel::equal_to<valuei_type, valuef_type>());
     }
 
   // Sequential fallback
@@ -1152,7 +1152,7 @@
              const T& val)
     {
       typedef typename iterator_traits<ForwardIterator>::value_type value_type;
-      return search_n(begin, end, count, val,
+      return _GLIBCXX_STD_P::search_n(begin, end, count, val,
                       __gnu_parallel::equal_to<value_type, T>());
     }
 
@@ -2093,7 +2093,7 @@
       typedef typename iterator1_traits::value_type value1_type;
       typedef typename iterator2_traits::value_type value2_type;
 
-      return merge(begin1, end1, begin2, end2, result, 
+      return _GLIBCXX_STD_P::merge(begin1, end1, begin2, end2, result, 
                    __gnu_parallel::less<value1_type, value2_type>());
     }
 
@@ -2134,7 +2134,7 @@
     {
       typedef iterator_traits<RandomAccessIterator> traits_type;
       typedef typename traits_type::value_type value_type;
-      nth_element(begin, nth, end, std::less<value_type>());
+      _GLIBCXX_STD_P::nth_element(begin, nth, end, std::less<value_type>());
     }
 
   // Sequential fallback
@@ -2175,7 +2175,8 @@
     {
       typedef iterator_traits<RandomAccessIterator> traits_type;
       typedef typename traits_type::value_type value_type;
-      partial_sort(begin, middle, end, std::less<value_type>());
+      _GLIBCXX_STD_P::partial_sort(begin, middle, end,
+                                   std::less<value_type>());
     }
 
   // Sequential fallback
@@ -2244,7 +2245,7 @@
     max_element(ForwardIterator begin, ForwardIterator end)
     {
       typedef typename iterator_traits<ForwardIterator>::value_type value_type;
-      return max_element(begin, end, std::less<value_type>());
+      return _GLIBCXX_STD_P::max_element(begin, end, std::less<value_type>());
     }
 
   // Public interface
@@ -2335,7 +2336,7 @@
     min_element(ForwardIterator begin, ForwardIterator end)
     {
       typedef typename iterator_traits<ForwardIterator>::value_type value_type;
-      return min_element(begin, end, std::less<value_type>());
+      return _GLIBCXX_STD_P::min_element(begin, end, std::less<value_type>());
     }
 
   // Public interface

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]