#include <common.h>
Inheritance diagram for rpa::range_size< It >:
Public Member Functions | |
range_size (It aBeg, It aEnd, size_t aSize, chunk_t aMinChkSz=chunk_t()) | |
range_size (It aBeg, It aEnd, chunk_t aMinChkSz=chunk_t()) | |
range_size (const range_size &aRS) | |
Plain copy constructor. | |
void | calc_wdth (thread_tree_core &aThrTree) |
Adjusts the threads number actually used, less or equal than the max threads number. | |
size_t | size_thr (void) const |
slice | chop (void) |
template<class Rng2> | |
tuple2< slice, typename Rng2::slice > | chop (Rng2 &aSq2) |
slice | tail (void) |
Returns the sequences end, for algorithms working on one sequence: count,accumulate... | |
template<class Rng2> | |
tuple2< slice, typename Rng2::slice > | tail (Rng2 &aSq2) |
Private Types | |
typedef range_lambda< It > | rl_base |
Does not need volatile iterators because chops are done by the main thread. | |
Private Member Functions | |
void | check (void) const |
For debugging purpose only. | |
range_size & | operator= (const range_size &) |
Not assignable. No technical reason for this, just for full control. | |
Private Attributes | |
const size_t | _Size |
The number of elements in the input sequence, set by the constructor. | |
size_t | _SizePerThr |
The 'nominal' number of elements that each sub-thread will process. | |
Classes | |
struct | range_out |
struct | range_out< It2, std::output_iterator_tag > |
class | slice |
Models a slice begin/end given by 'chop' or 'tail', processed by a single sub-thread. More... |
typedef range_lambda< It > rpa::range_size< It >::rl_base [private] |
Does not need volatile iterators because chops are done by the main thread.
rpa::range_size< It >::range_size | ( | It | aBeg, | |
It | aEnd, | |||
size_t | aSize, | |||
chunk_t | aMinChkSz = chunk_t() | |||
) | [inline] |
Maybe the iterators type do not allow to compute quickly the number of elements, for example if this is the begin and end of a std::list. In this case, we can provide it explicitely, for example the container size. If the given number of elements is different of the distance between the two operators, the results are unpredictable !!!
This checks, in debugging mode, if the given distance is really the distance between the iterators. This check cannot be done for input_iterator_tag.
rpa::range_size< It >::range_size | ( | It | aBeg, | |
It | aEnd, | |||
chunk_t | aMinChkSz = chunk_t() | |||
) | [inline] |
If no number of elements is given, then we compute the iterators distance, which is very convenient for random_access iterators.
rpa::range_size< It >::range_size | ( | const range_size< It > & | aRS | ) | [inline] |
Plain copy constructor.
void rpa::range_size< It >::calc_wdth | ( | thread_tree_core & | aThrTree | ) | [inline] |
Adjusts the threads number actually used, less or equal than the max threads number.
It is useless to have more threads than elements to process. But there must be at least one thread.
The minimum reasonable value for the chunk size, in order to be efficient, is stored in _SizePerThr by the constructor.
If the number of elements to process, _Size, is smaller that this minimum myInitSizePerThr, there must be at least one thread.
void rpa::range_size< It >::check | ( | void | ) | const [inline, private] |
For debugging purpose only.
The size per threads is zero, only if there were no elements at the beginning.
If no elements, then Beg and Equal identical.
tuple2< slice, typename Rng2::slice > rpa::range_size< It >::chop | ( | Rng2 & | aSq2 | ) | [inline] |
slice rpa::range_size< It >::chop | ( | void | ) | [inline] |
We do not need the return value because we known in advance how many elements are there. If the sequence is empty, we return an empty slice.
range_size& rpa::range_size< It >::operator= | ( | const range_size< It > & | ) | [private] |
Not assignable. No technical reason for this, just for full control.
size_t rpa::range_size< It >::size_thr | ( | void | ) | const [inline] |
Used by the comparison function for debugging. Necessary because some execution methods change the order of the output results, and this new order is dependent on the number of elements processed in one go. So we use this number to analyse if the algorithm worked correctly.
tuple2< slice, typename Rng2::slice > rpa::range_size< It >::tail | ( | Rng2 & | aSq2 | ) | [inline] |
Returns the last slice of the sequence, that is a number of elements between _SizePerThr and 2*_SizePerThr-1. It would perhaps be fine to replace the method 'tail' by a change to 'chop', which would check whether the next call to 'chop' would finish, would exhaust the sequence. Pros: Simplified interface, no need to choose between 'chop' and 'tail'. Same interface for all sequences. Con : 'chop' would be slightly more complicated, therefore slower.
slice rpa::range_size< It >::tail | ( | void | ) | [inline] |
Returns the sequences end, for algorithms working on one sequence: count,accumulate...
const size_t rpa::range_size< It >::_Size [private] |
The number of elements in the input sequence, set by the constructor.
size_t rpa::range_size< It >::_SizePerThr [private] |
The 'nominal' number of elements that each sub-thread will process.
All the first sub-threads except the last one will process exactely this number. The last sub-thread, corresponding to the end of the sequence, will process a number of elements between _SizePerThr and 2*_SizePerThr-1. This, because of the rounding errors of the division of _Size by NbThreads.