You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<dd>constructs a dynamic task to perform STL-styled parallel sort using the <code>std::less<T></code> comparator, where <code>T</code> is the element type</dd>
<p>The following example creates a static task.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Task</span><spanclass="n">static_task</span><spanclass="o">=</span><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace</span><spanclass="p">([](){});</span></pre><p>Please refer to <ahref="StaticTasking.html" class="m-doc">Static Tasking</a> for details.</p>
<p>The following example creates a dynamic task (<ahref="classtf_1_1Subflow.html" class="m-doc">tf::<wbr/>Subflow</a>) that spawns two static tasks.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Task</span><spanclass="n">dynamic_task</span><spanclass="o">=</span><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace</span><spanclass="p">([](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Subflow</span><spanclass="o">&</span><spanclass="n">sf</span><spanclass="p">){</span>
<p>The following example creates an if-else block using one condition task and three static tasks.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Taskflow</span><spanclass="n">taskflow</span><spanclass="p">;</span>
<spanclass="n">cond</span><spanclass="p">.</span><spanclass="n">succeed</span><spanclass="p">(</span><spanclass="n">init</span><spanclass="p">);</span></pre><p>Please refer to <ahref="ConditionalTasking.html" class="m-doc">Conditional Tasking</a> for details.</p>
<p>The method returns a tuple of tasks each corresponding to the given callable target. You can use structured binding to get the return tasks one by one. The following example creates four static tasks and assign them to <code>A</code>, <code>B</code>, <code>C</code>, and <code>D</code> using structured binding.</p><preclass="m-code"><spanclass="k">auto</span><spanclass="p">[</span><spanclass="n">A</span><spanclass="p">,</span><spanclass="n">B</span><spanclass="p">,</span><spanclass="n">C</span><spanclass="p">,</span><spanclass="n">D</span><spanclass="p">]</span><spanclass="o">=</span><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace</span><spanclass="p">(</span>
<p>A placeholder task maps to a node in the taskflow graph, but it does not have any callable work assigned yet. A placeholder task is different from an empty task handle that does not point to any node in a graph.</p><preclass="m-code"><spanclass="c1">// create a placeholder task with no callable target assigned</span>
<p>This method is equivalent to calling tf::FlowBuilder::emplace_on(callable, d) where <code>d</code> is the caller's device context. The following example creates a cudaFlow of two kernel tasks, <code>task1</code> and <code>task2</code>, where <code>task1</code> runs before <code>task2</code>.</p><preclass="m-code"><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace</span><spanclass="p">([</span><spanclass="o">&</span><spanclass="p">](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">cudaFlow</span><spanclass="o">&</span><spanclass="n">cf</span><spanclass="p">){</span>
<spanclass="p">});</span></pre><p>Please refer to <ahref="GPUTaskingcudaFlow.html" class="m-doc">GPU Tasking (cudaFlow)</a> and <ahref="GPUTaskingcudaFlowCapturer.html" class="m-doc">GPU Tasking (cudaFlowCapturer)</a> for details.</p>
<p>The following example creates a cudaFlow of two kernel tasks, <code>task1</code> and <code>task2</code> on GPU <code>2</code>, where <code>task1</code> runs before <code>task2</code></p><preclass="m-code"><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace_on</span><spanclass="p">([</span><spanclass="o">&</span><spanclass="p">](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">cudaFlow</span><spanclass="o">&</span><spanclass="n">cf</span><spanclass="p">){</span>
<p>The following example creates a syclFlow of two kernel tasks, <code>task1</code> and <code>task2</code> on GPU <code>2</code>, where <code>task1</code> runs before <code>task2</code></p><preclass="m-code"><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace_on</span><spanclass="p">([</span><spanclass="o">&</span><spanclass="p">](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">syclFlow</span><spanclass="o">&</span><spanclass="n">cf</span><spanclass="p">){</span>
<spanclass="c1">// create two single-thread kernel tasks</span>
<p>The task spawns a subflow that applies the callable object to each object obtained by dereferencing every iterator in the range <code>[first, last)</code>. This method is equivalent to the parallel execution of the following loop:</p><preclass="m-code"><spanclass="k">for</span><spanclass="p">(</span><spanclass="k">auto</span><spanclass="n">itr</span><spanclass="o">=</span><spanclass="n">first</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">!=</span><spanclass="n">last</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">++</span><spanclass="p">)</span><spanclass="p">{</span>
<spanclass="p">}</span></pre><p>Arguments templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>. The callable needs to take a single argument of the dereferenced iterator type.</p><p>Please refer to <ahref="ParallelIterations.html" class="m-doc">Parallel Iterations</a> for details.</p>
<p>The task spawns a subflow that applies the callable object to each index in the range <code>[first, last)</code> with the step size.</p><p>This method is equivalent to the parallel execution of the following loop:</p><preclass="m-code"><spanclass="c1">// case 1: step size is positive</span>
<spanclass="p">}</span></pre><p>Arguments are templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>. The callable needs to take a single argument of the integral index type.</p><p>Please refer to <ahref="ParallelIterations.html" class="m-doc">Parallel Iterations</a> for details.</p>
<p>The task spawns a subflow to perform parallel reduction over <code>init</code> and the elements in the range <code>[first, last)</code>. The reduced result is store in <code>init</code>.</p><p>This method is equivalent to the parallel execution of the following loop:</p><preclass="m-code"><spanclass="k">for</span><spanclass="p">(</span><spanclass="k">auto</span><spanclass="n">itr</span><spanclass="o">=</span><spanclass="n">first</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">!=</span><spanclass="n">last</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">++</span><spanclass="p">)</span><spanclass="p">{</span>
<spanclass="p">}</span></pre><p>Arguments are templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>.</p><p>Please refer to <ahref="ParallelReduction.html" class="m-doc">Parallel Reduction</a> for details.</p>
<p>The task spawns a subflow to perform parallel reduction over <code>init</code> and the transformed elements in the range <code>[first, last)</code>. The reduced result is store in <code>init</code>.</p><p>This method is equivalent to the parallel execution of the following loop:</p><preclass="m-code"><spanclass="k">for</span><spanclass="p">(</span><spanclass="k">auto</span><spanclass="n">itr</span><spanclass="o">=</span><spanclass="n">first</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">!=</span><spanclass="n">last</span><spanclass="p">;</span><spanclass="n">itr</span><spanclass="o">++</span><spanclass="p">)</span><spanclass="p">{</span>
<spanclass="p">}</span></pre><p>Arguments are templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>.</p><p>Please refer to <ahref="ParallelReduction.html" class="m-doc">Parallel Reduction</a> for details.</p>
<p>constructs a dynamic task to perform STL-styled parallel sort</p>
<tableclass="m-table m-fullwidth m-flat">
<thead>
<tr><thcolspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<tdstyle="width: 1%">B</td>
<td>beginning iterator type (random-accessible)</td>
</tr>
<tr>
<td>E</td>
<td>ending iterator type (random-accessible)</td>
</tr>
<tr>
<td>C</td>
<td>comparator type</td>
</tr>
</tbody>
<thead>
<tr><thcolspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>iterator to the beginning (inclusive)</td>
</tr>
<tr>
<td>last</td>
<td>iterator to the end (exclusive)</td>
</tr>
<tr>
<td>cmp</td>
<td>comparison function object</td>
</tr>
</tbody>
</table>
<p>The task spawns a subflow to parallelly sort elements in the range <code>[first, last)</code>.</p><p>Arguments are templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>.</p><p>Please refer to <ahref="ParallelSort.html" class="m-doc">Parallel Sort</a> for details.</p>
<p>constructs a dynamic task to perform STL-styled parallel sort using the <code>std::less<T></code> comparator, where <code>T</code> is the element type</p>
<tableclass="m-table m-fullwidth m-flat">
<thead>
<tr><thcolspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<tdstyle="width: 1%">B</td>
<td>beginning iterator type (random-accessible)</td>
</tr>
<tr>
<td>E</td>
<td>ending iterator type (random-accessible)</td>
</tr>
</tbody>
<thead>
<tr><thcolspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>iterator to the beginning (inclusive)</td>
</tr>
<tr>
<td>last</td>
<td>iterator to the end (exclusive)</td>
</tr>
</tbody>
</table>
<p>The task spawns a subflow to parallelly sort elements in the range <code>[first, last)</code> using the <code>std::less<T></code> comparator, where <code>T</code> is the dereferenced iterator type.</p><p>Arguments are templated to enable stateful passing using <ahref="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html" class="m-doc-external">std::<wbr/>reference_wrapper</a>.</p><p>Please refer to <ahref="ParallelSort.html" class="m-doc">Parallel Sort</a> for details.</p>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<divclass="m-doc-search" id="search">
<ahref="#!" onclick="return hideSearch()"></a>
<divclass="m-container">
<divclass="m-row">
<divclass="m-col-m-8 m-push-m-2">
<divclass="m-doc-search-header m-text m-small">
<div><spanclass="m-label m-default">Tab</span> / <spanclass="m-label m-default">T</span> to search, <spanclass="m-label m-default">Esc</span> to close</div>