Nested parallel for loop: "Parallel outer for loop" in "parallel inner for loop as a function"
<p>I want to run a function that contains a for loop (supposed to run in parallel) in a parallel outer loop. So it looks like the following:</p>
<pre><code>void myfunction(){
    ...
    #pragma omp parallel for
    for (int i=0;i&lt;10;i++){
        do something...
    }
}


int main(){
    #pragma omp parallel for
    for(int i=0;i&lt;5;i++){
        myfunction();
    }
}
</code></pre>
<p>Given the above code, I want to create 5 parallel threads for the loop in the <code>main()</code> function, and I want each of the 5 threads to create another <code>K</code> threads to run its own parallel <em>for</em> loop.</p>
<p>Although I know how to run nested for loops if the inner loop is not in a separate function, I cannot find a solution for this kind of problem.</p>
<p>In fact, this piece of code is for parallel 5 fold cross-validation, where each fold has a for loop that should be parallelized.</p>