-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.c
33 lines (32 loc) · 744 Bytes
/
1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<omp.h>
#include<stdio.h>
#include<stdlib.h>
void main() {
int a[10],b[10],c[10],d[10],i;
for(i=0;i<10;i++)
a[i] = b[i] = i*10;
#pragma omp parallel num_threads(4)
{
int tid = omp_get_thread_num();
int x;
#pragma omp sections
{
#pragma omp section
{
printf("%d \n",omp_get_thread_num());
for(x=0;x<10;x++) {
c[x] = a[x] + b[x];
}
}
#pragma omp section
{
printf("%d \n",omp_get_thread_num());
for(x=0;x<10;x++) {
d[x] = a[x] * b[x];
}
}
}
}
for(i=0;i<10;i++)
printf("%d %d\n",c[i],d[i]);
}