17 #ifndef __TBB_parallel_reduce_H
18 #define __TBB_parallel_reduce_H
20 #define __TBB_parallel_reduce_H_include_area
31 namespace interface9 {
47 template<
typename Body>
55 has_right_zombie(false),
61 if( has_right_zombie )
62 zombie_space.begin()->~Body();
65 if( has_right_zombie ) {
67 Body*
s = zombie_space.begin();
75 template<
typename Range,
typename Body_,
typename Partitioner>
84 template<
typename Range,
typename Body,
typename Partitioner>
94 my_partition.note_affinity(
id );
96 template<
typename Body_>
101 start_reduce(
const Range& range, Body* body, Partitioner& partitioner ) :
104 my_partition(partitioner),
111 my_body(parent_.my_body),
112 my_range(parent_.my_range, split_obj),
113 my_partition(parent_.my_partition, split_obj),
116 my_partition.set_affinity(*
this);
122 my_body(parent_.my_body),
124 my_partition(parent_.my_partition,
split()),
127 my_partition.set_affinity(*
this);
128 my_partition.align_depth(
d );
131 static void run(
const Range& range, Body& body, Partitioner& partitioner ) {
132 if( !range.empty() ) {
133 #if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
143 #if __TBB_TASK_GROUP_CONTEXT
149 void run_body( Range &r ) { (*my_body)( r ); }
154 void offer_work(
typename Partitioner::split_type& split_obj) {
180 template<
typename Range,
typename Body,
typename Partitioner>
182 my_partition.check_being_stolen( *
this );
190 my_partition.execute(*
this, my_range);
201 template<
typename Body>
207 my_left_body( body ),
208 my_right_body( body,
split() )
212 my_left_body.join( my_right_body );
215 template<
typename Range,
typename Body_,
typename Partitioner>
221 template<
typename Range,
typename Body,
typename Partitioner>
233 my_partition( partitioner )
239 my_body( c.my_right_body ),
240 my_range( parent_.my_range, split_obj ),
241 my_partition( parent_.my_partition, split_obj )
246 static void run(
const Range& range, Body& body, Partitioner& partitioner ) {
247 if( !range.empty() ) {
248 #if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
258 #if __TBB_TASK_GROUP_CONTEXT
265 void offer_work(
typename Partitioner::split_type& split_obj) {
276 template<
typename Range,
typename Body,
typename Partitioner>
278 my_partition.
execute(*
this, my_range);
294 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
361 template<
typename Range,
typename Body>
368 template<
typename Range,
typename Body>
375 template<
typename Range,
typename Body>
382 template<
typename Range,
typename Body>
389 template<
typename Range,
typename Body>
394 #if __TBB_TASK_GROUP_CONTEXT
397 template<
typename Range,
typename Body>
404 template<
typename Range,
typename Body>
411 template<
typename Range,
typename Body>
418 template<
typename Range,
typename Body>
425 template<
typename Range,
typename Body>
436 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
437 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction ) {
446 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
447 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
451 ::run(range, body, partitioner );
457 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
458 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
462 ::run( range, body, partitioner );
468 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
469 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
473 ::run( range, body, partitioner );
479 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
480 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
484 ::run( range, body, partitioner );
488 #if __TBB_TASK_GROUP_CONTEXT
491 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
492 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
502 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
503 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
507 ::run( range, body, partitioner, context );
513 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
514 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
518 ::run( range, body, partitioner, context );
524 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
525 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
529 ::run( range, body, partitioner, context );
535 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
536 Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
540 ::run( range, body, partitioner, context );
547 template<
typename Range,
typename Body>
554 template<
typename Range,
typename Body>
561 template<
typename Range,
typename Body>
566 #if __TBB_TASK_GROUP_CONTEXT
569 template<
typename Range,
typename Body>
576 template<
typename Range,
typename Body>
583 template<
typename Range,
typename Body>
595 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
602 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
606 ::run(range, body, partitioner);
612 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
616 ::run(range, body, partitioner);
619 #if __TBB_TASK_GROUP_CONTEXT
622 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
630 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
635 ::run(range, body, partitioner, context);
641 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
646 ::run(range, body, partitioner, context);
655 #undef __TBB_parallel_reduce_H_include_area