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
Copy file name to clipboardExpand all lines: docs/Algorithms.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@
48
48
<h1>
49
49
Taskflow Algorithms
50
50
</h1>
51
-
<p>Taskflow defines a collection of algorithm functions especially designed to be used on ranges of elements.</p><ul><li><ahref="ParallelIterations.html" class="m-doc">Parallel Iterations</a></li><li><ahref="ParallelReduction.html" class="m-doc">Parallel Reduction</a></li><li><ahref="ParallelSort.html" class="m-doc">Parallel Sort</a></li></ul>
51
+
<p>Taskflow defines a collection of algorithm functions especially designed to be used on ranges of elements.</p><ul><li><ahref="ParallelIterations.html" class="m-doc">Parallel Iterations</a></li><li><ahref="ParallelTransforms.html" class="m-doc">Parallel Transforms</a></li><li><ahref="ParallelReduction.html" class="m-doc">Parallel Reduction</a></li><li><ahref="ParallelSort.html" class="m-doc">Parallel Sort</a></li></ul>
Copy file name to clipboardExpand all lines: docs/ComposableTasking.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -179,7 +179,7 @@ <h3>Contents</h3>
179
179
</g>
180
180
</g>
181
181
</svg>
182
-
</div><p>Debrief:</p><ul><li>Lines 1-12 create a taskflow of three tasks f1A, f1B, and f1C with f1A and f1B preceding f1C</li><li>Lines 17-30 create a taskflow of four tasks f2A, f2B, f2C, and f2D</li><li>Line 32 creates a module task from taskflow f1 through the method <ahref="classtf_1_1FlowBuilder.html#a0a01192f4f92c15380a4f259e2fec2d9" class="m-doc">Taskflow::<wbr/>composed_of</a></li><li>Line 33 enforces task f2C to run before the module task</li><li>Line 34 enforces the module task to run before task f2D</li></ul></section><sectionid="CreateAModuleTask"><h2><ahref="#CreateAModuleTask">Create a Module Task</a></h2><p>The task created from <ahref="classtf_1_1FlowBuilder.html#a0a01192f4f92c15380a4f259e2fec2d9" class="m-doc">Taskflow::<wbr/>composed_of</a> is a <em>module</em> task that runs on a pre-defined taskflow. A module task does not own the taskflow but maintains a soft mapping to the taskflow. You can create multiple module tasks from the same taskflow but only one module task can run at one time. For example, the following composition is valid. Even though the two module tasks <code>module1</code> and <code>module2</code> refer to the same taskflow <code>F1</code>, the dependency link prevents <code>F1</code> from multiple executions at the same time.</p><divclass="m-graph"><svgstyle="width: 24.312rem; height: 24.500rem;" viewBox="0.00 0.00 389.00 392.31">
182
+
</div><p>Debrief:</p><ul><li>Lines 1-12 create a taskflow of three tasks f1A, f1B, and f1C with f1A and f1B preceding f1C</li><li>Lines 17-30 create a taskflow of four tasks f2A, f2B, f2C, and f2D</li><li>Line 32 creates a module task from taskflow f1 through the method <ahref="classtf_1_1FlowBuilder.html#ac6f22228d4c2ea2e643c4b0d42c0e92a" class="m-doc">Taskflow::<wbr/>composed_of</a></li><li>Line 33 enforces task f2C to run before the module task</li><li>Line 34 enforces the module task to run before task f2D</li></ul></section><sectionid="CreateAModuleTask"><h2><ahref="#CreateAModuleTask">Create a Module Task</a></h2><p>The task created from <ahref="classtf_1_1FlowBuilder.html#ac6f22228d4c2ea2e643c4b0d42c0e92a" class="m-doc">Taskflow::<wbr/>composed_of</a> is a <em>module</em> task that runs on a pre-defined taskflow. A module task does not own the taskflow but maintains a soft mapping to the taskflow. You can create multiple module tasks from the same taskflow but only one module task can run at one time. For example, the following composition is valid. Even though the two module tasks <code>module1</code> and <code>module2</code> refer to the same taskflow <code>F1</code>, the dependency link prevents <code>F1</code> from multiple executions at the same time.</p><divclass="m-graph"><svgstyle="width: 24.312rem; height: 24.500rem;" viewBox="0.00 0.00 389.00 392.31">
<li><ahref="#A1IndexBasedParallelFor">Create an Index-based Parallel-Iteration Task</a></li>
56
+
<li><ahref="#A1IteratorBasedParallelFor">Create an Iterator-based Parallel-Iteration Task</a></li>
57
57
</ul>
58
58
</div>
59
-
<p>Taskflow provides template function that constructs a task to perform parallel iterations over a range of items.</p><sectionid="A1IndexBasedParallelFor"><h2><ahref="#A1IndexBasedParallelFor">Index-based Parallel Iterations</a></h2><p>Index-based parallel-for performs parallel iterations over a range <code>[first, last)</code> with the given <code>step</code> size. The task created by <ahref="classtf_1_1FlowBuilder.html#ac17879c60511d573e35f73ef3f620d8d" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each_index(B&& first, E&& last, S&& step, C callable)</a> represents parallel execution of the following loop:</p><preclass="m-code"><spanclass="c1">// positive step</span>
59
+
<p>Taskflow provides template functions for constructing tasks to perform parallel iterations over ranges of items.</p><sectionid="A1IndexBasedParallelFor"><h2><ahref="#A1IndexBasedParallelFor">Create an Index-based Parallel-Iteration Task</a></h2><p>Index-based parallel-for performs parallel iterations over a range <code>[first, last)</code> with the given <code>step</code> size. The task created by <ahref="classtf_1_1FlowBuilder.html#a38ffe176bc3ae1827b9964322e3769d4" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each_index(B first, E last, S step, C callable)</a> represents parallel execution of the following loop:</p><preclass="m-code"><spanclass="c1">// positive step</span>
</div><p>The index types, <code>B</code>, <code>E</code>, and <code>S</code>, are templates to preserve the variable types and their underlying types must be of the same <em>integral</em> type (e.g., <code>int</code>, <code>size_t</code>, <code>unsigned</code>). By default, <ahref="classtf_1_1FlowBuilder.html#ac17879c60511d573e35f73ef3f620d8d" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each_index</a> creates a task that spawns a subflow (see <ahref="DynamicTasking.html" class="m-doc">Dynamic Tasking</a>) to run iterations in parallel. The subflow closure captures all input arguments through perfect forwarding to form a stateful closure such that any changes on the arguments will be visible to the execution context of the subflow. For example:</p><preclass="m-code"><spanclass="kt">int</span><spanclass="o">*</span><spanclass="n">vec</span><spanclass="p">;</span>
198
+
</div><p>The index types, <code>B</code>, <code>E</code>, and <code>S</code>, are templates to preserve the variable types and their underlying types must be of the same <em>integral</em> type (e.g., <code>int</code>, <code>size_t</code>, <code>unsigned</code>). By default, <ahref="classtf_1_1FlowBuilder.html#a38ffe176bc3ae1827b9964322e3769d4" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each_index</a> creates a task that spawns a subflow (see <ahref="DynamicTasking.html" class="m-doc">Dynamic Tasking</a>) to run iterations in parallel. The subflow closure captures all input arguments through perfect forwarding to form a stateful closure such that any changes on the arguments will be visible to the execution context of the subflow. For example:</p><preclass="m-code"><spanclass="kt">int</span><spanclass="o">*</span><spanclass="n">vec</span><spanclass="p">;</span>
<spanclass="c1">// std::cout << "parallel iteration on index " << vec[i] << '\n';</span>
216
216
<spanclass="c1">// });</span>
217
217
218
-
<spanclass="n">init</span><spanclass="p">.</span><spanclass="n">precede</span><spanclass="p">(</span><spanclass="n">pf</span><spanclass="p">);</span></pre><p>When <code>init</code> finishes, the parallel-for task <code>pf</code> will see <code>first</code> as 0 and <code>last</code> as 1000 and performs parallel iterations over the 1000 items. This property is especially important for task graph parallelism, because users can define end-to-end parallelism through stateful closures that marshal parameter exchange between dependent tasks.</p></section><sectionid="A1IteratorBasedParallelFor"><h2><ahref="#A1IteratorBasedParallelFor">Iterator-based Parallel Iterations</a></h2><p>Iterator-based parallel-for performs parallel iterations over a range specified by two <ahref="https://en.cppreference.com/w/cpp/iterator/iterator">STL-styled iterators</a>, <code>first</code> and <code>last</code>. The task created by <ahref="classtf_1_1FlowBuilder.html#abc7f5fa54f40901d10f5f26062be3f40" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each(B&& first, E&& last, C callable)</a> represents a parallel execution of the following loop:</p><preclass="m-code"><spanclass="k">for</span><spanclass="p">(</span><spanclass="k">auto</span><spanclass="n">i</span><spanclass="o">=</span><spanclass="n">first</span><spanclass="p">;</span><spanclass="n">i</span><spanclass="o"><</span><spanclass="n">last</span><spanclass="p">;</span><spanclass="n">i</span><spanclass="o">++</span><spanclass="p">)</span><spanclass="p">{</span>
218
+
<spanclass="n">init</span><spanclass="p">.</span><spanclass="n">precede</span><spanclass="p">(</span><spanclass="n">pf</span><spanclass="p">);</span></pre><p>When <code>init</code> finishes, the parallel-for task <code>pf</code> will see <code>first</code> as 0 and <code>last</code> as 1000 and performs parallel iterations over the 1000 items. This property is especially important for task graph parallelism, because users can define end-to-end parallelism through stateful closures that marshal parameter exchange between dependent tasks.</p></section><sectionid="A1IteratorBasedParallelFor"><h2><ahref="#A1IteratorBasedParallelFor">Create an Iterator-based Parallel-Iteration Task</a></h2><p>Iterator-based parallel-for performs parallel iterations over a range specified by two <ahref="https://en.cppreference.com/w/cpp/iterator/iterator">STL-styled iterators</a>, <code>first</code> and <code>last</code>. The task created by <ahref="classtf_1_1FlowBuilder.html#ab405d7b10040530d8b04c11767b4960d" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each(B first, E last, C callable)</a> represents a parallel execution of the following loop:</p><preclass="m-code"><spanclass="k">for</span><spanclass="p">(</span><spanclass="k">auto</span><spanclass="n">i</span><spanclass="o">=</span><spanclass="n">first</span><spanclass="p">;</span><spanclass="n">i</span><spanclass="o"><</span><spanclass="n">last</span><spanclass="p">;</span><spanclass="n">i</span><spanclass="o">++</span><spanclass="p">)</span><spanclass="p">{</span>
<spanclass="p">}</span></pre><p>By default, tf::Taskflow::for_each(B&& first, E&& last, C&& callable) creates a task that spawns a subflow (see <ahref="DynamicTasking.html" class="m-doc">Dynamic Tasking</a>) that applies the callable to the object obtained by dereferencing every iterator in the range <code>[first, last)</code>. It is user's responsibility for ensuring the range is valid within the execution of the parallel-for task. Iterators must have the post-increment operator ++ defined. This version of parallel-for applies to all iterable STL containers.</p><preclass="m-code"><spanclass="n">std</span><spanclass="o">::</span><spanclass="n">vector</span><spanclass="o"><</span><spanclass="kt">int</span><spanclass="o">></span><spanclass="n">vec</span><spanclass="o">=</span><spanclass="p">{</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="mi">3</span><spanclass="p">,</span><spanclass="mi">4</span><spanclass="p">,</span><spanclass="mi">5</span><spanclass="p">};</span>
220
+
<spanclass="p">}</span></pre><p>By default, <ahref="classtf_1_1FlowBuilder.html#ab405d7b10040530d8b04c11767b4960d" class="m-doc">tf::<wbr/>Taskflow::<wbr/>for_each(B first, E last, C callable)</a> creates a task that spawns a subflow (see <ahref="DynamicTasking.html" class="m-doc">Dynamic Tasking</a>) that applies the callable to the object obtained by dereferencing every iterator in the range <code>[first, last)</code>. It is user's responsibility for ensuring the range is valid within the execution of the parallel-for task. Iterators must have the post-increment operator ++ defined. This version of parallel-for applies to all iterable STL containers.</p><preclass="m-code"><spanclass="n">std</span><spanclass="o">::</span><spanclass="n">vector</span><spanclass="o"><</span><spanclass="kt">int</span><spanclass="o">></span><spanclass="n">vec</span><spanclass="o">=</span><spanclass="p">{</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="mi">3</span><spanclass="p">,</span><spanclass="mi">4</span><spanclass="p">,</span><spanclass="mi">5</span><spanclass="p">};</span>
<spanclass="n">std</span><spanclass="o">::</span><spanclass="n">cout</span><spanclass="o"><<</span><spanclass="s">"parallel for on item "</span><spanclass="o"><<</span><spanclass="n">i</span><spanclass="o"><<</span><spanclass="sc">'\n'</span><spanclass="p">;</span>
0 commit comments