Taskflow
2.7.0
|
We study the classic problem, Fibonacci Number, to demonstrate the use of recursive task parallelism.
In mathematics, the Fibonacci numbers, commonly denoted F(n)
, form a sequence such that each number is the sum of the two preceding ones, starting from 0 and 1.
A common solution for computing fibonacci numbers is recursion.
We use tf::Subflow to recursively compute fibonacci numbers in parallel.
The spawned taskflow graph for computing up to the 7th fibonacci number is shown below:
Even if recursive dynamic tasking or subflows are permitted, the recursion depth may not be too deep or it can cause stack overflow.