Guest User

Untitled

a guest
May 5th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <omp.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. int main (int argc, char *argv[]) {
  7.    
  8.     int i    = 0;
  9.     int size = pow(10.0, atoi(argv[1]));
  10.     int sum  = 0;
  11.     int enableParallel = atoi(argv[2]);
  12.  
  13.     #pragma omp parallel for default(none) if(enableParallel) schedule(static) shared(size, sum) private(i)
  14.     for(i = 0; i < size; i++) {
  15.         sum++;
  16.     }  
  17.     printf("Sum: %i\n" , sum);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment