tf::StaticPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
taskflow/algorithm/partitioner.hpp
typename C DefaultClosureWrapper
PartitionerType static constexpr PartitionerType tf::StaticPartitioner< C >::type () type tf::StaticPartitioner::type

queries the partition type (static)

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

default constructor

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

construct a static partitioner with the given chunk size

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

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

size_t size_t tf::StaticPartitioner< C >::adjusted_chunk_size (size_t N, size_t W, size_t w) const adjusted_chunk_size tf::StaticPartitioner::adjusted_chunk_size size_t N size_t W size_t w

queries the adjusted chunk size

Returns the given chunk size if it is not zero, or returns `N/W + (w < NW)`, where `N` is the number of iterations, `W` is the number of workers, and `w` is the worker ID.

typename F
std::enable_if_t< std::is_invocable_r_v< void, F, size_t, size_t >, void > * nullptr
void void tf::StaticPartitioner< C >::loop (size_t N, size_t W, size_t curr_b, size_t chunk_size, F &&func) loop tf::StaticPartitioner::loop size_t N size_t W size_t curr_b size_t chunk_size F && func
typename F
std::enable_if_t< std::is_invocable_r_v< bool, F, size_t, size_t >, void > * nullptr
void void tf::StaticPartitioner< C >::loop_until (size_t N, size_t W, size_t curr_b, size_t chunk_size, F &&func) loop_until tf::StaticPartitioner::loop_until size_t N size_t W size_t curr_b size_t chunk_size F && func

class to construct a static partitioner for scheduling parallel algorithms

C

closure wrapper type (default tf::DefaultClosureWrapper)

The partitioner divides iterations into chunks and distributes chunks to workers in order. If the chunk size is not specified (default `0`), the partitioner resorts to a chunk size that equally distributes iterations into workers.

    std::vector<int>data={1,2,3,4,5,6,7,8,9,10}
    taskflow.for_each(
    data.begin(),data.end(),[](inti){},StaticPartitioner(0)
    );
    executor.run(taskflow).run();

In addition to partition size, the application can specify a closure wrapper for a static 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::StaticPartitioner(0,[](auto&&closure){
    //dosomethingbeforeinvokingthepartitionedtask
    //...

    //invokethepartitionedtask
    closure();

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

tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
tf::StaticPartitioner< C >
tf::DefaultClosureWrapper
tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
_closure_wrapper
tf::StaticPartitioner< C >
- tf::StaticPartitioner
  _chunk_size
- tf::StaticPartitioner
  _closure_wrapper
- tf::StaticPartitioner
  adjusted_chunk_size
- tf::StaticPartitioner
  chunk_size
- tf::StaticPartitioner
  closure_wrapper
- tf::StaticPartitioner
  closure_wrapper_type
- tf::StaticPartitioner
  is_default_wrapper_v
- tf::StaticPartitioner
  loop
- tf::StaticPartitioner
  loop_until
- tf::StaticPartitioner
  operator()
- tf::StaticPartitioner
  PartitionerBase
- tf::StaticPartitioner
  StaticPartitioner
- tf::StaticPartitioner
  StaticPartitioner
- tf::StaticPartitioner
  StaticPartitioner
- tf::StaticPartitioner
  type