Skip to content

Commit a78edab

Browse files
committed
Merge branch 'master' into dev
2 parents 3185f90 + e40c633 commit a78edab

3 files changed

Lines changed: 13 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ Cpp-Taskflow is being actively developed and contributed by the following people
916916
- [Paolo Bolzoni](https://github.com/paolobolzoni) helped remove extraneous semicolons to suppress extra warning during compilation and contributed to a dataflow example
917917
- [Pursche](https://github.com/Pursche) fixed compilation warning on Microsoft Visual Studio
918918
- [KingDuckZ][KingDuckZ] helped discover the memory leak in the memory allocator used in graph and topology
919-
- [mrogez-yseop](https://github.com/mrogez-yseop) helped fix the missing comma in outputting the execution timeline JSON from the observer
919+
- [mrogez-yseop](https://github.com/mrogez-yseop) helped fix the missing comma in outputting the execution timeline JSON from the observer and the composition of an empty taskflow.
920920
- [Sztergbaum Roman](https://github.com/Milerius) replaced the error-prone global setting in cmake with project-specific targets
921921

922922
Meanwhile, we appreciate the support from many organizations for our development on Cpp-Taskflow.

benchmark/matrix_multiplication/taskflow.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,41 @@ void matrix_multiplication_taskflow(unsigned num_threads) {
77
tf::Executor executor(num_threads);
88
tf::Taskflow taskflow;
99

10-
std::vector<tf::Task> tasks;
11-
tasks.reserve(4*N);
1210
auto sync = taskflow.emplace([](){});
1311

1412
for(int i=0; i<N; ++i) {
15-
tasks[i] = taskflow.emplace([&, i=i](){
13+
taskflow.emplace([&, i=i](){
1614
for(int j=0; j<N; ++j) {
1715
a[i][j] = i + j;
1816
}
19-
});
20-
tasks[i].precede(sync);
17+
}).precede(sync);
2118
}
2219

2320
for(int i=0; i<N; ++i) {
24-
tasks[i+N] = taskflow.emplace([&, i=i](){
21+
taskflow.emplace([&, i=i](){
2522
for(int j=0; j<N; ++j) {
2623
b[i][j] = i * j;
2724
}
28-
});
29-
tasks[i+N].precede(sync);
25+
}).precede(sync);
3026
}
31-
tasks.clear();
3227

3328
for(int i=0; i<N; ++i) {
34-
tasks[i+2*N] = taskflow.emplace([&, i=i](){
29+
taskflow.emplace([&, i=i](){
3530
for(int j=0; j<N; ++j) {
3631
c[i][j] = 0;;
3732
}
38-
});
39-
tasks[i+2*N].precede(sync);
33+
}).precede(sync);
4034
}
41-
tasks.clear();
4235

4336
for(int i=0; i<N; ++i) {
44-
tasks[i+3*N] = taskflow.emplace([&, i=i](){
37+
auto t = taskflow.emplace([&, i=i](){
4538
for(int j=0; j<N; ++j) {
4639
for(int k=0; k<N; k++) {
4740
c[i][j] += a[i][k] * b[k][j];
4841
}
4942
}
5043
});
51-
sync.precede(tasks[i+3*N]);
44+
sync.precede(t);
5245
}
5346

5447
executor.run(taskflow).get();

taskflow/core/executor.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ inline void Executor::_schedule_unsync(
510510
) const {
511511

512512
// module node need another initialization
513-
if(node->_module != nullptr && !node->is_spawned()) {
513+
if(node->_module != nullptr && !node->_module->empty() && !node->is_spawned()) {
514514
_init_module_node_unsync(node, stack);
515515
}
516516

@@ -526,7 +526,7 @@ inline void Executor::_schedule_unsync(
526526
// here we guarantee to run by a thread so no need to cache the
527527
// size from nodes
528528
for(auto node : nodes) {
529-
if(node->_module != nullptr && !node->is_spawned()) {
529+
if(node->_module != nullptr && !node->_module->empty() && !node->is_spawned()) {
530530
_init_module_node_unsync(node, stack);
531531
}
532532
stack.push(node);
@@ -541,7 +541,7 @@ inline void Executor::_schedule(Node* node, bool bypass) {
541541
assert(_workers.size() != 0);
542542

543543
// module node need another initialization
544-
if(node->_module != nullptr && !node->is_spawned()) {
544+
if(node->_module != nullptr && !node->_module->empty() && !node->is_spawned()) {
545545
_init_module_node(node);
546546
}
547547

@@ -582,7 +582,7 @@ inline void Executor::_schedule(PassiveVector<Node*>& nodes) {
582582
}
583583

584584
for(auto node : nodes) {
585-
if(node->_module != nullptr && !node->is_spawned()) {
585+
if(node->_module != nullptr && !node->_module->empty() && !node->is_spawned()) {
586586
_init_module_node(node);
587587
}
588588
}

0 commit comments

Comments
 (0)