For-loop inside parallel region
问题 If there is a for-loop inside a parallel region, would for-loop be parallelized again or every thread will execute its own for-loop? T sum; #pragma omp parallel { #pragma omp for reduction(+: sum) for (;;) { T priv_var; sum += priv_var; } } 回答1: Yes, this code will cause OpenMP to parallelise the for loop across the threads that are spawned by the parallel region. However, I believe that your current for statement is invalid for OpenMP parallelisation. You need to explicitly provide an