277 lines
18 KiB
XML
277 lines
18 KiB
XML
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
|
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.9.1" xml:lang="en-US">
|
|
<compounddef id="classtf_1_1PartitionerBase" kind="class" language="C++" prot="public">
|
|
<compoundname>tf::PartitionerBase</compoundname>
|
|
<basecompoundref prot="public" virt="non-virtual">tf::IsPartitioner</basecompoundref>
|
|
<includes refid="partitioner_8hpp" local="no">taskflow/algorithm/partitioner.hpp</includes>
|
|
<templateparamlist>
|
|
<param>
|
|
<type>typename C</type>
|
|
<defval><ref refid="structtf_1_1DefaultClosureWrapper" kindref="compound">DefaultClosureWrapper</ref></defval>
|
|
</param>
|
|
</templateparamlist>
|
|
<sectiondef kind="public-type">
|
|
<memberdef kind="typedef" id="classtf_1_1PartitionerBase_1a2b6152f24c2a3d6e750349d02ecb4595" prot="public" static="no">
|
|
<type>C</type>
|
|
<definition>using tf::PartitionerBase< C >::closure_wrapper_type = C</definition>
|
|
<argsstring></argsstring>
|
|
<name>closure_wrapper_type</name>
|
|
<briefdescription>
|
|
<para>the closure type </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="137" column="3" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="137" bodyend="-1"/>
|
|
</memberdef>
|
|
</sectiondef>
|
|
<sectiondef kind="protected-attrib">
|
|
<memberdef kind="variable" id="classtf_1_1PartitionerBase_1a9ff56f7150ee4ff42b5006942f9c4b52" prot="protected" static="no" mutable="no">
|
|
<type>size_t</type>
|
|
<definition>size_t tf::PartitionerBase< C >::_chunk_size</definition>
|
|
<argsstring></argsstring>
|
|
<name>_chunk_size</name>
|
|
<initializer>{0}</initializer>
|
|
<briefdescription>
|
|
<para>chunk size </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="183" column="10" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="183" bodyend="-1"/>
|
|
</memberdef>
|
|
<memberdef kind="variable" id="classtf_1_1PartitionerBase_1a9c5a8d350a913bea4c63d350e2bc9d1b" prot="protected" static="no" mutable="no">
|
|
<type>C</type>
|
|
<definition>C tf::PartitionerBase< C >::_closure_wrapper</definition>
|
|
<argsstring></argsstring>
|
|
<name>_closure_wrapper</name>
|
|
<briefdescription>
|
|
<para>closure wrapper </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="188" column="5" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="188" bodyend="-1"/>
|
|
</memberdef>
|
|
</sectiondef>
|
|
<sectiondef kind="public-func">
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1ad0037e70726a054527a923821ec2d95a" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
|
|
<type></type>
|
|
<definition>tf::PartitionerBase< C >::PartitionerBase</definition>
|
|
<argsstring>()=default</argsstring>
|
|
<name>PartitionerBase</name>
|
|
<briefdescription>
|
|
<para>default constructor </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="142" column="3"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1a099464a339e09d9f6e4a59bec425c53a" prot="public" static="no" const="no" explicit="yes" inline="yes" virt="non-virtual">
|
|
<type></type>
|
|
<definition>tf::PartitionerBase< C >::PartitionerBase</definition>
|
|
<argsstring>(size_t chunk_size)</argsstring>
|
|
<name>PartitionerBase</name>
|
|
<param>
|
|
<type>size_t</type>
|
|
<declname>chunk_size</declname>
|
|
</param>
|
|
<briefdescription>
|
|
<para>construct a partitioner with the given chunk size </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="147" column="12" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="147" bodyend="147"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1a9cf9f5400992c6d9bd4131b5af2b9e8e" prot="public" static="no" const="no" explicit="no" inline="yes" virt="non-virtual">
|
|
<type></type>
|
|
<definition>tf::PartitionerBase< C >::PartitionerBase</definition>
|
|
<argsstring>(size_t chunk_size, C &&closure_wrapper)</argsstring>
|
|
<name>PartitionerBase</name>
|
|
<param>
|
|
<type>size_t</type>
|
|
<declname>chunk_size</declname>
|
|
</param>
|
|
<param>
|
|
<type>C &&</type>
|
|
<declname>closure_wrapper</declname>
|
|
</param>
|
|
<briefdescription>
|
|
<para>construct a partitioner with the given chunk size and closure wrapper </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="152" column="3" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="152" bodyend="155"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1afa34299dea355738efa5684024d08215" prot="public" static="no" const="yes" explicit="no" inline="yes" virt="non-virtual">
|
|
<type>size_t</type>
|
|
<definition>size_t tf::PartitionerBase< C >::chunk_size</definition>
|
|
<argsstring>() const</argsstring>
|
|
<name>chunk_size</name>
|
|
<briefdescription>
|
|
<para>query the chunk size of this partitioner </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="160" column="10" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="160" bodyend="160"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1a481097aeb7ec62dcc23584eaa48cbce4" prot="public" static="no" const="no" explicit="no" inline="yes" virt="non-virtual">
|
|
<type>void</type>
|
|
<definition>void tf::PartitionerBase< C >::chunk_size</definition>
|
|
<argsstring>(size_t cz)</argsstring>
|
|
<name>chunk_size</name>
|
|
<param>
|
|
<type>size_t</type>
|
|
<declname>cz</declname>
|
|
</param>
|
|
<briefdescription>
|
|
<para>update the chunk size of this partitioner </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="165" column="8" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="165" bodyend="165"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1a929714296243b2c63e4f2baa2025d380" prot="public" static="no" const="yes" explicit="no" inline="yes" virt="non-virtual">
|
|
<type>const C &</type>
|
|
<definition>const C& tf::PartitionerBase< C >::closure_wrapper</definition>
|
|
<argsstring>() const</argsstring>
|
|
<name>closure_wrapper</name>
|
|
<briefdescription>
|
|
<para>acquire an immutable access to the closure wrapper object </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="170" column="11" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="170" bodyend="170"/>
|
|
</memberdef>
|
|
<memberdef kind="function" id="classtf_1_1PartitionerBase_1a99e23ce7c0faf3a932ab2b7ac51e58f4" prot="public" static="no" const="no" explicit="no" inline="yes" virt="non-virtual">
|
|
<templateparamlist>
|
|
<param>
|
|
<type>typename F</type>
|
|
</param>
|
|
</templateparamlist>
|
|
<type>void</type>
|
|
<definition>void tf::PartitionerBase< C >::closure_wrapper</definition>
|
|
<argsstring>(F &&fn)</argsstring>
|
|
<name>closure_wrapper</name>
|
|
<param>
|
|
<type>F &&</type>
|
|
<declname>fn</declname>
|
|
</param>
|
|
<briefdescription>
|
|
<para>modify the closure wrapper object </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<inbodydescription>
|
|
</inbodydescription>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="176" column="8" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="176" bodyend="176"/>
|
|
</memberdef>
|
|
</sectiondef>
|
|
<briefdescription>
|
|
<para>class to derive a partitioner for scheduling parallel algorithms </para>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
<para><parameterlist kind="templateparam"><parameteritem>
|
|
<parameternamelist>
|
|
<parametername>C</parametername>
|
|
</parameternamelist>
|
|
<parameterdescription>
|
|
<para>closure wrapper type</para>
|
|
</parameterdescription>
|
|
</parameteritem>
|
|
</parameterlist>
|
|
The class provides base methods to derive a partitioner that can be used to schedule parallel iterations (e.g., <ref refid="classtf_1_1FlowBuilder_1aae3edfa278baa75b08414e083c14c836" kindref="member">tf::Taskflow::for_each</ref>).</para>
|
|
<para>An partitioner defines the scheduling method for running parallel algorithms, such <ref refid="classtf_1_1FlowBuilder_1aae3edfa278baa75b08414e083c14c836" kindref="member">tf::Taskflow::for_each</ref>, <ref refid="classtf_1_1FlowBuilder_1afb24798ebf46e253a40b01bffb1da6a7" kindref="member">tf::Taskflow::reduce</ref>, and so on. By default, we provide the following partitioners:</para>
|
|
<para><itemizedlist>
|
|
<listitem><para><ref refid="classtf_1_1GuidedPartitioner" kindref="compound">tf::GuidedPartitioner</ref> to enable guided scheduling algorithm of adaptive chunk size</para>
|
|
</listitem><listitem><para><ref refid="classtf_1_1DynamicPartitioner" kindref="compound">tf::DynamicPartitioner</ref> to enable dynamic scheduling algorithm of equal chunk size</para>
|
|
</listitem><listitem><para><ref refid="classtf_1_1StaticPartitioner" kindref="compound">tf::StaticPartitioner</ref> to enable static scheduling algorithm of static chunk size</para>
|
|
</listitem><listitem><para><ref refid="classtf_1_1RandomPartitioner" kindref="compound">tf::RandomPartitioner</ref> to enable random scheduling algorithm of random chunk size</para>
|
|
</listitem></itemizedlist>
|
|
</para>
|
|
<para>Depending on applications, partitioning algorithms can impact the performance a lot. For example, if a parallel-iteration workload contains a regular work unit per iteration, <ref refid="classtf_1_1StaticPartitioner" kindref="compound">tf::StaticPartitioner</ref> can deliver the best performance. On the other hand, if the work unit per iteration is irregular and unbalanced, <ref refid="classtf_1_1GuidedPartitioner" kindref="compound">tf::GuidedPartitioner</ref> or <ref refid="classtf_1_1DynamicPartitioner" kindref="compound">tf::DynamicPartitioner</ref> can outperform <ref refid="classtf_1_1StaticPartitioner" kindref="compound">tf::StaticPartitioner</ref>. In most situations, <ref refid="classtf_1_1GuidedPartitioner" kindref="compound">tf::GuidedPartitioner</ref> can deliver decent performance and is thus used as our default partitioner.</para>
|
|
<para><simplesect kind="note"><para>Giving the partition size of 0 lets the Taskflow runtime automatically determines the partition size for the given partitioner.</para>
|
|
</simplesect>
|
|
In addition to partition size, the application can specify a closure wrapper for a 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:</para>
|
|
<para><programlisting filename=".cpp"><codeline><highlight class="normal"><ref refid="cpp/atomic/atomic" kindref="compound" external="/home/thuang295/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::atomic<int></ref><sp/><ref refid="cpp/algorithm/count" kindref="compound" external="/home/thuang295/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">count</ref><sp/>=<sp/>0;</highlight></codeline>
|
|
<codeline><highlight class="normal"><ref refid="classtf_1_1Taskflow" kindref="compound">tf::Taskflow</ref><sp/>taskflow;</highlight></codeline>
|
|
<codeline><highlight class="normal">taskflow.<ref refid="classtf_1_1FlowBuilder_1a3b132bd902331a11b04b4ad66cf8bf77" kindref="member">for_each_index</ref>(0,<sp/>100,<sp/>1,<sp/></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/>[](){<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="cpp/io/c/fprintf" kindref="compound" external="/home/thuang295/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">printf</ref>(</highlight><highlight class="stringliteral">"%d\n"</highlight><highlight class="normal">,<sp/>i);<sp/></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/>},</highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><ref refid="classtf_1_1StaticPartitioner" kindref="compound">tf::StaticPartitioner</ref>(0,<sp/>[](</highlight><highlight class="keyword">auto</highlight><highlight class="normal">&&<sp/>closure){</highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>do<sp/>something<sp/>before<sp/>invoking<sp/>the<sp/>partitioned<sp/>task</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>...</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>invoke<sp/>the<sp/>partitioned<sp/>task</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>closure();</highlight></codeline>
|
|
<codeline><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>do<sp/>something<sp/>else<sp/>after<sp/>invoking<sp/>the<sp/>partitioned<sp/>task</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>...</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline><highlight class="normal">);</highlight></codeline>
|
|
<codeline><highlight class="normal">executor.run(taskflow).wait();</highlight></codeline>
|
|
</programlisting></para>
|
|
<para><simplesect kind="note"><para>The default closure wrapper (<ref refid="structtf_1_1DefaultClosureWrapper" kindref="compound">tf::DefaultClosureWrapper</ref>) does nothing but invoke the partitioned task (closure). </para>
|
|
</simplesect>
|
|
</para>
|
|
</detaileddescription>
|
|
<inheritancegraph>
|
|
<node id="1">
|
|
<label>tf::PartitionerBase< C ></label>
|
|
<link refid="classtf_1_1PartitionerBase"/>
|
|
<childnode refid="2" relation="public-inheritance">
|
|
</childnode>
|
|
</node>
|
|
<node id="2">
|
|
<label>tf::IsPartitioner</label>
|
|
</node>
|
|
</inheritancegraph>
|
|
<collaborationgraph>
|
|
<node id="1">
|
|
<label>tf::PartitionerBase< C ></label>
|
|
<link refid="classtf_1_1PartitionerBase"/>
|
|
<childnode refid="2" relation="public-inheritance">
|
|
</childnode>
|
|
<childnode refid="3" relation="usage">
|
|
<edgelabel>_closure_wrapper</edgelabel>
|
|
</childnode>
|
|
</node>
|
|
<node id="2">
|
|
<label>tf::IsPartitioner</label>
|
|
</node>
|
|
<node id="3">
|
|
<label>tf::DefaultClosureWrapper</label>
|
|
<link refid="structtf_1_1DefaultClosureWrapper"/>
|
|
</node>
|
|
</collaborationgraph>
|
|
<location file="taskflow/algorithm/partitioner.hpp" line="130" column="1" bodyfile="taskflow/algorithm/partitioner.hpp" bodystart="130" bodyend="189"/>
|
|
<listofallmembers>
|
|
<member refid="classtf_1_1PartitionerBase_1a9ff56f7150ee4ff42b5006942f9c4b52" prot="protected" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>_chunk_size</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a9c5a8d350a913bea4c63d350e2bc9d1b" prot="protected" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>_closure_wrapper</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1afa34299dea355738efa5684024d08215" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>chunk_size</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a481097aeb7ec62dcc23584eaa48cbce4" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>chunk_size</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a929714296243b2c63e4f2baa2025d380" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>closure_wrapper</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a99e23ce7c0faf3a932ab2b7ac51e58f4" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>closure_wrapper</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a2b6152f24c2a3d6e750349d02ecb4595" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>closure_wrapper_type</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1ad0037e70726a054527a923821ec2d95a" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>PartitionerBase</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a099464a339e09d9f6e4a59bec425c53a" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>PartitionerBase</name></member>
|
|
<member refid="classtf_1_1PartitionerBase_1a9cf9f5400992c6d9bd4131b5af2b9e8e" prot="public" virt="non-virtual"><scope>tf::PartitionerBase</scope><name>PartitionerBase</name></member>
|
|
</listofallmembers>
|
|
</compounddef>
|
|
</doxygen>
|