Using OMP_NESTED = FALSE, a thread team is assigned to a parallel top-level region and does not contain additional threads at each nested level, so no more than two threads will do useful work.
With OMP_NESTED = TRUE, a thread command is assigned at each level. Your system has 8 logical processors, so the size of the command is most likely 8. The command includes one thread from outside the region, so only 7 new threads are launched. The recursion tree for fib (n) has about fib (n) nodes. (A good self-referencing property of fib!) Thus, the code can create 7 * fib (n) threads that can quickly run out of resources.
The fix is ββto use one parallel area around the entire task tree. Move the omp parallel and omp single logic to the main one, outside the feed. Thus, a single thread command will work on the entire task tree.
A common point is to distinguish the potential of parallelism from actual parallelism. The task directives indicate the potential of parallelism, which may or may not actually be used at run time. omp parallel (for all practical purposes) indicates actual parallelism. Typically, you want the actual parallelism to match the hardware available so as not to soak the machine, but the potential of parallelism will be much greater so that the runtime can balance the load.
source share