Skip to content

Commit 76f093b

Browse files
added git attributes
1 parent c8a12ca commit 76f093b

13 files changed

Lines changed: 452 additions & 673 deletions

File tree

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
benchmark/* linguist-vendored
2+
doc/* linguist-vendored
3+
image/* linguist-vendored
4+
3rd-party/* linguist-vendored

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A fast C++ header-only library to help you quickly write parallel programs with
1515
Cpp-Taskflow is by far faster, more expressive, fewer lines of code, and easier for drop-in integration
1616
than existing parallel task programming libraries such as [OpenMP Tasking][OpenMP Tasking] and Intel [TBB FlowGraph][TBB FlowGraph].
1717

18-
![](image/plot/plot.jpg)
18+
![](image/performance.jpg)
1919

2020
Cpp-Taskflow enables you to implement efficient task decomposition strategies
2121
that incorporate both regular loop-based parallelism
@@ -387,9 +387,9 @@ auto C = tf.silent_emplace([] () {}).name("C");
387387
auto D = tf.silent_emplace([] () {}).name("D");
388388
auto E = tf.silent_emplace([] () {}).name("E");
389389

390-
A.broadcast(B, C, E);
390+
A.precede(B, C, E);
391391
C.precede(D);
392-
B.broadcast(D, E);
392+
B.precede(D, E);
393393

394394
std::cout << tf.dump();
395395
```
@@ -664,7 +664,6 @@ Visit [documentation][wiki] to see the complete list.
664664
| name | string | self | assign a human-readable name to the task |
665665
| work | callable | self | assign a work of a callable object to the task |
666666
| precede | task | self | enable this task to run *before* the given task |
667-
| broadcast | task list | self | enable this task to run *before* the given tasks |
668667
| gather | task list | self | enable this task to run *after* the given tasks |
669668
| num_dependents | none | size | return the number of dependents (inputs) of this task |
670669
| num_successors | none | size | return the number of successors (outputs) of this task |
@@ -696,16 +695,14 @@ The method `precede` is the basic building block to add a precedence between two
696695
A.precede(B);
697696
```
698697

699-
### *broadcast*
700-
701-
The method `broadcast` lets you precede a task to multiple tasks.
698+
You can precede multiple tasks at one time.
702699

703700
<img align="right" width="30%" src="image/broadcast.png">
704701

705702
```cpp
706703
// make A run before B, C, D, and E
707704
// B, C, D, and E run in parallel
708-
A.broadcast(B, C, D, E);
705+
A.precede(B, C, D, E);
709706
```
710707

711708
### *gather*

example/parallel_for.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void parallel_for_on_range(int N) {
99
std::iota(range.begin(), range.end(), 0);
1010

1111
tf::Taskflow tf;
12-
tf.parallel_for(range, [&] (const int i) {
12+
tf.parallel_for(range.begin(), range.end(), [&] (const int i) {
1313
printf("parallel_for on container item: %d\n", i);
1414
});
1515
tf.wait_for_all();

image/performance.jpeg

-70.5 KB
Binary file not shown.

image/performance.jpg

1.2 MB
Loading

taskflow/graph/basic_taskflow.hpp

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#pragma once
22

3-
#include "../threadpool/threadpool.hpp"
4-
#include "flow_builder.hpp"
3+
#include "task.hpp"
54
#include "framework.hpp"
65

76
namespace tf {
87

9-
// Class: BasicTaskflow
10-
// template argument E : executor, the threadpool implementation
8+
/** @class BasicTaskflow
9+
*
10+
* @brief The base class to derive a taskflow class
11+
*
12+
* @tparam E: executor type to use in this taskflow
13+
*
14+
* This class is the base class to derive a taskflow class.
15+
*
16+
*/
1117
template <template <typename...> typename E>
1218
class BasicTaskflow : public FlowBuilder {
1319

@@ -32,35 +38,112 @@ class BasicTaskflow : public FlowBuilder {
3238
public:
3339

3440
using Executor = E<Closure>;
35-
41+
42+
/**
43+
@brief construct the taskflow with @std_thread_hardware_concurrency worker threads
44+
*/
3645
explicit BasicTaskflow();
37-
explicit BasicTaskflow(unsigned);
38-
explicit BasicTaskflow(std::shared_ptr<Executor>);
46+
47+
/**
48+
@brief construct the taskflow with N worker threads
49+
*/
50+
explicit BasicTaskflow(unsigned N);
51+
52+
/**
53+
@brief construct the taskflow with a given executor
54+
*/
55+
explicit BasicTaskflow(std::shared_ptr<Executor> executor);
56+
57+
/**
58+
@brief destruct the taskflow
3959
60+
Destructing a taskflow object will first wait for all running topologies to finish
61+
and then clean up all associated data storages.
62+
*/
4063
~BasicTaskflow();
4164

65+
/**
66+
@brief share ownership of the executor associated with this taskflow object
67+
68+
@return a @std_shared_ptr of the executor
69+
*/
4270
std::shared_ptr<Executor> share_executor();
43-
71+
72+
/**
73+
@brief dispatch the present graph to threads and return immediately
74+
75+
@return a @std_shared_future to access the execution status of the dispatched graph
76+
*/
4477
std::shared_future<void> dispatch();
78+
79+
/**
80+
@brief dispatch the present graph to threads and run a callaback when the graph completes
4581
82+
@return a @std_shared_future to access the execution status of the dispatched graph
83+
*/
4684
template <typename C>
4785
std::shared_future<void> dispatch(C&&);
48-
86+
87+
/**
88+
@brief dispatch the present graph to threads and return immediately
89+
*/
4990
void silent_dispatch();
91+
92+
/**
93+
@brief dispatch the present graph to threads and run a callback when the graph completes
5094
95+
@param callable a callable object to execute on completion
96+
*/
5197
template <typename C>
52-
void silent_dispatch(C&&);
53-
98+
void silent_dispatch(C&& callable);
99+
100+
/**
101+
@brief dispatch the present graph to threads and wait for all topologies to complete
102+
*/
54103
void wait_for_all();
104+
105+
/**
106+
@brief wait for all running topologies to complete and clean them up
107+
*/
55108
void wait_for_topologies();
56-
void dump(std::ostream&) const;
57-
void dump_topologies(std::ostream&) const;
109+
110+
/**
111+
@brief dump the present task dependency graph to a @std_ostream in DOT format
112+
113+
@param ostream a @std_ostream target
114+
*/
115+
void dump(std::ostream& ostream) const;
116+
117+
/**
118+
@brief dump the present topologies to a @std_ostream in DOT format
58119
120+
@param ostream a @std_ostream target
121+
*/
122+
void dump_topologies(std::ostream& ostream) const;
123+
124+
/**
125+
@brief return the number of nodes in the present task dependency graph
126+
*/
59127
size_t num_nodes() const;
128+
129+
/**
130+
@brief return the number of worker threads
131+
*/
60132
size_t num_workers() const;
61-
size_t num_topologies() const;
62133

134+
/**
135+
@brief return the number of existing topologies
136+
*/
137+
size_t num_topologies() const;
138+
139+
/**
140+
@brief dump the present task dependency graph in DOT format to a @std_string
141+
*/
63142
std::string dump() const;
143+
144+
/**
145+
@brief dump the existing topologies in DOT format to a @std_string
146+
*/
64147
std::string dump_topologies() const;
65148

66149
private:

0 commit comments

Comments
 (0)