What is the usage of reduction in openmp?
问题 I have this piece of code that is parallelized. int i,n; double area,pi,x; area=0.0; #pragma omp parallel for private(x) reduction (+:area) for(i=0; i<n; i++){ x= (i+0.5)/n; area+= 4.0/(1.0+x*x); } pi = area/n; It is said that the reduction will remove the race condition that could happen if we didn't use a reduction. Still I'm wondering do we need to add lastprivate for area since its used outside the parallel loop and will not be visible outside of it. Else does the reduction cover this as