I am trying to learn the concepts of OpenMP and stumbled upon a case that I find difficult to learn how to solve this library.
Say we have the following recursive function
void recurse(int tmp[], int p, const int size)
{
if (p == size)
{
performTask(tmp);
}
else
{
for(int i = 0; i < size; i++)
{
tmp[p] = i;
recurse(tmp, p+1, size);
}
}
}
int main(int argc, char * argv[])
{
int tmp[10];
recurse(tmp, 0, 10);
return 0;
}
How can I execute performTaskin parallel when creating new structures in the main thread using OpenMP?
I know that there is something called "tasks" and I think that what I should use here, but everything that I came up with, just does not get any success in performance. Please point me in the right direction.
Edit: I made the sample program more specific for a better explanation.
source
share