Calculate Fibonacci numbers exploiting nested parallelism through TTaskGroup.
int Fibonacci(int n) {
if( n<2 ) {
} else {
tg.
Run([&]{x=Fibonacci(n-1);});
tg.
Run([&]{y=Fibonacci(n-2);});
}
}
void mt302_TTaskGroupNested()
{
cout << "Fibonacci(33) = " << Fibonacci(33) << endl;
}
- Date
- August 2017
- Author
- Danilo Piparo
Definition in file mt302_TTaskGroupNested.C.