Advertisement
Guest User

OMP #10

a guest
Nov 25th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*
  2. ============================================================================
  3. Name : first.c
  4. Author : Arslan_ITIS
  5. Version :
  6. Copyright : Your copyright notice
  7. Description : Hello OpenMP World in C
  8. ============================================================================
  9. */
  10. #include <omp.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. int main(){
  14. int a[10][10];
  15. for(int i = 0; i < 10; i++){
  16. for(int j = 0; j < 10; j++){
  17. a[i][j] = i+j;
  18. }
  19. }
  20. int min, max;
  21. min = 0; max =0;
  22. omp_set_num_threads(8);
  23. #pragma omp parallel for
  24. for(int i = 0; i < 10; i++){
  25. for(int j = 0; j < 10; j++){
  26. #pragma omp critical
  27. if(a[i][j] < min) min = a[i][j];
  28. #pragma omp critical
  29. if(a[i][j] > max) max = a[i][j];
  30. }
  31. }
  32. printf("min = %d max = %d", min, max);
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement