parallel_reduce.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __TBB_parallel_reduce_H
#define __TBB_parallel_reduce_H
#define __TBB_parallel_reduce_H_include_area
#include "internal/_warning_suppress_enable_notice.h"
#include <new>
#include "task.h"
#include "aligned_space.h"
#include "partitioner.h"
#include "tbb_profiling.h"
namespace tbb {
namespace interface9 {
namespace internal {
using namespace tbb::internal;
enum {
root_task, left_child, right_child
};
typedef char reduction_context;
template<typename Body>
class finish_reduce: public flag_task {
bool has_right_zombie;
const reduction_context my_context;
Body* my_body;
aligned_space<Body> zombie_space;
finish_reduce( reduction_context context_ ) :
has_right_zombie(false), // TODO: substitute by flag_task::child_stolen?
my_context(context_),
my_body(NULL)
{
}
~finish_reduce() {
if( has_right_zombie )
zombie_space.begin()->~Body();
}
task* execute() __TBB_override {
if( has_right_zombie ) {
// Right child was stolen.
Body* s = zombie_space.begin();
my_body->join( *s );
// Body::join() won't be called if canceled. Defer destruction to destructor
}
if( my_context==left_child )
itt_store_word_with_release( static_cast<finish_reduce*>(parent())->my_body, my_body );
return NULL;
}
template<typename Range,typename Body_, typename Partitioner>
friend class start_reduce;
};
void allocate_sibling(task* start_reduce_task, task *tasks[], size_t start_bytes, size_t finish_bytes);
template<typename Range, typename Body, typename Partitioner>
class start_reduce: public task {
typedef finish_reduce<Body> finish_type;
Body* my_body;
Range my_range;
typename Partitioner::task_partition_type my_partition;
reduction_context my_context;
task* execute() __TBB_override;
void note_affinity( affinity_id id ) __TBB_override {
my_partition.note_affinity( id );
}
template<typename Body_>
friend class finish_reduce;
public:
start_reduce( const Range& range, Body* body, Partitioner& partitioner ) :
my_body(body),
my_range(range),
my_partition(partitioner),
my_context(root_task)
{
}
start_reduce( start_reduce& parent_, typename Partitioner::split_type& split_obj ) :
my_body(parent_.my_body),
my_range(parent_.my_range, split_obj),
my_partition(parent_.my_partition, split_obj),
my_context(right_child)
{
my_partition.set_affinity(*this);
parent_.my_context = left_child;
}
start_reduce( start_reduce& parent_, const Range& r, depth_t d ) :
my_body(parent_.my_body),
my_range(r),
my_partition(parent_.my_partition, split()),
my_context(right_child)
{
my_partition.set_affinity(*this);
my_partition.align_depth( d ); // TODO: move into constructor of partitioner
parent_.my_context = left_child;
}
static void run( const Range& range, Body& body, Partitioner& partitioner ) {
if( !range.empty() ) {
#if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
task::spawn_root_and_wait( *new(task::allocate_root()) start_reduce(range,&body,partitioner) );
#else
// Bound context prevents exceptions from body to affect nesting or sibling algorithms,
// and allows users to handle exceptions safely by wrapping parallel_for in the try-block.
task_group_context context(PARALLEL_REDUCE);
task::spawn_root_and_wait( *new(task::allocate_root(context)) start_reduce(range,&body,partitioner) );
#endif /* __TBB_TASK_GROUP_CONTEXT && !TBB_JOIN_OUTER_TASK_GROUP */
}
}
#if __TBB_TASK_GROUP_CONTEXT
static void run( const Range& range, Body& body, Partitioner& partitioner, task_group_context& context ) {
if( !range.empty() )
task::spawn_root_and_wait( *new(task::allocate_root(context)) start_reduce(range,&body,partitioner) );
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
void run_body( Range &r ) { (*my_body)( r ); }
// TODO: remove code duplication from 'offer_work' methods
void offer_work(typename Partitioner::split_type& split_obj) {
task *tasks[2];
allocate_sibling(static_cast<task*>(this), tasks, sizeof(start_reduce), sizeof(finish_type));
new((void*)tasks[0]) finish_type(my_context);
new((void*)tasks[1]) start_reduce(*this, split_obj);
spawn(*tasks[1]);
}
void offer_work(const Range& r, depth_t d = 0) {
task *tasks[2];
allocate_sibling(static_cast<task*>(this), tasks, sizeof(start_reduce), sizeof(finish_type));
new((void*)tasks[0]) finish_type(my_context);
new((void*)tasks[1]) start_reduce(*this, r, d);
spawn(*tasks[1]);
}
};
// TODO: 'inline' here is to avoid multiple definition error but for sake of code size this should not be inlined
inline void allocate_sibling(task* start_reduce_task, task *tasks[], size_t start_bytes, size_t finish_bytes) {
tasks[0] = &start_reduce_task->allocate_continuation().allocate(finish_bytes);
start_reduce_task->set_parent(tasks[0]);
tasks[0]->set_ref_count(2);
tasks[1] = &tasks[0]->allocate_child().allocate(start_bytes);
}
template<typename Range, typename Body, typename Partitioner>
task* start_reduce<Range,Body,Partitioner>::execute() {
my_partition.check_being_stolen( *this );
if( my_context==right_child ) {
finish_type* parent_ptr = static_cast<finish_type*>(parent());
if( !itt_load_word_with_acquire(parent_ptr->my_body) ) { // TODO: replace by is_stolen_task() or by parent_ptr->ref_count() == 2???
my_body = new( parent_ptr->zombie_space.begin() ) Body(*my_body,split());
parent_ptr->has_right_zombie = true;
}
} else __TBB_ASSERT(my_context==root_task,NULL);// because left leaf spawns right leafs without recycling
my_partition.execute(*this, my_range);
if( my_context==left_child ) {
finish_type* parent_ptr = static_cast<finish_type*>(parent());
__TBB_ASSERT(my_body!=parent_ptr->zombie_space.begin(),NULL);
itt_store_word_with_release(parent_ptr->my_body, my_body );
}
return NULL;
}
template<typename Body>
class finish_deterministic_reduce: public task {
Body &my_left_body;
Body my_right_body;
finish_deterministic_reduce( Body &body ) :
my_left_body( body ),
my_right_body( body, split() )
{
}
task* execute() __TBB_override {
my_left_body.join( my_right_body );
return NULL;
}
template<typename Range,typename Body_, typename Partitioner>
friend class start_deterministic_reduce;
};
template<typename Range, typename Body, typename Partitioner>
class start_deterministic_reduce: public task {
typedef finish_deterministic_reduce<Body> finish_type;
Body &my_body;
Range my_range;
typename Partitioner::task_partition_type my_partition;
task* execute() __TBB_override;
start_deterministic_reduce( const Range& range, Body& body, Partitioner& partitioner ) :
my_body( body ),
my_range( range ),
my_partition( partitioner )
{
}
start_deterministic_reduce( start_deterministic_reduce& parent_, finish_type& c, typename Partitioner::split_type& split_obj ) :
my_body( c.my_right_body ),
my_range( parent_.my_range, split_obj ),
my_partition( parent_.my_partition, split_obj )
{
}
public:
static void run( const Range& range, Body& body, Partitioner& partitioner ) {
if( !range.empty() ) {
#if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
task::spawn_root_and_wait( *new(task::allocate_root()) start_deterministic_reduce(range,&body,partitioner) );
#else
// Bound context prevents exceptions from body to affect nesting or sibling algorithms,
// and allows users to handle exceptions safely by wrapping parallel_for in the try-block.
task_group_context context(PARALLEL_REDUCE);
task::spawn_root_and_wait( *new(task::allocate_root(context)) start_deterministic_reduce(range,body,partitioner) );
#endif /* __TBB_TASK_GROUP_CONTEXT && !TBB_JOIN_OUTER_TASK_GROUP */
}
}
#if __TBB_TASK_GROUP_CONTEXT
static void run( const Range& range, Body& body, Partitioner& partitioner, task_group_context& context ) {
if( !range.empty() )
task::spawn_root_and_wait( *new(task::allocate_root(context)) start_deterministic_reduce(range,body,partitioner) );
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
void offer_work( typename Partitioner::split_type& split_obj) {
task* tasks[2];
allocate_sibling(static_cast<task*>(this), tasks, sizeof(start_deterministic_reduce), sizeof(finish_type));
new((void*)tasks[0]) finish_type(my_body);
new((void*)tasks[1]) start_deterministic_reduce(*this, *static_cast<finish_type*>(tasks[0]), split_obj);
spawn(*tasks[1]);
}
void run_body( Range &r ) { my_body(r); }
};
template<typename Range, typename Body, typename Partitioner>
task* start_deterministic_reduce<Range,Body, Partitioner>::execute() {
my_partition.execute(*this, my_range);
return NULL;
}
} // namespace internal
} //namespace interfaceX
namespace internal {
using interface9::internal::start_reduce;
using interface9::internal::start_deterministic_reduce;
template<typename Range, typename Value, typename RealBody, typename Reduction>
class lambda_reduce_body {
//FIXME: decide if my_real_body, my_reduction, and identity_element should be copied or referenced
// (might require some performance measurements)
const Value& identity_element;
const RealBody& my_real_body;
const Reduction& my_reduction;
Value my_value;
lambda_reduce_body& operator= ( const lambda_reduce_body& other );
public:
lambda_reduce_body( const Value& identity, const RealBody& body, const Reduction& reduction )
: identity_element(identity)
, my_real_body(body)
, my_reduction(reduction)
, my_value(identity)
{ }
lambda_reduce_body( const lambda_reduce_body& other )
: identity_element(other.identity_element)
, my_real_body(other.my_real_body)
, my_reduction(other.my_reduction)
, my_value(other.my_value)
{ }
lambda_reduce_body( lambda_reduce_body& other, tbb::split )
: identity_element(other.identity_element)
, my_real_body(other.my_real_body)
, my_reduction(other.my_reduction)
, my_value(other.identity_element)
{ }
void operator()(Range& range) {
my_value = my_real_body(range, const_cast<const Value&>(my_value));
}
void join( lambda_reduce_body& rhs ) {
my_value = my_reduction(const_cast<const Value&>(my_value), const_cast<const Value&>(rhs.my_value));
}
Value result() const {
return my_value;
}
};
} // namespace internal
// Requirements on Range concept are documented in blocked_range.h
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body ) {
internal::start_reduce<Range,Body, const __TBB_DEFAULT_PARTITIONER>::run( range, body, __TBB_DEFAULT_PARTITIONER() );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const simple_partitioner& partitioner ) {
internal::start_reduce<Range,Body,const simple_partitioner>::run( range, body, partitioner );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const auto_partitioner& partitioner ) {
internal::start_reduce<Range,Body,const auto_partitioner>::run( range, body, partitioner );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const static_partitioner& partitioner ) {
internal::start_reduce<Range,Body,const static_partitioner>::run( range, body, partitioner );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, affinity_partitioner& partitioner ) {
internal::start_reduce<Range,Body,affinity_partitioner>::run( range, body, partitioner );
}
#if __TBB_TASK_GROUP_CONTEXT
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, task_group_context& context ) {
internal::start_reduce<Range,Body,const __TBB_DEFAULT_PARTITIONER>::run( range, body, __TBB_DEFAULT_PARTITIONER(), context );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const simple_partitioner& partitioner, task_group_context& context ) {
internal::start_reduce<Range,Body,const simple_partitioner>::run( range, body, partitioner, context );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const auto_partitioner& partitioner, task_group_context& context ) {
internal::start_reduce<Range,Body,const auto_partitioner>::run( range, body, partitioner, context );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, const static_partitioner& partitioner, task_group_context& context ) {
internal::start_reduce<Range,Body,const static_partitioner>::run( range, body, partitioner, context );
}
template<typename Range, typename Body>
void parallel_reduce( const Range& range, Body& body, affinity_partitioner& partitioner, task_group_context& context ) {
internal::start_reduce<Range,Body,affinity_partitioner>::run( range, body, partitioner, context );
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const __TBB_DEFAULT_PARTITIONER>
::run(range, body, __TBB_DEFAULT_PARTITIONER() );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const simple_partitioner& partitioner ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const simple_partitioner>
::run(range, body, partitioner );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const auto_partitioner& partitioner ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const auto_partitioner>
::run( range, body, partitioner );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const static_partitioner& partitioner ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const static_partitioner>
::run( range, body, partitioner );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
affinity_partitioner& partitioner ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,affinity_partitioner>
::run( range, body, partitioner );
return body.result();
}
#if __TBB_TASK_GROUP_CONTEXT
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
task_group_context& context ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const __TBB_DEFAULT_PARTITIONER>
::run( range, body, __TBB_DEFAULT_PARTITIONER(), context );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const simple_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const simple_partitioner>
::run( range, body, partitioner, context );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const auto_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const auto_partitioner>
::run( range, body, partitioner, context );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const static_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,const static_partitioner>
::run( range, body, partitioner, context );
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
affinity_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>,affinity_partitioner>
::run( range, body, partitioner, context );
return body.result();
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body ) {
internal::start_deterministic_reduce<Range, Body, const simple_partitioner>::run(range, body, simple_partitioner());
}
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body, const simple_partitioner& partitioner ) {
internal::start_deterministic_reduce<Range, Body, const simple_partitioner>::run(range, body, partitioner);
}
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body, const static_partitioner& partitioner ) {
internal::start_deterministic_reduce<Range, Body, const static_partitioner>::run(range, body, partitioner);
}
#if __TBB_TASK_GROUP_CONTEXT
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body, task_group_context& context ) {
internal::start_deterministic_reduce<Range,Body, const simple_partitioner>::run( range, body, simple_partitioner(), context );
}
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body, const simple_partitioner& partitioner, task_group_context& context ) {
internal::start_deterministic_reduce<Range, Body, const simple_partitioner>::run(range, body, partitioner, context);
}
template<typename Range, typename Body>
void parallel_deterministic_reduce( const Range& range, Body& body, const static_partitioner& partitioner, task_group_context& context ) {
internal::start_deterministic_reduce<Range, Body, const static_partitioner>::run(range, body, partitioner, context);
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
// TODO: consider making static_partitioner the default
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction ) {
return parallel_deterministic_reduce(range, identity, real_body, reduction, simple_partitioner());
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction, const simple_partitioner& partitioner ) {
internal::lambda_reduce_body<Range,Value,RealBody,Reduction> body(identity, real_body, reduction);
internal::start_deterministic_reduce<Range,internal::lambda_reduce_body<Range,Value,RealBody,Reduction>, const simple_partitioner>
::run(range, body, partitioner);
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction, const static_partitioner& partitioner ) {
internal::lambda_reduce_body<Range, Value, RealBody, Reduction> body(identity, real_body, reduction);
internal::start_deterministic_reduce<Range, internal::lambda_reduce_body<Range, Value, RealBody, Reduction>, const static_partitioner>
::run(range, body, partitioner);
return body.result();
}
#if __TBB_TASK_GROUP_CONTEXT
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
task_group_context& context ) {
return parallel_deterministic_reduce(range, identity, real_body, reduction, simple_partitioner(), context);
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const simple_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range, Value, RealBody, Reduction> body(identity, real_body, reduction);
internal::start_deterministic_reduce<Range, internal::lambda_reduce_body<Range, Value, RealBody, Reduction>, const simple_partitioner>
::run(range, body, partitioner, context);
return body.result();
}
template<typename Range, typename Value, typename RealBody, typename Reduction>
Value parallel_deterministic_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction,
const static_partitioner& partitioner, task_group_context& context ) {
internal::lambda_reduce_body<Range, Value, RealBody, Reduction> body(identity, real_body, reduction);
internal::start_deterministic_reduce<Range, internal::lambda_reduce_body<Range, Value, RealBody, Reduction>, const static_partitioner>
::run(range, body, partitioner, context);
return body.result();
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
} // namespace tbb
#include "internal/_warning_suppress_disable_notice.h"
#undef __TBB_parallel_reduce_H_include_area
#endif /* __TBB_parallel_reduce_H */
aligned_space.h
_warning_suppress_disable_notice.h
_warning_suppress_enable_notice.h
partitioner.h
task.h
__TBB_DEFAULT_PARTITIONER
#define __TBB_DEFAULT_PARTITIONER
Definition: tbb_config.h:597
tbb_profiling.h
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
__TBB_override
#define __TBB_override
Definition: tbb_stddef.h:240
s
void const char const char int ITT_FORMAT __itt_group_sync s
Definition: ittnotify_static.h:91
d
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
Definition: ittnotify_static.h:109
parent
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id parent
Definition: ittnotify_static.h:176
tbb::parallel_deterministic_reduce
void parallel_deterministic_reduce(const Range &range, Body &body)
Parallel iteration with deterministic reduction and default simple partitioner.
Definition: parallel_reduce.h:548
tbb::parallel_reduce
void parallel_reduce(const Range &range, Body &body)
Parallel iteration with reduction and default partitioner.
Definition: parallel_reduce.h:362
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::internal
Identifiers declared inside namespace internal should never be used directly by client code.
Definition: atomic.h:65
tbb::internal::itt_load_word_with_acquire
T itt_load_word_with_acquire(const tbb::atomic< T > &src)
Definition: tbb_profiling.h:168
tbb::internal::itt_store_word_with_release
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
Definition: tbb_profiling.h:157
internal
Definition: _flow_graph_async_msg_impl.h:24
tbb::interface9::internal::depth_t
unsigned char depth_t
Definition: partitioner.h:150
tbb::interface9::internal::left_child
@ left_child
Definition: parallel_reduce.h:39
tbb::interface9::internal::root_task
@ root_task
Definition: parallel_reduce.h:39
tbb::interface9::internal::right_child
@ right_child
Definition: parallel_reduce.h:39
tbb::interface9::internal::allocate_sibling
void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
Definition: tbb/parallel_for.h:131
tbb::interface9::internal::reduction_context
char reduction_context
Definition: parallel_reduce.h:43
tbb::interface9::internal::finish_reduce
Task type used to combine the partial results of parallel_reduce.
Definition: parallel_reduce.h:48
tbb::interface9::internal::finish_reduce::execute
task * execute() __TBB_override
Should be overridden by derived classes.
Definition: parallel_reduce.h:64
tbb::interface9::internal::finish_reduce::~finish_reduce
~finish_reduce()
Definition: parallel_reduce.h:60
tbb::interface9::internal::finish_reduce::finish_reduce
finish_reduce(reduction_context context_)
Definition: parallel_reduce.h:54
tbb::interface9::internal::finish_reduce::zombie_space
aligned_space< Body > zombie_space
Definition: parallel_reduce.h:53
tbb::interface9::internal::finish_reduce::my_context
const reduction_context my_context
Definition: parallel_reduce.h:51
tbb::interface9::internal::finish_reduce::my_body
Body * my_body
Definition: parallel_reduce.h:52
tbb::interface9::internal::finish_reduce::has_right_zombie
bool has_right_zombie
Pointer to body, or NULL if the left child has not yet finished.
Definition: parallel_reduce.h:50
tbb::interface9::internal::start_reduce
Task type used to split the work of parallel_reduce.
Definition: parallel_reduce.h:85
tbb::interface9::internal::start_reduce::offer_work
void offer_work(typename Partitioner::split_type &split_obj)
spawn right task, serves as callback for partitioner
Definition: parallel_reduce.h:154
tbb::interface9::internal::start_reduce::offer_work
void offer_work(const Range &r, depth_t d=0)
spawn right task, serves as callback for partitioner
Definition: parallel_reduce.h:162
tbb::interface9::internal::start_reduce::my_partition
Partitioner::task_partition_type my_partition
Definition: parallel_reduce.h:89
tbb::interface9::internal::start_reduce::run
static void run(const Range &range, Body &body, Partitioner &partitioner)
Definition: parallel_reduce.h:131
tbb::interface9::internal::start_reduce::start_reduce
start_reduce(start_reduce &parent_, const Range &r, depth_t d)
Construct right child from the given range as response to the demand.
Definition: parallel_reduce.h:121
tbb::interface9::internal::start_reduce::my_context
reduction_context my_context
Definition: parallel_reduce.h:90
tbb::interface9::internal::start_reduce::start_reduce
start_reduce(const Range &range, Body *body, Partitioner &partitioner)
Constructor used for root task.
Definition: parallel_reduce.h:101
tbb::interface9::internal::start_reduce::my_body
Body * my_body
Definition: parallel_reduce.h:87
tbb::interface9::internal::start_reduce::start_reduce
start_reduce(start_reduce &parent_, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
Definition: parallel_reduce.h:110
tbb::interface9::internal::start_reduce::my_range
Range my_range
Definition: parallel_reduce.h:88
tbb::interface9::internal::start_reduce::finish_type
finish_reduce< Body > finish_type
Definition: parallel_reduce.h:86
tbb::interface9::internal::start_reduce::execute
task * execute() __TBB_override
Should be overridden by derived classes.
Definition: parallel_reduce.h:181
tbb::interface9::internal::start_reduce::run
static void run(const Range &range, Body &body, Partitioner &partitioner, task_group_context &context)
Definition: parallel_reduce.h:144
tbb::interface9::internal::start_reduce::run_body
void run_body(Range &r)
Run body for range.
Definition: parallel_reduce.h:150
tbb::interface9::internal::finish_deterministic_reduce
Task type used to combine the partial results of parallel_deterministic_reduce.
Definition: parallel_reduce.h:202
tbb::interface9::internal::finish_deterministic_reduce::my_left_body
Body & my_left_body
Definition: parallel_reduce.h:203
tbb::interface9::internal::finish_deterministic_reduce::my_right_body
Body my_right_body
Definition: parallel_reduce.h:204
tbb::interface9::internal::finish_deterministic_reduce::finish_deterministic_reduce
finish_deterministic_reduce(Body &body)
Definition: parallel_reduce.h:206
tbb::interface9::internal::finish_deterministic_reduce::execute
task * execute() __TBB_override
Should be overridden by derived classes.
Definition: parallel_reduce.h:211
tbb::interface9::internal::start_deterministic_reduce
Task type used to split the work of parallel_deterministic_reduce.
Definition: parallel_reduce.h:222
tbb::interface9::internal::start_deterministic_reduce::finish_type
finish_deterministic_reduce< Body > finish_type
Definition: parallel_reduce.h:223
tbb::interface9::internal::start_deterministic_reduce::my_partition
Partitioner::task_partition_type my_partition
Definition: parallel_reduce.h:226
tbb::interface9::internal::start_deterministic_reduce::my_range
Range my_range
Definition: parallel_reduce.h:225
tbb::interface9::internal::start_deterministic_reduce::run
static void run(const Range &range, Body &body, Partitioner &partitioner)
Definition: parallel_reduce.h:246
tbb::interface9::internal::start_deterministic_reduce::execute
task * execute() __TBB_override
Should be overridden by derived classes.
Definition: parallel_reduce.h:277
tbb::interface9::internal::start_deterministic_reduce::run_body
void run_body(Range &r)
Definition: parallel_reduce.h:273
tbb::interface9::internal::start_deterministic_reduce::my_body
Body & my_body
Definition: parallel_reduce.h:224
tbb::interface9::internal::start_deterministic_reduce::start_deterministic_reduce
start_deterministic_reduce(start_deterministic_reduce &parent_, finish_type &c, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
Definition: parallel_reduce.h:238
tbb::interface9::internal::start_deterministic_reduce::run
static void run(const Range &range, Body &body, Partitioner &partitioner, task_group_context &context)
Definition: parallel_reduce.h:259
tbb::interface9::internal::start_deterministic_reduce::offer_work
void offer_work(typename Partitioner::split_type &split_obj)
Definition: parallel_reduce.h:265
tbb::internal::lambda_reduce_body
Auxiliary class for parallel_reduce; for internal use only.
Definition: parallel_reduce.h:295
tbb::internal::lambda_reduce_body::result
Value result() const
Definition: parallel_reduce.h:330
tbb::internal::lambda_reduce_body::lambda_reduce_body
lambda_reduce_body(const lambda_reduce_body &other)
Definition: parallel_reduce.h:312
tbb::internal::lambda_reduce_body::operator=
lambda_reduce_body & operator=(const lambda_reduce_body &other)
tbb::internal::lambda_reduce_body::lambda_reduce_body
lambda_reduce_body(lambda_reduce_body &other, tbb::split)
Definition: parallel_reduce.h:318
tbb::internal::lambda_reduce_body::my_reduction
const Reduction & my_reduction
Definition: parallel_reduce.h:302
tbb::internal::lambda_reduce_body::my_real_body
const RealBody & my_real_body
Definition: parallel_reduce.h:301
tbb::internal::lambda_reduce_body::join
void join(lambda_reduce_body &rhs)
Definition: parallel_reduce.h:327
tbb::internal::lambda_reduce_body::operator()
void operator()(Range &range)
Definition: parallel_reduce.h:324
tbb::internal::lambda_reduce_body::identity_element
const Value & identity_element
Definition: parallel_reduce.h:300
tbb::internal::lambda_reduce_body::lambda_reduce_body
lambda_reduce_body(const Value &identity, const RealBody &body, const Reduction &reduction)
Definition: parallel_reduce.h:306
tbb::internal::lambda_reduce_body::my_value
Value my_value
Definition: parallel_reduce.h:303
tbb::interface9::internal::flag_task
Join task node that contains shared flag for stealing feedback.
Definition: partitioner.h:128
tbb::simple_partitioner
A simple partitioner.
Definition: partitioner.h:586
tbb::auto_partitioner
An auto partitioner.
Definition: partitioner.h:613
tbb::static_partitioner
A static partitioner.
Definition: partitioner.h:632
tbb::affinity_partitioner
An affinity partitioner.
Definition: partitioner.h:651
tbb::internal::allocate_continuation_proxy::allocate
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
Definition: task.cpp:96
tbb::internal::allocate_child_proxy::allocate
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
Definition: task.cpp:114
tbb::task_group_context
Used to form groups of tasks.
Definition: task.h:358
tbb::task
Base class for user-defined tasks.
Definition: task.h:615
tbb::task::execute
virtual task * execute()=0
Should be overridden by derived classes.
tbb::task::allocate_continuation
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
Definition: task.h:676
tbb::task::set_parent
void set_parent(task *p)
sets parent task pointer to specified value
Definition: task.h:868
tbb::task::allocate_child
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
Definition: task.h:681
tbb::task::allocate_root
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:663
tbb::task::set_ref_count
void set_ref_count(int count)
Set reference count.
Definition: task.h:761
tbb::task::affinity_id
internal::affinity_id affinity_id
An id as used for specifying affinity.
Definition: task.h:940
tbb::task::spawn_root_and_wait
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
Definition: task.h:808
tbb::split
Dummy type that distinguishes splitting constructor from copy constructor.
Definition: tbb_stddef.h:416

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.