<p>A <ahref="classtf_1_1Pipeline.html" class="m-doc">tf::<wbr/>Pipeline</a> is a composable graph object that allows users to parallelize an application using pipeline parallelism. Unlike conventional pipeline programming frameworks (e.g., Intel TBB), <ahref="classtf_1_1Pipeline.html" class="m-doc">tf::<wbr/>Pipeline</a> does not provide any data abstraction but a task-parallel framework for users to customize their data layout when leveraging pipeline parallelism. The following code creates a pipeline with four parallel lines that schedule five tokens through three pipes of a serial-parallel-serial direction:</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Taskflow</span><spanclass="w"></span><spanclass="n">taskflow</span><spanclass="p">;</span>
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">run</span><spanclass="p">(</span><spanclass="n">taskflow</span><spanclass="p">).</span><spanclass="n">wait</span><spanclass="p">();</span></pre><p>The five tokens will be scheduled across four parallel lines in a circular fashion, as depicted below:</p><divclass="m-graph"><svgstyle="width: 24.200rem; height: 33.200rem;" viewBox="0.00 0.00 242.00 332.00">
</div><p>At each pipe stage, the program propagates the result to the next pipe by adding one to the result stored in a custom data storage, <code>buffer</code>. The pipeline scheduler will generate five scheduling tokens and then stop.</p><p>Internally, <ahref="classtf_1_1Pipeline.html" class="m-doc">tf::<wbr/>Pipeline</a> uses <ahref="http://en.cppreference.com/w/cpp/utility/tuple.html" class="m-doc-external">std::<wbr/>tuple</a> to store the given sequence of pipes. The definition of each pipe can be different, completely decided by the compiler to optimize the object layout. After a pipeline is constructed, it is not possible to change its pipes. If applications need to change these pipes, please use <ahref="classtf_1_1ScalablePipeline.html" class="m-doc">tf::<wbr/>ScalablePipeline</a>.</p>
<p>Constructs a pipeline of up to <code>num_lines</code> parallel lines to schedule tokens through the given linear chain of pipes. The first pipe must define a serial direction (<ahref="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0" class="m-doc">tf::<wbr/>PipeType::<wbr/>SERIAL</a>) or an exception will be thrown.</p>
<p>Constructs a pipeline of up to <code>num_lines</code> parallel lines to schedule tokens through the given linear chain of pipes. The first pipe must define a serial direction (<ahref="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0" class="m-doc">tf::<wbr/>PipeType::<wbr/>SERIAL</a>) or an exception will be thrown.</p>
<p>The function returns the number of parallel lines given by the user upon the construction of the pipeline. The number of lines represents the maximum parallelism this pipeline can achieve.</p>
<p>Resetting the pipeline to the initial state. After resetting a pipeline, its token identifier will start from zero as if the pipeline was just constructed.</p>