1

I am using the Parallel Pattern Library. The class combinable plays the role of reduction clause in openMP, and enables to merge results from parallel calculations.

Does .combine(max()) exists (btw, could you point at some ref with allowed operations with combine, did not find that)?

Thanks and regards.

Stephan Dollberg
  • 32,985
  • 16
  • 81
  • 107
kiriloff
  • 25,609
  • 37
  • 148
  • 229

1 Answers1

1

Yes, you can pass std::max to combineable::combine, one thing you have to take into account when passing template functions as predicates is that you have to explicitly name the type:

combineable<T> max;

// .. do processing

max.combine(std::max<T>);

You can find all the official MSDN docs about combine (and all the other PPL stuff) here.

Stephan Dollberg
  • 32,985
  • 16
  • 81
  • 107
  • However, I don't get why here syntax is `max.combine(std::max);` (and it is compiling so), and not `max.combine(std::max());`, whereas in doc the syntax for plus is `.combine(plus())` (and it is compiling so) ? – kiriloff Apr 30 '12 at 12:26
  • @dlib `std::max` is a function predicate, thus you only name the function, no braces are needed. `std::plus` is a class which has a overloaded `operator()`, what you are doing when you say `std::plus()` is that you are creating a temporary class of that type whose `operator()` is used by combine. – Stephan Dollberg Apr 30 '12 at 13:32