Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f781d7a

Browse files
updated doc
1 parent df2a7a4 commit f781d7a

File tree

9 files changed

+16
-176
lines changed

9 files changed

+16
-176
lines changed

README.md

Lines changed: 2 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![TFProf](image/tfprof.svg)](https://taskflow.github.io/tfprof/)
88
[![Cite](image/cite-ipdps.svg)][IPDPS19]
99

10-
Taskflow helps you quickly write parallel tasks programs in modern C++
10+
Taskflow helps you quickly write parallel and heterogeneous tasks programs in modern C++
1111

1212
# Why Taskflow?
1313

@@ -84,9 +84,7 @@ Technical details can be referred to our [IPDPS paper][IPDPS19].
8484
* [Step 1: Create a cudaFlow](#step-1-create-a-cudaflow)
8585
* [Step 2: Compile and Execute a cudaFlow](#step-2-compile-and-execute-a-cudaflow)
8686
* [Visualize a Taskflow Graph](#visualize-a-taskflow-graph)
87-
* [API Reference](#api-reference)
8887
* [System Requirements](#system-requirements)
89-
* [Compile Unit Tests, Examples, and Benchmarks](#compile-unit-tests-examples-and-benchmarks)
9088
* [Who is Using Taskflow?](#who-is-using-taskflow)
9189

9290

@@ -451,130 +449,6 @@ tf.dump(std::cout); // dump the graph including dynamic tasks
451449

452450
<div align="right"><b><a href="#table-of-contents">[↑]</a></b></div>
453451

454-
455-
456-
457-
# API Reference
458-
459-
The official [documentation][wiki] explains a complete list of
460-
Taskflow API.
461-
Here, we highlight commonly used methods.
462-
463-
## Taskflow API
464-
465-
The class `tf::Taskflow` is the main place to create a task dependency graph.
466-
467-
### *emplace/placeholder*
468-
469-
You can use `emplace` to create a task from a target callable.
470-
471-
```cpp
472-
tf::Task task = taskflow.emplace([] () { std::cout << "my task\n"; });
473-
```
474-
475-
When a task cannot be determined beforehand, you can create a placeholder and assign the callable later.
476-
477-
```cpp
478-
tf::Task A = taskflow.emplace([](){});
479-
tf::Task B = taskflow.placeholder();
480-
A.precede(B);
481-
B.work([](){ /* do something */ });
482-
```
483-
484-
### *for_each/for_each_index*
485-
486-
The method `for_each` creates a subflow to perform parallel iterations over a range of elements
487-
specified by `[beg, end)`.
488-
489-
```cpp
490-
auto v = {'A', 'B', 'C', 'D'};
491-
auto t = taskflow.for_each(v.begin(), v.end(),
492-
[] (char i) {
493-
std::cout << "parallel iteration on character " << i << '\n';
494-
}
495-
);
496-
```
497-
498-
You can also specify an *index-based* range with the given step size.
499-
500-
```cpp
501-
// [0, 11) with a step size of 2, i.e., 0, 2, 4, 6, 8, 10
502-
auto t = taskflow.for_each_index(0, 11, 2,
503-
[] (int i) {
504-
std::cout << "parallel iteration on index " << i << std::endl;
505-
}
506-
);
507-
```
508-
509-
## Task API
510-
511-
Each time you create a task, the taskflow object adds a node to the present task dependency graph
512-
and return a *task handle* to you.
513-
You can access or modify the attributes of the associated task node.
514-
515-
### *name*
516-
517-
The method `name` lets you assign a human-readable string to a task.
518-
519-
```cpp
520-
A.name("my name is A");
521-
```
522-
523-
### *work*
524-
525-
The method `work` lets you assign a callable to a task.
526-
527-
```cpp
528-
A.work([] () { std::cout << "hello world!"; });
529-
```
530-
531-
### *precede/succeed*
532-
533-
The method `precede/succeed` lets you add a preceding/succeeding link between tasks.
534-
535-
<img align="right" width="30%" src="image/broadcast.svg">
536-
537-
```cpp
538-
// A runs before B, C, D, and E
539-
A.precede(B, C, D, E);
540-
```
541-
542-
The method `succeed` is similar to `precede` but operates in the opposite direction.
543-
544-
### *empty/has_work*
545-
546-
A task is empty if it is not associated with any graph node.
547-
548-
```cpp
549-
tf::Task task; // assert(task.empty());
550-
```
551-
552-
A placeholder task is associated with a graph node but has no work assigned yet.
553-
554-
```
555-
tf::Task task = taskflow.placeholder(); // assert(!task.has_work());
556-
```
557-
558-
## Executor API
559-
560-
The class `tf::Executor` is used for executing one or multiple taskflow objects.
561-
562-
### *run/run_n/run_until*
563-
564-
The run series are *thread-safe* and *non-blocking* calls to execute a taskflow.
565-
Issuing multiple runs on the same taskflow will automatically synchronize
566-
to a sequential chain of executions.
567-
568-
```cpp
569-
executor.run(taskflow); // runs a graph once
570-
executor.run_n(taskflow, 5); // runs a graph five times
571-
executor.run_until(taskflow, my_pred); // keeps running until the my_pred becomes true
572-
executor.wait_for_all(); // blocks until all tasks finish
573-
```
574-
575-
The first run finishes before the second run, and the second run finishes before the third run.
576-
<div align="right"><b><a href="#table-of-contents">[↑]</a></b></div>
577-
578452
# System Requirements
579453

580454
To use the latest [Taskflow](https://github.com/taskflow/taskflow/archive/master.zip), you only need a [C++17][C++17] compiler.
@@ -584,49 +458,12 @@ To use the latest [Taskflow](https://github.com/taskflow/taskflow/archive/master
584458
+ Microsoft Visual Studio at least v15.7 (MSVC++ 19.14); see [vcpkg guide](https://github.com/taskflow/taskflow/issues/143)
585459
+ AppleClang Xode Version at least v8
586460
+ Intel C++ Compiler at least v19.0.1
587-
+ Nvidia CUDA Toolkit and Compiler ([nvcc][nvcc]) at least v11.0 with -std=c++17
461+
+ Nvidia CUDA Toolkit and Compiler ([nvcc][nvcc]) at least v11.1 with -std=c++17
588462

589463
Taskflow works on Linux, Windows, and Mac OS X. See the [C++ compiler support](https://en.cppreference.com/w/cpp/compiler_support) status.
590464

591465
<div align="right"><b><a href="#table-of-contents">[↑]</a></b></div>
592466

593-
# Compile Unit Tests, Examples, and Benchmarks
594-
595-
Taskflow uses [CMake](https://cmake.org/) to build examples and unit tests.
596-
We recommend using out-of-source build.
597-
598-
```bash
599-
~$ cmake --version # must be at least 3.9 or higher
600-
~$ mkdir build
601-
~$ cd build
602-
~$ cmake ../
603-
~$ make & make test # run all unit tests
604-
```
605-
606-
## Examples
607-
608-
The folder `examples/` contains several examples and is a great place to learn to use Taskflow.
609-
610-
| Example | Description |
611-
| ------- | ----------- |
612-
| [simple.cpp](./examples/simple.cpp) | uses basic task building blocks to create a trivial taskflow graph |
613-
| [visualization.cpp](./examples/visualization.cpp)| inspects a taskflow through the dump method |
614-
| [parallel_for.cpp](./examples/parallel_for.cpp)| parallelizes a for loop with unbalanced workload |
615-
| [subflow.cpp](./examples/subflow.cpp)| demonstrates how to create a subflow graph that spawns three dynamic tasks |
616-
| [run_variants.cpp](./examples/run_variants.cpp)| shows multiple ways to run a taskflow graph |
617-
| [composition.cpp](./examples/composition.cpp)| demonstrates the decomposable interface of taskflow |
618-
| [observer.cpp](./examples/observer.cpp)| demonstrates how to monitor the thread activities in scheduling and running tasks |
619-
| [condition.cpp](./examples/condition.cpp) | creates a conditional tasking graph with a feedback loop control flow |
620-
| [cuda/saxpy.cu](./examples/cuda/saxpy.cu) | uses cudaFlow to create a saxpy (single-precision A·X Plus Y) task graph |
621-
| [cuda/matmul.cu](./examples/cuda/matmul.cu) | uses cudaFlow to create a matrix multiplication workload and compares it with a CPU basline |
622-
623-
## Benchmarks
624-
625-
Please visit [benchmarks](benchmarks/benchmarks.md) to learn to
626-
compile the benchmarks.
627-
628-
<div align="right"><b><a href="#table-of-contents">[↑]</a></b></div>
629-
630467
# Who is Using Taskflow?
631468

632469
Taskflow is being used in both industry and academic projects to scale up existing workloads

docs/References.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h3>Contents</h3>
5656
<li><a href="#RefRecognition">Recognition</a></li>
5757
</ul>
5858
</div>
59-
<p>This page summarizes a list of publication related to Taskflow. Please cite the article(s) accordingly.</p><section id="RefConference"><h2><a href="#RefConference">Conference</a></h2><ol><li>Tsung-Wei Huang, &quot;<a href="iccad20.pdf">A General-purpose Parallel and Heterogeneous Task Programming System for VLSI CAD</a>,&quot; <em>IEEE/ACM International Conference on Computer-aided Design (ICCAD)</em>, CA, 2020</li><li>Chun-Xun Lin, Tsung-Wei Huang, and Martin Wong, &quot;<a href="icpads20.pdf">An Efficient Work-Stealing Scheduler for Task Dependency Graph</a>,&quot; <em>IEEE International Conference on Parallel and Distributed Systems (ICPADS)</em>, Hong Kong, 2020</li><li>Tsung-Wei Huang, Chun-Xun Lin, Guannan Guo, and Martin Wong, &quot;<a href="ipdps19.pdf">Cpp-Taskflow: Fast Task-based Parallel Programming using Modern C++</a>,&quot; <em>IEEE International Parallel and Distributed Processing Symposium (IPDPS)</em>, pp. 974-983, Rio de Janeiro, Brazil, 2019</li><li>Chun-Xun Lin, Tsung-Wei Huang, Guannan Guo, and Martin Wong, &quot;<a href="mm19.pdf">A Modern C++ Parallel Task Programming Library</a>,&quot; <em>ACM Multimedia Conference (MM)</em>, pp. 2284-2287, Nice, France, 2019</li><li>Chun-Xun Lin, Tsung-Wei Huang, Guannan Guo, and Martin Wong, &quot;<a href="hpec19.pdf">An Efficient and Composable Parallel Task Programming Library</a>,&quot; <em>IEEE High-performance and Extreme Computing Conference (HPEC)</em>, pp. 1-7, Waltham, MA, 2019</li></ol></section><section id="RefJournal"><h2><a href="#RefJournal">Journal</a></h2><ol><li>Tsung-Wei Huang, Dian-Lun Lin, Yibo Lin, and Chun-Xun Lin, &quot;Cpp-Taskflow: A General-purpose Parallel Task Programming System at Scale,&quot; <em>IEEE Transactions on Computer-aided Design of Integrated Circuits and Systems (TCAD)</em>, to appear, 2020</li><li>Tsung-Wei Huang, Dian-Lun Lin, Yibo Lin, and Chun-Xun Lin, &quot;<a href="2004.10908v2.pdf">Cpp-Taskflow v2: A General-purpose Parallel and Heterogeneous Task Programming System at Scale</a>,&quot; <em>Computing Research Repository (CoRR)</em>, arXiv:2004.10908, 2020</li></ol></section><section id="RefRecognition"><h2><a href="#RefRecognition">Recognition</a></h2><ol><li>Champion of the MIT/Amazon Graph Challenge at the 2020 IEEE High-performance Extreme Computing Conference</li><li>Second Prize of Open-Source Software Competition at the 2019 ACM Multimedia Conference</li><li>ACM SIGDA Outstanding PhD Dissertation Award at the 2019 ACM/IEEE Design Automation Conference</li><li>Best Poster Award at the 2018 Official C++ Conference, voted by thousands of developers</li></ol></section>
59+
<p>This page summarizes a list of publication related to Taskflow. If you are using Taskflow, please cite the following paper:</p><p>Tsung-Wei Huang, Chun-Xun Lin, Guannan Guo, and Martin Wong, &quot;<a href="ipdps19.pdf">Cpp-Taskflow: Fast Task-based Parallel Programming using Modern C++</a>,&quot; <em>IEEE International Parallel and Distributed Processing Symposium (IPDPS)</em>, pp. 974-983, Rio de Janeiro, Brazil, 2019</p><section id="RefConference"><h2><a href="#RefConference">Conference</a></h2><ol><li>Tsung-Wei Huang, &quot;<a href="iccad20.pdf">A General-purpose Parallel and Heterogeneous Task Programming System for VLSI CAD</a>,&quot; <em>IEEE/ACM International Conference on Computer-aided Design (ICCAD)</em>, CA, 2020</li><li>Chun-Xun Lin, Tsung-Wei Huang, and Martin Wong, &quot;<a href="icpads20.pdf">An Efficient Work-Stealing Scheduler for Task Dependency Graph</a>,&quot; <em>IEEE International Conference on Parallel and Distributed Systems (ICPADS)</em>, Hong Kong, 2020</li><li>Tsung-Wei Huang, Chun-Xun Lin, Guannan Guo, and Martin Wong, &quot;<a href="ipdps19.pdf">Cpp-Taskflow: Fast Task-based Parallel Programming using Modern C++</a>,&quot; <em>IEEE International Parallel and Distributed Processing Symposium (IPDPS)</em>, pp. 974-983, Rio de Janeiro, Brazil, 2019</li><li>Chun-Xun Lin, Tsung-Wei Huang, Guannan Guo, and Martin Wong, &quot;<a href="mm19.pdf">A Modern C++ Parallel Task Programming Library</a>,&quot; <em>ACM Multimedia Conference (MM)</em>, pp. 2284-2287, Nice, France, 2019</li><li>Chun-Xun Lin, Tsung-Wei Huang, Guannan Guo, and Martin Wong, &quot;<a href="hpec19.pdf">An Efficient and Composable Parallel Task Programming Library</a>,&quot; <em>IEEE High-performance and Extreme Computing Conference (HPEC)</em>, pp. 1-7, Waltham, MA, 2019</li></ol></section><section id="RefJournal"><h2><a href="#RefJournal">Journal</a></h2><ol><li>Tsung-Wei Huang, Dian-Lun Lin, Yibo Lin, and Chun-Xun Lin, &quot;Cpp-Taskflow: A General-purpose Parallel Task Programming System at Scale,&quot; <em>IEEE Transactions on Computer-aided Design of Integrated Circuits and Systems (TCAD)</em>, to appear, 2020</li><li>Tsung-Wei Huang, Dian-Lun Lin, Yibo Lin, and Chun-Xun Lin, &quot;<a href="2004.10908v2.pdf">Cpp-Taskflow v2: A General-purpose Parallel and Heterogeneous Task Programming System at Scale</a>,&quot; <em>Computing Research Repository (CoRR)</em>, arXiv:2004.10908, 2020</li></ol></section><section id="RefRecognition"><h2><a href="#RefRecognition">Recognition</a></h2><ol><li>Champion of the MIT/Amazon Graph Challenge at the 2020 IEEE High-performance Extreme Computing Conference</li><li>Second Prize of Open-Source Software Competition at the 2019 ACM Multimedia Conference</li><li>ACM SIGDA Outstanding PhD Dissertation Award at the 2019 ACM/IEEE Design Automation Conference</li><li>Best Poster Award at the 2018 Official C++ Conference, voted by thousands of developers</li></ol></section>
6060
</div>
6161
</div>
6262
</div>

docs/kmeans.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h3>Contents</h3>
119119
<span class="kt">unsigned</span> <span class="n">P</span> <span class="o">=</span> <span class="mi">12</span><span class="p">;</span> <span class="c1">// 12 partitioned tasks</span>
120120

121121
<span class="c1">// update cluster</span>
122-
<span class="n">taskflow</span><span class="p">.</span><span class="n">parallel_for</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">](</span><span class="kt">int</span> <span class="n">i</span><span class="p">){</span>
122+
<span class="n">taskflow</span><span class="p">.</span><span class="n">for_each_index</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">](</span><span class="kt">int</span> <span class="n">i</span><span class="p">){</span>
123123
<span class="kt">float</span> <span class="n">x</span> <span class="o">=</span> <span class="n">px</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
124124
<span class="kt">float</span> <span class="n">y</span> <span class="o">=</span> <span class="n">py</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
125125
<span class="kt">float</span> <span class="n">best_d</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">numeric_limits</span><span class="o">&lt;</span><span class="kt">float</span><span class="o">&gt;::</span><span class="n">max</span><span class="p">();</span>
@@ -182,7 +182,7 @@ <h3>Contents</h3>
182182
<span class="p">}).</span><span class="n">name</span><span class="p">(</span><span class="s">&quot;clean_up&quot;</span><span class="p">);</span>
183183

184184
<span class="c1">// update cluster</span>
185-
<span class="n">tf</span><span class="o">::</span><span class="n">Task</span> <span class="n">pf</span> <span class="o">=</span> <span class="n">taskflow</span><span class="p">.</span><span class="n">parallel_for</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">](</span><span class="kt">int</span> <span class="n">i</span><span class="p">){</span>
185+
<span class="n">tf</span><span class="o">::</span><span class="n">Task</span> <span class="n">pf</span> <span class="o">=</span> <span class="n">taskflow</span><span class="p">.</span><span class="n">for_each_index</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">](</span><span class="kt">int</span> <span class="n">i</span><span class="p">){</span>
186186
<span class="kt">float</span> <span class="n">x</span> <span class="o">=</span> <span class="n">px</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
187187
<span class="kt">float</span> <span class="n">y</span> <span class="o">=</span> <span class="n">py</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
188188
<span class="kt">float</span> <span class="n">best_d</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">numeric_limits</span><span class="o">&lt;</span><span class="kt">float</span><span class="o">&gt;::</span><span class="n">max</span><span class="p">();</span>

docs/m.math.cache

0 Bytes
Binary file not shown.

docs/matrix_multiplication.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ <h3>Contents</h3>
8383
<span class="p">}</span>
8484

8585
<span class="n">executor</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">taskflow</span><span class="p">).</span><span class="n">wait</span><span class="p">();</span>
86-
<span class="p">}</span></pre><p>Instead of creating tasks one-by-one over a loop, you can leverage Taskflow::parallel_for to create a <em>parallel-for</em> task. A parallel-for task spawns a subflow to perform parallel iterations over the given range.</p><pre class="m-code"><span class="c1">// perform parallel iterations on the range [0, M) with the step size of 1</span>
87-
<span class="n">tf</span><span class="o">::</span><span class="n">Task</span> <span class="n">task</span> <span class="o">=</span> <span class="n">taskflow</span><span class="p">.</span><span class="n">parallel_for</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">]</span> <span class="p">(</span><span class="kt">int</span> <span class="n">m</span><span class="p">)</span> <span class="p">{</span>
86+
<span class="p">}</span></pre><p>Instead of creating tasks one-by-one over a loop, you can leverage <a href="classtf_1_1FlowBuilder.html#ab8417b211b18bb1e0f45a049331f084d" class="m-doc">Taskflow::<wbr />for_each_index</a> to create a <em>parallel-for</em> task. A parallel-for task spawns a subflow to perform parallel iterations over the given range.</p><pre class="m-code"><span class="c1">// perform parallel iterations on the range [0, M) with the step size of 1</span>
87+
<span class="n">tf</span><span class="o">::</span><span class="n">Task</span> <span class="n">task</span> <span class="o">=</span> <span class="n">taskflow</span><span class="p">.</span><span class="n">for_each_index</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">&amp;</span><span class="p">]</span> <span class="p">(</span><span class="kt">int</span> <span class="n">m</span><span class="p">)</span> <span class="p">{</span>
8888
<span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="n">n</span><span class="o">&lt;</span><span class="n">N</span><span class="p">;</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
8989
<span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">k</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="n">k</span><span class="o">&lt;</span><span class="n">K</span><span class="p">;</span> <span class="n">k</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
9090
<span class="n">C</span><span class="p">[</span><span class="n">m</span><span class="p">][</span><span class="n">n</span><span class="p">]</span> <span class="o">+=</span> <span class="n">A</span><span class="p">[</span><span class="n">m</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">B</span><span class="p">[</span><span class="n">k</span><span class="p">][</span><span class="n">n</span><span class="p">];</span>

0 commit comments

Comments
 (0)