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: README.md
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -479,6 +479,7 @@ Visit [documentation][wiki] to see the complete list.
479
479
| placeholder | none | task | insert a node without any work; work can be assigned later |
480
480
| linearize | task list | none | create a linear dependency in the given task list |
481
481
| parallel_for | beg, end, callable, group | task pair | apply the callable in parallel and group-by-group to the result of dereferencing every iterator in the range |
482
+
| parallel_for | beg, end, step, callable, group | task pair | apply the callable in parallel and group-by-group to a index-based range |
482
483
| reduce | beg, end, res, bop | task pair | reduce a range of elements to a single result through a binary operator |
483
484
| transform_reduce | beg, end, res, bop, uop | task pair | apply a unary operator to each element in the range and reduce them to a single result through a binary operator |
484
485
| dispatch | none | future | dispatch the current graph and return a shared future to block on completion |
@@ -569,12 +570,42 @@ auto [S, T] = tf.parallel_for(
569
570
[] (int i) {
570
571
std::cout << "AB and CD run in parallel" << '\n';
571
572
},
572
-
2 // group to execute two tasks at a time
573
+
2 // group two tasks at a time
573
574
);
574
575
```
575
576
576
577
By default, taskflow performs an even partition over worker threads
577
-
if the group size is not specified.
578
+
if the group size is not specified (or equal to 0).
579
+
580
+
In addition to range-based iterator, parallel\_for has another overload on an index-based loop.
581
+
The first three argument to this overload indicates
582
+
starting index, ending index (exclusive), and step size.
583
+
584
+
```cpp
585
+
// [0, 10) with a step size of 2
586
+
auto [S, T] = tf.parallel_for(
587
+
0, 10, 2,
588
+
[] (int i) {
589
+
std::cout << "parallel_for on index " << i << std::endl;
0 commit comments