How can I make this array sum is parallelized using OpenMP ? what should be shared, and what should be private ?
Here is the code for array sum ..
m
check out this code.
#include #include #include void main() { int sum=0; int lsum=0; int A[8]={1,2,3,4,5,6,7,8}; #pragma omp parallel private(lsum) { int i; #pragma omp for for (i=0; i<8; i++) { lsum = lsum +A[i]; } #pragma omp critical { sum+=lsum; } } printf("%d/n", sum); }