Initialize variable for omp reduction
问题 The OpenMP standard specifies an initial value for a reduction variable. So do I have to initialize the variable and how would I do that in the following case: int sum; //... for(int it=0;i<maxIt;i++){ #pragma omp parallel { #pragma omp for nowait for(int i=0;i<ct;i++) arrayX[i]=arrayY[i]; sum = 0; #pragma omp for reduction(+:sum) for(int i=0;i<ct;i++) sum+=arrayZ[i]; } //Use sum } Note that I use only 1 parallel region to minimize overhead and to allow the nowait in the first loop. Using