tf::RandomPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
taskflow/algorithm/partitioner.hpp
typename C DefaultClosureWrapper
float float tf::RandomPartitioner< C >::_alpha _alpha tf::RandomPartitioner::_alpha {0.01f}
float float tf::RandomPartitioner< C >::_beta _beta tf::RandomPartitioner::_beta {0.5f}
PartitionerType static constexpr PartitionerType tf::RandomPartitioner< C >::type () type tf::RandomPartitioner::type

queries the partition type (dynamic)

tf::RandomPartitioner< C >::RandomPartitioner
()=default
RandomPartitioner
tf::RandomPartitioner::RandomPartitioner

default constructor

tf::RandomPartitioner< C >::RandomPartitioner
(size_t sz)
RandomPartitioner
tf::RandomPartitioner::RandomPartitioner
size_t sz

construct a dynamic partitioner with the given chunk size

tf::RandomPartitioner< C >::RandomPartitioner
(size_t sz, C &&closure)
RandomPartitioner
tf::RandomPartitioner::RandomPartitioner
size_t sz
C && closure

construct a random partitioner with the given chunk size and the closure

tf::RandomPartitioner< C >::RandomPartitioner
(float alpha, float beta)
RandomPartitioner
tf::RandomPartitioner::RandomPartitioner
float alpha
float beta

constructs a random partitioner with the given parameters

tf::RandomPartitioner< C >::RandomPartitioner
(float alpha, float beta, C &&closure)
RandomPartitioner
tf::RandomPartitioner::RandomPartitioner
float alpha
float beta
C && closure

constructs a random partitioner with the given parameters and the closure

float float tf::RandomPartitioner< C >::alpha () const alpha tf::RandomPartitioner::alpha

queries the `alpha` value

float float tf::RandomPartitioner< C >::beta () const beta tf::RandomPartitioner::beta

queries the `beta` value

std::pair< size_t, size_t > std::pair< size_t, size_t > tf::RandomPartitioner< C >::chunk_size_range (size_t N, size_t W) const chunk_size_range tf::RandomPartitioner::chunk_size_range size_t N size_t W

queries the range of chunk size

N

number of iterations

W

number of workers

typename F
std::enable_if_t< std::is_invocable_r_v< void, F, size_t, size_t >, void > * nullptr
void void tf::RandomPartitioner< C >::loop (size_t N, size_t W, std::atomic< size_t > &next, F &&func) const loop tf::RandomPartitioner::loop size_t N size_t W std::atomic< size_t > & next F && func
typename F
std::enable_if_t< std::is_invocable_r_v< bool, F, size_t, size_t >, void > * nullptr
void void tf::RandomPartitioner< C >::loop_until (size_t N, size_t W, std::atomic< size_t > &next, F &&func) const loop_until tf::RandomPartitioner::loop_until size_t N size_t W std::atomic< size_t > & next F && func

class to construct a random partitioner for scheduling parallel algorithms

C

closure wrapper type (default tf::DefaultClosureWrapper)

Similar to tf::DynamicPartitioner, the partitioner splits iterations into many partitions but each with a random chunk size in the range, `c = [alpha * N * W, beta * N * W]`. By default, `alpha` is `0.01` and `beta` is `0.5`, respectively.

In addition to partition size, the application can specify a closure wrapper for a random partitioner. A closure wrapper allows the application to wrapper a partitioned task (i.e., closure) with a custom function object that performs additional tasks. For example:

    std::atomic<int>count=0;
    tf::Taskflowtaskflow;
    taskflow.for_each_index(0,100,1,
    [](){
    printf("%d\n",i);
    },
    tf::RandomPartitioner(0,[](auto&&closure){
    //dosomethingbeforeinvokingthepartitionedtask
    //...

    //invokethepartitionedtask
    closure();

    //dosomethingelseafterinvokingthepartitionedtask
    //...
    }
    );
    executor.run(taskflow).wait();

tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
tf::RandomPartitioner< C >
tf::DefaultClosureWrapper
tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
_closure_wrapper
tf::RandomPartitioner< C >
- tf::RandomPartitioner
  _alpha
- tf::RandomPartitioner
  _beta
- tf::RandomPartitioner
  _chunk_size
- tf::RandomPartitioner
  _closure_wrapper
- tf::RandomPartitioner
  alpha
- tf::RandomPartitioner
  beta
- tf::RandomPartitioner
  chunk_size
- tf::RandomPartitioner
  chunk_size_range
- tf::RandomPartitioner
  closure_wrapper
- tf::RandomPartitioner
  closure_wrapper_type
- tf::RandomPartitioner
  is_default_wrapper_v
- tf::RandomPartitioner
  loop
- tf::RandomPartitioner
  loop_until
- tf::RandomPartitioner
  operator()
- tf::RandomPartitioner
  PartitionerBase
- tf::RandomPartitioner
  RandomPartitioner
- tf::RandomPartitioner
  RandomPartitioner
- tf::RandomPartitioner
  RandomPartitioner
- tf::RandomPartitioner
  RandomPartitioner
- tf::RandomPartitioner
  RandomPartitioner
- tf::RandomPartitioner
  type