Search code examples
c++multithreadingparallel-processingppl

c++ PPL parallel work - function max() in reduction class 'combinable'


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.


Solution

  • 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.