[PATCH][libstdc++-v3 parallel mode] PR 33488 improved

Johannes Singler singler@ira.uka.de
Tue Oct 2 10:15:00 GMT 2007


Benjamin Kosnik wrote:

> I think Chris was getting back to the uglification issue with the
> parallel mode code in general, where some user code like this:
> 
> #include <algorithm>
> 
> using namespace __gnu_parallel;
> 
> class Settings {} ; // error conflicts with __gnu_parallel::Settings
> 
> is currently problematic, but should not be. I'd prefer to deal with
> this issue all at once, when some of the other parallel code bugzilla
> issues have been resolved. 

I agree.

>>> I can't quite remember exactly how those came about now, but I
>>> remember we found you needed that many bits to fix all the existing
>>> code floating about (I think mainly some strange bits of boost).
>> As long these functors are used by "our" code, we probably don't need
>> all the variants. Is there a reason to include them nevertheless?
> 
> I don't think so. 
> 
> However, a couple of things.
> 
> Like for __gnu_parallel::less, you'll need two version of operator() if
> you have two argument types.
> 
> ie, should be:
> 
> +  template<typename T1, typename T2>
> +  struct equal_to : std::binary_function<T1, T2, bool>
> +  {
> +    bool operator()(const T1& t1, const T2& t2) const
> +    { return t1 == t2; }
> +    bool operator()(const T2& t2, const T1& t1) const
> +    { return t2 == t1; }
> +  };
> 
> Similarly for the relevant multiplies and plus code.

But if the algorithms guarantee to call it only the "right" order, we
don't need two versions, right? That was my question. Of course, we can
add them anyway.

> In addition:
> 
> -    typedef iterator_traits<InputIterator1> traits_type;
> -    typedef typename traits_type::value_type value_type;
> -
> -    return inner_product(first1, last1, first2, init,
> std::plus<value_type>(), 
> -			 std::multiplies<value_type>(),
> parallelism_tag);
> +    return inner_product(first1, last1, first2, init,
> +                           __gnu_parallel::plus<
> +                             T,
> +                             typename
> iterator_traits<InputIterator1>::value_type
> +                           >(),
> +                           __gnu_parallel::multiplies<
> +                             typename
> iterator_traits<InputIterator1>::value_type,
> +                             typename
> iterator_traits<InputIterator2>::value_type
> +                           >(),
> +                           parallelism_tag);
> 
> Don't even think about removing these typedefs for traits_type and
> value_type.
> 
> Instead, use them, and consider new typedefs for the multiplies and
> plus types. 

Okay.

Johannes



More information about the Libstdc++ mailing list