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/PrioritizedTasking.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ <h3>Contents</h3>
55
55
<li><ahref="#AssignAPriorityToATask">Assign a Priority to a Task</a></li>
56
56
</ul>
57
57
</nav>
58
-
<p>This chapter demonstrates how to assigns a task a priority to <em>hint</em> the scheduler about one task of a higher priority should start earlier than another task of a lower priority. Task priorities are useful in many cases. For instance, we may prioritize some tasks over others to improve responsiveness or data locality of parallel tasks.</p><sectionid="AssignAPriorityToATask"><h2><ahref="#AssignAPriorityToATask">Assign a Priority to a Task</a></h2><p>Taskflow supports three different priority levels, <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fab89de3b4b81c4facfac906edf29aec8c" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>HIGH</a>, <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fa1e23852820b9154316c7c06e2b7ba051" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>NORMAL</a>, and <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fa41bc94cbd8eebea13ce0491b2ac11b88" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>LOW</a>, as defined in <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346f" class="m-doc">tf::<wbr/>TaskPriority</a>. When there are parallel tasks (i.e., no dependencies), Taskflow will <code>try</code> to execute tasks of higher priorities before tasks of lower priorities. By default, all tasks have the highest priorities (<code><ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fab89de3b4b81c4facfac906edf29aec8c" class="m-doc">TaskPriority::<wbr/>HIGH</a></code>) unless otherwise assigned.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Executor</span><spanclass="w"></span><spanclass="nf">executor</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">);</span><spanclass="w"></span>
58
+
<p>This chapter demonstrates how to assigns a task a priority to <em>hint</em> the scheduler about one task of a higher priority should start earlier than another task of a lower priority. Task priorities are useful in many cases. For instance, we may prioritize some tasks over others to improve responsiveness or data locality of parallel tasks.</p><sectionid="AssignAPriorityToATask"><h2><ahref="#AssignAPriorityToATask">Assign a Priority to a Task</a></h2><p>Taskflow supports three different priority levels, <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fab89de3b4b81c4facfac906edf29aec8c" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>HIGH</a>, <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fa1e23852820b9154316c7c06e2b7ba051" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>NORMAL</a>, and <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fa41bc94cbd8eebea13ce0491b2ac11b88" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>LOW</a>, as defined in <ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346f" class="m-doc">tf::<wbr/>TaskPriority</a>. When there are parallel tasks (i.e., no dependencies), Taskflow will <code>try</code> to execute tasks of higher priorities before tasks of lower priorities. By default, all tasks have the highest priorities (<code><ahref="namespacetf.html#ac9f4add8f716ed323b0bdbbc1d89346fab89de3b4b81c4facfac906edf29aec8c" class="m-doc">tf::<wbr/>TaskPriority::<wbr/>HIGH</a></code>) unless otherwise assigned.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Executor</span><spanclass="w"></span><spanclass="nf">executor</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">);</span><spanclass="w"></span>
<li>class <ahref="classtf_1_1TaskView.html" class="m-doc">TaskView</a><spanclass="m-doc">class to access task information from the observer interface</span></li>
97
-
<li>class <ahref="classtf_1_1TFProfObserver.html" class="m-doc">TFProfObserver</a><spanclass="m-doc">class to create an observer based on the built-in taskflow profiler format</span></li>
97
+
<liclass="m-doc-collapsible collapsed">
98
+
<ahref="#" onclick="return toggle(this)">class</a><ahref="classtf_1_1TFProfObserver.html" class="m-doc">TFProfObserver</a><spanclass="m-doc">class to create an observer based on the built-in taskflow profiler format</span>
<li>class <ahref="classtf_1_1WorkerInterface.html" class="m-doc">WorkerInterface</a><spanclass="m-doc">class to configure worker behavior in an executor</span></li>
100
106
<li>class <ahref="classtf_1_1WorkerView.html" class="m-doc">WorkerView</a><spanclass="m-doc">class to create an immutable view of a worker in an executor</span></li>
<spanclass="c1">// dump the thread activities to Taskflow Profiler format.</span>
78
-
<spanclass="n">observer</span><spanclass="o">-></span><spanclass="n">dump</span><spanclass="p">(</span><spanclass="n">std</span><spanclass="o">::</span><spanclass="n">cout</span><spanclass="p">);</span><spanclass="w"></span></pre><p>We recommend using our <ahref="https://taskflow.github.io/tfprof/">Taskflow Profiler</a> python script to observe thread activities instead of the raw function call. The script will turn on environment variables needed for observing all executors in a taskflow program and dump the result to a valid, clean JSON file compatible with the format of <ahref="https://taskflow.github.io/tfprof/">Taskflow Profiler</a>.</p>
<p>class to configure worker behavior in an executor</p>
52
52
<navclass="m-block m-default">
53
53
<h3>Contents</h3>
54
54
<ul>
@@ -61,7 +61,7 @@ <h3>Contents</h3>
61
61
</li>
62
62
</ul>
63
63
</nav>
64
-
<p>The <ahref="classtf_1_1WorkerInterface.html" class="m-doc">tf::<wbr/>WorkerInterface</a> class lets users to interact with the executor to customize the thread behavior, such as calling custom methods before and after a worker enters and leaves the loop.</p><p>When you create an executor, it spawns a set of workers to run tasks. The interaction between the executor and its spawned workers looks like the following:</p><p>for(size_t n=0; n<num_workers; n++) { create_thread([](<ahref="classtf_1_1Worker.html" class="m-doc">Worker</a>& worker)</p><p>pre-processing executor-specific worker information ...</p><p>enter the scheduling loop Here, <ahref="classtf_1_1WorkerInterface.html#a41c3b931a36bde8eff4aa8d375e8888a" class="m-doc">WorkerInterface::<wbr/>scheduler_prologue</a> is invoked, if any</p><pre>while(1) {
64
+
<p>The <ahref="classtf_1_1WorkerInterface.html" class="m-doc">tf::<wbr/>WorkerInterface</a> class lets users interact with the executor to customize the worker behavior, such as calling custom methods before and after a worker enters and leaves the loop.When you create an executor, it spawns a set of workers to run tasks. The interaction between the executor and its spawned workers looks like the following:</p><p>for(size_t n=0; n<num_workers; n++) { create_thread([](<ahref="classtf_1_1Worker.html" class="m-doc">Worker</a>& worker)</p><p>pre-processing executor-specific worker information ...</p><p>enter the scheduling loop Here, <ahref="classtf_1_1WorkerInterface.html#a41c3b931a36bde8eff4aa8d375e8888a" class="m-doc">WorkerInterface::<wbr/>scheduler_prologue</a> is invoked, if any</p><pre>while(1) {
65
65
perform_work_stealing_algorithm();
66
66
if(stop) {
67
67
break;
@@ -109,6 +109,7 @@ <h3>
109
109
</tr>
110
110
</tbody>
111
111
</table>
112
+
<p>The method is called by the constructor of an executor.</p>
0 commit comments