Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ============================================================================
- Name : first.c
- Author : Arslan_ITIS
- Version :
- Copyright : Your copyright notice
- Description : Hello OpenMP World in C
- ============================================================================
- */
- #include <omp.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- int a[10][10];
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- a[i][j] = i+j;
- }
- }
- int min, max;
- min = 0; max =0;
- omp_set_num_threads(8);
- #pragma omp parallel for
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- #pragma omp critical
- if(a[i][j] < min) min = a[i][j];
- #pragma omp critical
- if(a[i][j] > max) max = a[i][j];
- }
- }
- printf("min = %d max = %d", min, max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement