default_partitioner Class Template Reference

Interface for partitioners: configuring how ranges are partitioned. More...

Inherited by tag_partitioner.

List of all members.

Public Types

typedef range_is_range_type split_type

Public Member Functions

template<typename Range, typename StepInstance>
void divide_and_originate (Range &range, StepInstance &si) const
 divide given range into in arbitrary number of ranges of type Range
template<typename Range>
bool is_divisible (const Range &range) const
 return true, if given range is divisible, false otherwise
int grain_size (size_t fullRangeSize) const


Detailed Description

template<int grainSize = 0>
class CnC::default_partitioner< grainSize >

Interface for partitioners: configuring how ranges are partitioned.

The default_partitioner implements the template interface that each partitioner must satisfy.

Given a range type "R", a partitioner "P" must provide a copy-constructor and the following (template) interface:

The default_partitioner can be parametrized as follows: Set template argument to > 0 to let it use a fixed grainsize. If it equals 0, the grainsize is set to "original_rangeSize / #threads / 4"

Definition at line 49 of file default_partitioner.h.


Member Typedef Documentation

typedef range_is_range_type split_type

set to range_is_tag_type if tag is self-dividing, e.g. if the range-type is also the tag-type as passed to the step set to range_is_range_type if tag is undivisible, e.g. if range-type != step_type

Reimplemented in tag_partitioner.

Definition at line 84 of file default_partitioner.h.


Member Function Documentation

void divide_and_originate ( Range &  range,
StepInstance &  si 
) const [inline]

divide given range into in arbitrary number of ranges of type Range

Call si.originate_range( r ) for each new range. The original - but modified - range is treated as unsplittable afterwards. It must *not* be passed to originate_range! If tag-types are self-dividing (e.g. if range-type == tag-type) you can call "originate" instead of "originate_range" for leaves of the recursive range-tree.

The aggregated set of the members of the sub-ranges applied to "t.originate[_range]" must equal the set of member in given range. Overlapping ranges or gaps may lead to arbitrary effects.

Parameters:
range the original range to split, may be altered
si opaque object, call t.Put( r, splittable ) for all sub-ranges

Reimplemented in tag_partitioner.

Definition at line 140 of file default_partitioner.h.

00141     {
00142         divide_and_originate( range, si, grain_size( range.size() ) );
00143     }

int grain_size ( size_t  fullRangeSize  )  const [inline]

Returns:
grainsize for given size of unsplitted range

Definition at line 102 of file default_partitioner.h.

00103     {
00104         if( grainSize > 0 ) return grainSize;
00105         else {
00106             if( m_grainSize <= 0 ) {
00107                 static int _nt = 0;
00108                 if( _nt == 0 ) {
00109                     if( getenv( "CNC_NUM_THREADS" ) ) {
00110                         _nt = atoi( getenv( "CNC_NUM_THREADS" ) );
00111                     } else {
00112                         _nt = tbb::task_scheduler_init::default_num_threads();
00113                     }
00114                 }
00115 #define MX( _a, _b ) ((_a) > (_b) ? (_a) : (_b))
00116                 const_cast< int & >( m_grainSize ) = rangeSize > 0 ? MX( 1, (int)(rangeSize / (size_t)_nt / 4) ) : 1;
00117             }
00118             return m_grainSize;
00119         }
00120     }


The documentation for this class was generated from the following file:

Generated on Tue Aug 31 15:30:28 2010 for CnC by  doxygen 1.5.6