1 #include <omp.h> 2 3 // globals 4 extern int xdim; 5 extern int ydim; 6 7 // does a = b + c 8 void addmatrix(int ** a, int ** b, int ** c) { 9 10 int i,j; 11 12 // handle the outer loop in parallel 13 #pragma omp parallel for \ 14 shared(a,b,c,xdim,ydim) \ 15 private(i,j) \ 16 schedule(dynamic) 17 for(j=0;j<ydim;j++) { 18 19 // nothing special will be done to parallelize the inner loop-- 20 // this section is already done in parallel 21 for(i=0;i<xdim;i++) { 22 a[j][i] = b[j][i] + c[j][i]; 23 } 24 25 } // end of parallel for (implicit barrier) 26 27 } 28