docs/classtf_1_1GuidedPartitioner.html
class to create a guided partitioner for scheduling parallel algorithms
| Template parameters |
|---|
| C |
The size of a partition is proportional to the number of unassigned iterations divided by the number of workers, and the size will gradually decrease to the given chunk size. The last partition may be smaller than the chunk size.
In addition to partition size, the application can specify a closure wrapper for a guided partitioner. A closure wrapper allows the application to wrap a partitioned task (i.e., closure) with a custom function object that performs additional tasks. For example:
std::atomic\<int\> count = 0;tf::Taskflow taskflow;taskflow.for\_each\_index(0, 100, 1, [](){printf("%d\n", i); },tf::GuidedPartitioner(0, [](auto&& closure){// do something before invoking the partitioned task// ...// invoke the partitioned taskclosure();// do something else after invoking the partitioned task// ...});executor.run(taskflow).wait();
template<typename C = DefaultClosureWrapper> class PartitionerBase<DefaultClosureWrapper>class to derive a partitioner for scheduling parallel algorithms
static auto type() -> PartitionerType constexprqueries the partition type (dynamic)
GuidedPartitioner() defaulteddefault constructorGuidedPartitioner(size_t sz) explicit construct a guided partitioner with the given chunk sizeGuidedPartitioner(size_t sz, C&& closure) explicit construct a guided partitioner with the given chunk size and the closure