-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
417 lines (415 loc) · 50.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Taskflow Handbook</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="taskflow_logo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname"><a href="https://taskflow.github.io/">Taskflow</a>
 <span id="projectnumber">3.2.0-Master-Branch</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">Modern C++ Parallel <a class="el" href="classtf_1_1Task.html" title="class to create a task handle over a node in a taskflow graph">Task</a> Programming </div></div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ASimpleFirstProgram">Start Your First Taskflow Program</a></li>
<li class="level1"><a href="#QuickStartCreateASubflowGraph">Create a Subflow Graph</a></li>
<li class="level1"><a href="#QuickStartIntegrateControlFlowIntoATaskGraph">Integrate Control Flow into a Task Graph</a></li>
<li class="level1"><a href="#QuickStartOffloadTasksToGPU">Offload Tasks to a GPU</a></li>
<li class="level1"><a href="#QuickStartComposeTaskGraphs">Compose Task Graphs</a></li>
<li class="level1"><a href="#QuickStartLaunchAsyncTasks">Launch Asynchronous Tasks</a></li>
<li class="level1"><a href="#QuickStartRunATaskflowThroughAnExecution">Run a Taskflow through an Executor</a></li>
<li class="level1"><a href="#QuickStartLeverageStandardParallelAlgorithms">Leverage Standard Parallel Algorithms</a></li>
<li class="level1"><a href="#QuickStartVisualizeATaskflow">Visualize Taskflow Graphs</a></li>
<li class="level1"><a href="#SupportedCompilers">Supported Compilers</a></li>
<li class="level1"><a href="#QuickStartGetInvolved">Get Involved</a></li>
<li class="level1"><a href="#License">License</a></li>
</ul>
</div>
<div class="textblock"><p>Taskflow helps you quickly write parallel and heterogeneous task programs with <em>high performance</em> and simultaneous <em>high productivity</em>. It is faster, more expressive, fewer lines of code, and easier for drop-in integration than many of existing task programming libraries. The source code is available in <a href="https://github.com/taskflow/">project GitHub</a>.</p>
<h1><a class="anchor" id="ASimpleFirstProgram"></a>
Start Your First Taskflow Program</h1>
<p>The following program (<code>simple.cpp</code>) creates four tasks <code>A</code>, <code>B</code>, <code>C</code>, and <code>D</code>, where <code>A</code> runs before <code>B</code> and <code>C</code>, and <code>D</code> runs after <code>B</code> and <code>C</code>. When <code>A</code> finishes, <code>B</code> and <code>C</code> can run in parallel.</p>
<div class="dotgraph">
<img src="dot_simple.png" alt="dot_simple.png" border="0" usemap="#dot_simple.map"/>
</div>
<div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="taskflow_8hpp.html">taskflow/taskflow.hpp</a>></span> <span class="comment">// Taskflow is header-only</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(){</div>
<div class="line"> </div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Executor.html">tf::Executor</a> executor;</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Taskflow.html">tf::Taskflow</a> taskflow;</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">auto</span> [A, B, C, D] = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>( <span class="comment">// create four tasks</span></div>
<div class="line"> [] () { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"TaskA\n"</span>; },</div>
<div class="line"> [] () { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"TaskB\n"</span>; },</div>
<div class="line"> [] () { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"TaskC\n"</span>; },</div>
<div class="line"> [] () { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"TaskD\n"</span>; } </div>
<div class="line"> ); </div>
<div class="line"> </div>
<div class="line"> A.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(B, C); <span class="comment">// A runs before B and C</span></div>
<div class="line"> D.<a class="code hl_function" href="classtf_1_1Task.html#a331b1b726555072e7c7d10941257f664">succeed</a>(B, C); <span class="comment">// D runs after B and C</span></div>
<div class="line"> </div>
<div class="line"> executor.<a class="code hl_function" href="classtf_1_1Executor.html#a519777f5783981d534e9e53b99712069">run</a>(taskflow).wait(); </div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="aclasstf_1_1Executor_html"><div class="ttname"><a href="classtf_1_1Executor.html">tf::Executor</a></div><div class="ttdoc">class to create an executor for running a taskflow graph</div><div class="ttdef"><b>Definition</b> executor.hpp:50</div></div>
<div class="ttc" id="aclasstf_1_1Executor_html_a519777f5783981d534e9e53b99712069"><div class="ttname"><a href="classtf_1_1Executor.html#a519777f5783981d534e9e53b99712069">tf::Executor::run</a></div><div class="ttdeci">tf::Future< void > run(Taskflow &taskflow)</div><div class="ttdoc">runs a taskflow once</div><div class="ttdef"><b>Definition</b> executor.hpp:1573</div></div>
<div class="ttc" id="aclasstf_1_1FlowBuilder_html_a60d7a666cab71ecfa3010b2efb0d6b57"><div class="ttname"><a href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">tf::FlowBuilder::emplace</a></div><div class="ttdeci">Task emplace(C &&callable)</div><div class="ttdoc">creates a static task</div><div class="ttdef"><b>Definition</b> flow_builder.hpp:742</div></div>
<div class="ttc" id="aclasstf_1_1Task_html_a331b1b726555072e7c7d10941257f664"><div class="ttname"><a href="classtf_1_1Task.html#a331b1b726555072e7c7d10941257f664">tf::Task::succeed</a></div><div class="ttdeci">Task & succeed(Ts &&... tasks)</div><div class="ttdoc">adds precedence links from other tasks to this</div><div class="ttdef"><b>Definition</b> task.hpp:428</div></div>
<div class="ttc" id="aclasstf_1_1Task_html_a8c78c453295a553c1c016e4062da8588"><div class="ttname"><a href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">tf::Task::precede</a></div><div class="ttdeci">Task & precede(Ts &&... tasks)</div><div class="ttdoc">adds precedence links from this to other tasks</div><div class="ttdef"><b>Definition</b> task.hpp:420</div></div>
<div class="ttc" id="aclasstf_1_1Taskflow_html"><div class="ttname"><a href="classtf_1_1Taskflow.html">tf::Taskflow</a></div><div class="ttdoc">class to create a taskflow object</div><div class="ttdef"><b>Definition</b> core/taskflow.hpp:73</div></div>
<div class="ttc" id="ataskflow_8hpp_html"><div class="ttname"><a href="taskflow_8hpp.html">taskflow.hpp</a></div><div class="ttdoc">main taskflow include file</div></div>
</div><!-- fragment --><p>Taskflow is <em>header-only</em> and there is no wrangle with installation. To compile the program, clone the Taskflow project and tell the compiler to include the headers under <code>taskflow/</code>.</p>
<div class="fragment"><div class="line">~$ git clone https://github.com/taskflow/taskflow.git # clone it only once</div>
<div class="line">~$ g++ -std=c++17 simple.cpp -I taskflow/taskflow -O2 -pthread -o simple</div>
<div class="line">~$ ./simple</div>
<div class="line">TaskA</div>
<div class="line">TaskC </div>
<div class="line">TaskB </div>
<div class="line">TaskD</div>
</div><!-- fragment --><p>Taskflow comes with a built-in profiler, <a href="https://taskflow.github.io/tfprof/">Taskflow Profiler</a>, for you to profile and visualize taskflow programs in an easy-to-use web-based interface.</p>
<div class="image">
<img src="tfprof.png" alt=""/>
</div>
<div class="fragment"><div class="line"># run the program with the environment variable TF_ENABLE_PROFILER enabled</div>
<div class="line">~$ TF_ENABLE_PROFILER=simple.json ./simple</div>
<div class="line">~$ cat simple.json</div>
<div class="line">[</div>
<div class="line">{"executor":"0","data":[{"worker":0,"level":0,"data":[{"span":[172,186],"name":"0_0","type":"static"},{"span":[187,189],"name":"0_1","type":"static"}]},{"worker":2,"level":0,"data":[{"span":[93,164],"name":"2_0","type":"static"},{"span":[170,179],"name":"2_1","type":"static"}]}]}</div>
<div class="line">]</div>
<div class="line"># paste the profiling json data to https://taskflow.github.io/tfprof/</div>
</div><!-- fragment --><h1><a class="anchor" id="QuickStartCreateASubflowGraph"></a>
Create a Subflow Graph</h1>
<p>Taskflow supports <em>dynamic tasking</em> for you to create a subflow graph from the execution of a task to perform dynamic parallelism. The following program spawns a task dependency graph parented at task <code>B</code>.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> A = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"A"</span>); </div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> C = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"C"</span>); </div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> D = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"D"</span>); </div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> B = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] (<a class="code hl_class" href="classtf_1_1Subflow.html">tf::Subflow</a>& subflow) { <span class="comment">// subflow task B</span></div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> B1 = subflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"B1"</span>); </div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> B2 = subflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"B2"</span>); </div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> B3 = subflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"B3"</span>); </div>
<div class="line"> B3.<a class="code hl_function" href="classtf_1_1Task.html#a331b1b726555072e7c7d10941257f664">succeed</a>(B1, B2); <span class="comment">// B3 runs after B1 and B2</span></div>
<div class="line">}).name(<span class="stringliteral">"B"</span>);</div>
<div class="line"> </div>
<div class="line">A.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(B, C); <span class="comment">// A runs before B and C</span></div>
<div class="line">D.<a class="code hl_function" href="classtf_1_1Task.html#a331b1b726555072e7c7d10941257f664">succeed</a>(B, C); <span class="comment">// D runs after B and C</span></div>
<div class="ttc" id="aclasstf_1_1Subflow_html"><div class="ttname"><a href="classtf_1_1Subflow.html">tf::Subflow</a></div><div class="ttdoc">class to construct a subflow graph from the execution of a dynamic task</div><div class="ttdef"><b>Definition</b> flow_builder.hpp:889</div></div>
<div class="ttc" id="aclasstf_1_1Task_html"><div class="ttname"><a href="classtf_1_1Task.html">tf::Task</a></div><div class="ttdoc">class to create a task handle over a node in a taskflow graph</div><div class="ttdef"><b>Definition</b> task.hpp:187</div></div>
</div><!-- fragment --><div class="dotgraph">
<img src="dot_subflow-join.png" alt="dot_subflow-join.png" border="0" usemap="#dot_subflow-join.map"/>
</div>
<h1><a class="anchor" id="QuickStartIntegrateControlFlowIntoATaskGraph"></a>
Integrate Control Flow into a Task Graph</h1>
<p>Taskflow supports <em>conditional tasking</em> for you to make rapid control-flow decisions across dependent tasks to implement cycles and conditions in an <em>end-to-end</em> task graph.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> init = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"init"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> stop = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){}).name(<span class="stringliteral">"stop"</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// creates a condition task that returns a random binary</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> cond = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([](){ <span class="keywordflow">return</span> <a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a>() % 2; }).name(<span class="stringliteral">"cond"</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// creates a feedback loop {0: cond, 1: stop}</span></div>
<div class="line">init.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(cond);</div>
<div class="line">cond.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(cond, stop); <span class="comment">// moves on to 'cond' on returning 0, or 'stop' on 1</span></div>
<div class="ttc" id="arand_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a></div><div class="ttdeci">T rand(T... args)</div></div>
</div><!-- fragment --><div class="dotgraph">
<img src="dot_conditional-tasking-1.png" alt="dot_conditional-tasking-1.png" border="0" usemap="#dot_conditional-tasking-1.map"/>
</div>
<h1><a class="anchor" id="QuickStartOffloadTasksToGPU"></a>
Offload Tasks to a GPU</h1>
<p>Taskflow supports GPU tasking for you to accelerate a wide range of scientific computing applications by harnessing the power of CPU-GPU collaborative computing using CUDA.</p>
<div class="fragment"><div class="line">__global__ <span class="keywordtype">void</span> saxpy(<span class="keywordtype">int</span> n, <span class="keywordtype">float</span> a, <span class="keywordtype">float</span> *x, <span class="keywordtype">float</span> *y) {</div>
<div class="line"> <span class="keywordtype">int</span> i = blockIdx.x*blockDim.x + threadIdx.x;</div>
<div class="line"> <span class="keywordflow">if</span> (i < n) {</div>
<div class="line"> y[i] = a*x[i] + y[i];</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> cudaflow = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([&](<a class="code hl_class" href="classtf_1_1cudaFlow.html">tf::cudaFlow</a>& cf) {</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> h2d_x = cf.<a class="code hl_function" href="classtf_1_1cudaFlow.html#af03e04771b655f9e629eb4c22e19b19f">copy</a>(dx, hx.data(), N).<a class="code hl_function" href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">name</a>(<span class="stringliteral">"h2d_x"</span>);</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> h2d_y = cf.<a class="code hl_function" href="classtf_1_1cudaFlow.html#af03e04771b655f9e629eb4c22e19b19f">copy</a>(dy, hy.data(), N).<a class="code hl_function" href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">name</a>(<span class="stringliteral">"h2d_y"</span>);</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> d2h_x = cf.<a class="code hl_function" href="classtf_1_1cudaFlow.html#af03e04771b655f9e629eb4c22e19b19f">copy</a>(hx.data(), dx, N).<a class="code hl_function" href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">name</a>(<span class="stringliteral">"d2h_x"</span>);</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> d2h_y = cf.<a class="code hl_function" href="classtf_1_1cudaFlow.html#af03e04771b655f9e629eb4c22e19b19f">copy</a>(hy.data(), dy, N).<a class="code hl_function" href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">name</a>(<span class="stringliteral">"d2h_y"</span>);</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> saxpy = cf.<a class="code hl_function" href="classtf_1_1cudaFlow.html#aa6e734462c8b8d922f44e621f94b104c">kernel</a>((N+255)/256, 256, 0, saxpy, N, 2.0f, dx, dy)</div>
<div class="line"> .<a class="code hl_function" href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">name</a>(<span class="stringliteral">"saxpy"</span>); <span class="comment">// parameters to the saxpy kernel</span></div>
<div class="line"> saxpy.<a class="code hl_function" href="classtf_1_1cudaTask.html#a4a9ca1a34bac47e4c9b04eb4fb2f7775">succeed</a>(h2d_x, h2d_y)</div>
<div class="line"> .<a class="code hl_function" href="classtf_1_1cudaTask.html#abdd68287ec4dff4216af34d1db44d1b4">precede</a>(d2h_x, d2h_y);</div>
<div class="line">}).name(<span class="stringliteral">"cudaFlow"</span>);</div>
<div class="ttc" id="aclasstf_1_1cudaFlow_html"><div class="ttname"><a href="classtf_1_1cudaFlow.html">tf::cudaFlow</a></div><div class="ttdoc">class to create a cudaFlow task dependency graph</div><div class="ttdef"><b>Definition</b> cudaflow.hpp:56</div></div>
<div class="ttc" id="aclasstf_1_1cudaFlow_html_aa6e734462c8b8d922f44e621f94b104c"><div class="ttname"><a href="classtf_1_1cudaFlow.html#aa6e734462c8b8d922f44e621f94b104c">tf::cudaFlow::kernel</a></div><div class="ttdeci">cudaTask kernel(dim3 g, dim3 b, size_t s, F f, ArgsT &&... args)</div><div class="ttdoc">creates a kernel task</div><div class="ttdef"><b>Definition</b> cudaflow.hpp:1272</div></div>
<div class="ttc" id="aclasstf_1_1cudaFlow_html_af03e04771b655f9e629eb4c22e19b19f"><div class="ttname"><a href="classtf_1_1cudaFlow.html#af03e04771b655f9e629eb4c22e19b19f">tf::cudaFlow::copy</a></div><div class="ttdeci">cudaTask copy(T *tgt, const T *src, size_t num)</div><div class="ttdoc">creates a memcopy task that copies typed data</div><div class="ttdef"><b>Definition</b> cudaflow.hpp:1348</div></div>
<div class="ttc" id="aclasstf_1_1cudaTask_html"><div class="ttname"><a href="classtf_1_1cudaTask.html">tf::cudaTask</a></div><div class="ttdoc">class to create a task handle over an internal node of a cudaFlow graph</div><div class="ttdef"><b>Definition</b> cuda_task.hpp:65</div></div>
<div class="ttc" id="aclasstf_1_1cudaTask_html_a4a9ca1a34bac47e4c9b04eb4fb2f7775"><div class="ttname"><a href="classtf_1_1cudaTask.html#a4a9ca1a34bac47e4c9b04eb4fb2f7775">tf::cudaTask::succeed</a></div><div class="ttdeci">cudaTask & succeed(Ts &&... tasks)</div><div class="ttdoc">adds precedence links from other tasks to this</div><div class="ttdef"><b>Definition</b> cuda_task.hpp:189</div></div>
<div class="ttc" id="aclasstf_1_1cudaTask_html_ab81b4f71a44af8d61758524f0c274962"><div class="ttname"><a href="classtf_1_1cudaTask.html#ab81b4f71a44af8d61758524f0c274962">tf::cudaTask::name</a></div><div class="ttdeci">cudaTask & name(const std::string &name)</div><div class="ttdoc">assigns a name to the task</div><div class="ttdef"><b>Definition</b> cuda_task.hpp:200</div></div>
<div class="ttc" id="aclasstf_1_1cudaTask_html_abdd68287ec4dff4216af34d1db44d1b4"><div class="ttname"><a href="classtf_1_1cudaTask.html#abdd68287ec4dff4216af34d1db44d1b4">tf::cudaTask::precede</a></div><div class="ttdeci">cudaTask & precede(Ts &&... tasks)</div><div class="ttdoc">adds precedence links from this to other tasks</div><div class="ttdef"><b>Definition</b> cuda_task.hpp:182</div></div>
</div><!-- fragment --><div class="dotgraph">
<img src="dot_saxpy_1_cudaflow.png" alt="dot_saxpy_1_cudaflow.png" border="0" usemap="#dot_saxpy_1_cudaflow.map"/>
</div>
<h1><a class="anchor" id="QuickStartComposeTaskGraphs"></a>
Compose Task Graphs</h1>
<p>Taskflow is composable. You can create large parallel graphs through composition of modular and reusable blocks that are easier to optimize at an individual scope.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="classtf_1_1Taskflow.html">tf::Taskflow</a> f1, f2;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// create taskflow f1 of two tasks</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f1A = f1.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([]() { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Task f1A\n"</span>; }).name(<span class="stringliteral">"f1A"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f1B = f1.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([]() { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Task f1B\n"</span>; }).name(<span class="stringliteral">"f1B"</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// create taskflow f2 with one module task composed of f1</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f2A = f2.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([]() { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Task f2A\n"</span>; }).name(<span class="stringliteral">"f2A"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f2B = f2.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([]() { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Task f2B\n"</span>; }).name(<span class="stringliteral">"f2B"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f2C = f2.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([]() { <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Task f2C\n"</span>; }).name(<span class="stringliteral">"f2C"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> f1_module_task = f2.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#ac6f22228d4c2ea2e643c4b0d42c0e92a">composed_of</a>(f1).<a class="code hl_function" href="classtf_1_1Task.html#a08ada0425b490997b6ff7f310107e5e3">name</a>(<span class="stringliteral">"module"</span>);</div>
<div class="line"> </div>
<div class="line">f1_module_task.<a class="code hl_function" href="classtf_1_1Task.html#a331b1b726555072e7c7d10941257f664">succeed</a>(f2A, f2B)</div>
<div class="line"> .<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(f2C);</div>
<div class="ttc" id="aclasstf_1_1FlowBuilder_html_ac6f22228d4c2ea2e643c4b0d42c0e92a"><div class="ttname"><a href="classtf_1_1FlowBuilder.html#ac6f22228d4c2ea2e643c4b0d42c0e92a">tf::FlowBuilder::composed_of</a></div><div class="ttdeci">Task composed_of(T &object)</div><div class="ttdoc">creates a module task for the target object</div><div class="ttdef"><b>Definition</b> flow_builder.hpp:812</div></div>
<div class="ttc" id="aclasstf_1_1Task_html_a08ada0425b490997b6ff7f310107e5e3"><div class="ttname"><a href="classtf_1_1Task.html#a08ada0425b490997b6ff7f310107e5e3">tf::Task::name</a></div><div class="ttdeci">const std::string & name() const</div><div class="ttdoc">queries the name of the task</div><div class="ttdef"><b>Definition</b> task.hpp:499</div></div>
</div><!-- fragment --><div class="dotgraph">
<img src="dot_composition.png" alt="dot_composition.png" border="0" usemap="#dot_composition.map"/>
</div>
<h1><a class="anchor" id="QuickStartLaunchAsyncTasks"></a>
Launch Asynchronous Tasks</h1>
<p>Taskflow supports <em>asynchronous</em> tasking. You can launch tasks asynchronously to incorporate independent, dynamic parallelism in your taskflows.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="classtf_1_1Executor.html">tf::Executor</a> executor;</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Taskflow.html">tf::Taskflow</a> taskflow;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// create asynchronous tasks directly from an executor</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Future.html">tf::Future<std::optional<int></a>> future = executor.<a class="code hl_function" href="classtf_1_1Executor.html#a1e6866c8f1b6a2e932f06d0b4eb032c0">async</a>([](){ </div>
<div class="line"> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"async task returns 1\n"</span>;</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line">}); </div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#abf71e7ec0026ddfce79c912264369bc9">silent_async</a>([](){ <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"async task does not return\n"</span>; });</div>
<div class="line"> </div>
<div class="line"><span class="comment">// launch an asynchronous task from a running task</span></div>
<div class="line">taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([&](){</div>
<div class="line"> executor.<a class="code hl_function" href="classtf_1_1Executor.html#a1e6866c8f1b6a2e932f06d0b4eb032c0">async</a>([](){ <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"async task created within a task\n"</span>; });</div>
<div class="line">});</div>
<div class="line"> </div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#a519777f5783981d534e9e53b99712069">run</a>(taskflow).wait();</div>
<div class="ttc" id="aclasstf_1_1Executor_html_a1e6866c8f1b6a2e932f06d0b4eb032c0"><div class="ttname"><a href="classtf_1_1Executor.html#a1e6866c8f1b6a2e932f06d0b4eb032c0">tf::Executor::async</a></div><div class="ttdeci">auto async(F &&f, ArgsT &&... args)</div><div class="ttdoc">runs a given function asynchronously</div><div class="ttdef"><b>Definition</b> executor.hpp:784</div></div>
<div class="ttc" id="aclasstf_1_1Executor_html_abf71e7ec0026ddfce79c912264369bc9"><div class="ttname"><a href="classtf_1_1Executor.html#abf71e7ec0026ddfce79c912264369bc9">tf::Executor::silent_async</a></div><div class="ttdeci">void silent_async(F &&f, ArgsT &&... args)</div><div class="ttdoc">similar to tf::Executor::async but does not return a future object</div><div class="ttdef"><b>Definition</b> executor.hpp:815</div></div>
<div class="ttc" id="aclasstf_1_1Future_html"><div class="ttname"><a href="classtf_1_1Future.html">tf::Future</a></div><div class="ttdoc">class to access the result of an execution</div><div class="ttdef"><b>Definition</b> core/taskflow.hpp:571</div></div>
</div><!-- fragment --><h1><a class="anchor" id="QuickStartRunATaskflowThroughAnExecution"></a>
Run a Taskflow through an Executor</h1>
<p>The executor provides several <em>thread-safe</em> methods to run a taskflow. You can run a taskflow once, multiple times, or until a stopping criteria is met. These methods are non-blocking with a <code>tf::Future<void></code> return to let you query the execution status.</p>
<div class="fragment"><div class="line"><span class="comment">// runs the taskflow once</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Future.html">tf::Future<void></a> run_once = executor.<a class="code hl_function" href="classtf_1_1Executor.html#a519777f5783981d534e9e53b99712069">run</a>(taskflow); </div>
<div class="line"> </div>
<div class="line"><span class="comment">// wait on this run to finish</span></div>
<div class="line">run_once.get();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// run the taskflow four times</span></div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#a6d0617eebc9421f1ba1f82ce6dd02c00">run_n</a>(taskflow, 4);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// runs the taskflow five times</span></div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#a0f52e9dd64b65aba32ca0e13c1ed300a">run_until</a>(taskflow, [counter=5](){ <span class="keywordflow">return</span> --counter == 0; });</div>
<div class="line"> </div>
<div class="line"><span class="comment">// blocks the executor until all submitted taskflows complete</span></div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#ab9aa252f70e9a40020a1e5a89d485b85">wait_for_all</a>();</div>
<div class="ttc" id="aclasstf_1_1Executor_html_a0f52e9dd64b65aba32ca0e13c1ed300a"><div class="ttname"><a href="classtf_1_1Executor.html#a0f52e9dd64b65aba32ca0e13c1ed300a">tf::Executor::run_until</a></div><div class="ttdeci">tf::Future< void > run_until(Taskflow &taskflow, P &&pred)</div><div class="ttdoc">runs a taskflow multiple times until the predicate becomes true</div><div class="ttdef"><b>Definition</b> executor.hpp:1622</div></div>
<div class="ttc" id="aclasstf_1_1Executor_html_a6d0617eebc9421f1ba1f82ce6dd02c00"><div class="ttname"><a href="classtf_1_1Executor.html#a6d0617eebc9421f1ba1f82ce6dd02c00">tf::Executor::run_n</a></div><div class="ttdeci">tf::Future< void > run_n(Taskflow &taskflow, size_t N)</div><div class="ttdoc">runs a taskflow for N times</div><div class="ttdef"><b>Definition</b> executor.hpp:1595</div></div>
<div class="ttc" id="aclasstf_1_1Executor_html_ab9aa252f70e9a40020a1e5a89d485b85"><div class="ttname"><a href="classtf_1_1Executor.html#ab9aa252f70e9a40020a1e5a89d485b85">tf::Executor::wait_for_all</a></div><div class="ttdeci">void wait_for_all()</div><div class="ttdoc">wait for all tasks to complete</div><div class="ttdef"><b>Definition</b> executor.hpp:1709</div></div>
</div><!-- fragment --><h1><a class="anchor" id="QuickStartLeverageStandardParallelAlgorithms"></a>
Leverage Standard Parallel Algorithms</h1>
<p>Taskflow defines algorithms for you to quickly express common parallel patterns using standard C++ syntaxes, such as parallel iterations, parallel reductions, and parallel sort.</p>
<div class="fragment"><div class="line"><span class="comment">// standard parallel CPU algorithms</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> task1 = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#ab405d7b10040530d8b04c11767b4960d">for_each</a>( <span class="comment">// assign each element to 100 in parallel</span></div>
<div class="line"> first, last, [] (<span class="keyword">auto</span>& i) { i = 100; } </div>
<div class="line">);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> task2 = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#aa9494fe7b862fc832884ce318e8a37f5">reduce</a>( <span class="comment">// reduce a range of items in parallel</span></div>
<div class="line"> first, last, init, [] (<span class="keyword">auto</span> a, <span class="keyword">auto</span> b) { <span class="keywordflow">return</span> a + b; }</div>
<div class="line">);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> task3 = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a35e180eb63de6c9f28e43185e837a4fa">sort</a>( <span class="comment">// sort a range of items in parallel</span></div>
<div class="line"> first, last, [] (<span class="keyword">auto</span> a, <span class="keyword">auto</span> b) { <span class="keywordflow">return</span> a < b; }</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// standard parallel GPU algorithms</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> cuda1 = cudaflow.for_each( <span class="comment">// assign each element to 100 on GPU</span></div>
<div class="line"> dfirst, dlast, [] __device__ (<span class="keyword">auto</span> i) { i = 100; }</div>
<div class="line">);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> cuda2 = cudaflow.reduce( <span class="comment">// reduce a range of items on GPU</span></div>
<div class="line"> dfirst, dlast, init, [] __device__ (<span class="keyword">auto</span> a, <span class="keyword">auto</span> b) { <span class="keywordflow">return</span> a + b; }</div>
<div class="line">);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1cudaTask.html">tf::cudaTask</a> cuda3 = cudaflow.sort( <span class="comment">// sort a range of items on GPU</span></div>
<div class="line"> dfirst, dlast, [] __device__ (<span class="keyword">auto</span> a, <span class="keyword">auto</span> b) { <span class="keywordflow">return</span> a < b; }</div>
<div class="line">);</div>
<div class="ttc" id="aclasstf_1_1FlowBuilder_html_a35e180eb63de6c9f28e43185e837a4fa"><div class="ttname"><a href="classtf_1_1FlowBuilder.html#a35e180eb63de6c9f28e43185e837a4fa">tf::FlowBuilder::sort</a></div><div class="ttdeci">Task sort(B first, E last, C cmp)</div><div class="ttdoc">constructs a dynamic task to perform STL-styled parallel sort</div></div>
<div class="ttc" id="aclasstf_1_1FlowBuilder_html_aa9494fe7b862fc832884ce318e8a37f5"><div class="ttname"><a href="classtf_1_1FlowBuilder.html#aa9494fe7b862fc832884ce318e8a37f5">tf::FlowBuilder::reduce</a></div><div class="ttdeci">Task reduce(B first, E last, T &init, O bop)</div><div class="ttdoc">constructs a STL-styled parallel-reduce task</div></div>
<div class="ttc" id="aclasstf_1_1FlowBuilder_html_ab405d7b10040530d8b04c11767b4960d"><div class="ttname"><a href="classtf_1_1FlowBuilder.html#ab405d7b10040530d8b04c11767b4960d">tf::FlowBuilder::for_each</a></div><div class="ttdeci">Task for_each(B first, E last, C callable)</div><div class="ttdoc">constructs a STL-styled parallel-for task</div></div>
</div><!-- fragment --><p>Additionally, Taskflow provides composable graph building blocks for you to efficiently implement common parallel algorithms, such as parallel pipeline.</p>
<div class="fragment"><div class="line"><span class="comment">// create a pipeline to propagate five tokens through three serial stages</span></div>
<div class="line"><a class="code hl_class" href="classtf_1_1Pipeline.html">tf::Pipeline</a> pl(num_lines,</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Pipe.html">tf::Pipe</a>{<a class="code hl_enumvalue" href="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0">tf::PipeType::SERIAL</a>, [](<a class="code hl_class" href="classtf_1_1Pipeflow.html">tf::Pipeflow</a>& pf) {</div>
<div class="line"> <span class="keywordflow">if</span>(pf.token() == 5) {</div>
<div class="line"> pf.stop();</div>
<div class="line"> }</div>
<div class="line"> }},</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Pipe.html">tf::Pipe</a>{<a class="code hl_enumvalue" href="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0">tf::PipeType::SERIAL</a>, [](<a class="code hl_class" href="classtf_1_1Pipeflow.html">tf::Pipeflow</a>& pf) {</div>
<div class="line"> <a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/io/c/fprintf.html">printf</a>(<span class="stringliteral">"stage 2: input buffer[%zu] = %d\n"</span>, pf.line(), buffer[pf.line()]);</div>
<div class="line"> }},</div>
<div class="line"> <a class="code hl_class" href="classtf_1_1Pipe.html">tf::Pipe</a>{<a class="code hl_enumvalue" href="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0">tf::PipeType::SERIAL</a>, [](<a class="code hl_class" href="classtf_1_1Pipeflow.html">tf::Pipeflow</a>& pf) {</div>
<div class="line"> <a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/io/c/fprintf.html">printf</a>(<span class="stringliteral">"stage 3: input buffer[%zu] = %d\n"</span>, pf.line(), buffer[pf.line()]);</div>
<div class="line"> }}</div>
<div class="line">);</div>
<div class="line">taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#ac6f22228d4c2ea2e643c4b0d42c0e92a">composed_of</a>(pl)</div>
<div class="line">executor.<a class="code hl_function" href="classtf_1_1Executor.html#a519777f5783981d534e9e53b99712069">run</a>(taskflow).wait();</div>
<div class="ttc" id="aclasstf_1_1Pipe_html"><div class="ttname"><a href="classtf_1_1Pipe.html">tf::Pipe</a></div><div class="ttdoc">class to create a pipe object for a pipeline stage</div><div class="ttdef"><b>Definition</b> pipeline.hpp:136</div></div>
<div class="ttc" id="aclasstf_1_1Pipeflow_html"><div class="ttname"><a href="classtf_1_1Pipeflow.html">tf::Pipeflow</a></div><div class="ttdoc">class to create a pipeflow object used by the pipe callable</div><div class="ttdef"><b>Definition</b> pipeline.hpp:42</div></div>
<div class="ttc" id="aclasstf_1_1Pipeline_html"><div class="ttname"><a href="classtf_1_1Pipeline.html">tf::Pipeline</a></div><div class="ttdoc">class to create a pipeline scheduling framework</div><div class="ttdef"><b>Definition</b> pipeline.hpp:312</div></div>
<div class="ttc" id="afprintf_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/c/fprintf.html">std::printf</a></div><div class="ttdeci">T printf(T... args)</div></div>
<div class="ttc" id="anamespacetf_html_abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0"><div class="ttname"><a href="namespacetf.html#abb7a11e41fd457f69e7ff45d4c769564a7b804a28d6154ab8007287532037f1d0">tf::PipeType::SERIAL</a></div><div class="ttdeci">@ SERIAL</div><div class="ttdoc">serial type</div></div>
</div><!-- fragment --><h1><a class="anchor" id="QuickStartVisualizeATaskflow"></a>
Visualize Taskflow Graphs</h1>
<p>You can dump a taskflow graph to a DOT format and visualize it using a number of free GraphViz tools such as <a href="https://dreampuf.github.io/GraphvizOnline/">GraphViz Online</a>.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="classtf_1_1Taskflow.html">tf::Taskflow</a> taskflow;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> A = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] () {}).name(<span class="stringliteral">"A"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> B = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] () {}).name(<span class="stringliteral">"B"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> C = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] () {}).name(<span class="stringliteral">"C"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> D = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] () {}).name(<span class="stringliteral">"D"</span>);</div>
<div class="line"><a class="code hl_class" href="classtf_1_1Task.html">tf::Task</a> E = taskflow.<a class="code hl_function" href="classtf_1_1FlowBuilder.html#a60d7a666cab71ecfa3010b2efb0d6b57">emplace</a>([] () {}).name(<span class="stringliteral">"E"</span>);</div>
<div class="line">A.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(B, C, E);</div>
<div class="line">C.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(D);</div>
<div class="line">B.<a class="code hl_function" href="classtf_1_1Task.html#a8c78c453295a553c1c016e4062da8588">precede</a>(D, E);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// dump the graph to a DOT file through std::cout</span></div>
<div class="line">taskflow.<a class="code hl_function" href="classtf_1_1Taskflow.html#ac433018262e44b12c4cc9f0c4748d758">dump</a>(<a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a>); </div>
<div class="ttc" id="aclasstf_1_1Taskflow_html_ac433018262e44b12c4cc9f0c4748d758"><div class="ttname"><a href="classtf_1_1Taskflow.html#ac433018262e44b12c4cc9f0c4748d758">tf::Taskflow::dump</a></div><div class="ttdeci">void dump(std::ostream &ostream) const</div><div class="ttdoc">dumps the taskflow to a DOT format through a std::ostream target</div><div class="ttdef"><b>Definition</b> core/taskflow.hpp:363</div></div>
</div><!-- fragment --><div class="dotgraph">
<img src="dot_graphviz.png" alt="dot_graphviz.png" border="0" usemap="#dot_graphviz.map"/>
</div>
<h1><a class="anchor" id="SupportedCompilers"></a>
Supported Compilers</h1>
<p>To use Taskflow, you only need a compiler that supports C++17:</p>
<ul>
<li>GNU C++ Compiler at least v8.4 with -std=c++17 </li>
<li>Clang C++ Compiler at least v6.0 with -std=c++17 </li>
<li>Microsoft Visual Studio at least v19.27 with /std:c++17 </li>
<li>AppleClang Xode Version at least v12.0 with -std=c++17 </li>
<li>Nvidia CUDA Toolkit and Compiler (nvcc) at least v11.1 with -std=c++17 </li>
<li>Intel C++ Compiler at least v19.0.1 with -std=c++17 </li>
<li>Intel DPC++ Clang Compiler at least v13.0.0 with -std=c++17 and SYCL20</li>
</ul>
<p>Taskflow works on Linux, Windows, and Mac OS X.</p>
<h1><a class="anchor" id="QuickStartGetInvolved"></a>
Get Involved</h1>
<p>Visit our <a href="https://taskflow.github.io/">project website</a> and <a href="https://taskflow.github.io/showcase/index.html">showcase presentation</a> to learn more about Taskflow. To get involved:</p>
<ul>
<li>See release notes at <a class="el" href="Releases.html">Release Notes</a></li>
<li>Read the step-by-step tutorial at <a class="el" href="Cookbook.html">Cookbook</a></li>
<li>Submit an issue at <a href="https://github.com/taskflow/taskflow/issues">issue tracker</a></li>
<li>Learn more about our technical details at <a class="el" href="References.html">References</a></li>
<li>Watch our <a href="https://www.youtube.com/watch?v=MX15huP5DsM">2020 CppCon Taskflow Talk</a> and <a href="https://www.youtube.com/watch?v=u8Mc_WgGwVY">2020 MUC++ Taskflow Talk</a></li>
</ul>
<p>We are committed to support trustworthy developments for both academic and industrial research projects in parallel and heterogeneous computing. If you are using Taskflow, please cite the following paper we publised at 2022 IEEE TPDS:</p>
<ul>
<li>Tsung-Wei Huang, Dian-Lun Lin, Chun-Xun Lin, and Yibo Lin, "<a href="https://tsung-wei-huang.github.io/papers/tpds21-taskflow.pdf">Taskflow: A Lightweight Parallel and Heterogeneous Task Graph Computing System</a>," <em>IEEE Transactions on Parallel and Distributed Systems (TPDS)</em>, vol. 33, no. 6, pp. 1303-1320, June 2022</li>
</ul>
<p>More importantly, we appreciate all Taskflow <a class="el" href="contributors.html">Contributors</a> and the following organizations for sponsoring the Taskflow project!</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadCenter"></th><th class="markdownTableHeadCenter"></th><th class="markdownTableHeadCenter"></th><th class="markdownTableHeadCenter"></th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyCenter"><img src="images/utah-ece-logo.png" alt="" class="inline"/> </td><td class="markdownTableBodyCenter"><img src="images/nsf.png" alt="" class="inline"/> </td><td class="markdownTableBodyCenter"><img src="images/darpa.png" alt="" class="inline"/> </td><td class="markdownTableBodyCenter"><img src="images/NumFocus.png" alt="" class="inline"/> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyCenter"><img src="images/nvidia-logo.png" alt="" class="inline"/> </td><td class="markdownTableBodyCenter"></td><td class="markdownTableBodyCenter"></td><td class="markdownTableBodyCenter"></td></tr>
</table>
<h1><a class="anchor" id="License"></a>
License</h1>
<p>Taskflow is open-source under permissive MIT license. You are completely free to use, modify, and redistribute any work on top of Taskflow. The source code is available in <a href="https://github.com/taskflow/">project GitHub</a> and is actively maintained by <a href="https://tsung-wei-huang.github.io/">Dr. Tsung-Wei Huang</a> and his research group at the University of Utah. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
</ul>
</div>
</body>
</html>