1
0
mirror of https://github.com/OpenMP/Examples.git synced 2025-04-14 02:11:25 +01:00
2022-11-04 09:35:42 -07:00

32 lines
471 B
C

/*
* @@name: reduction.7
* @@type: C
* @@operation: compile
* @@expect: success
* @@version: omp_4.5
*/
#include <stdio.h>
#define N 100
void init(int n, float (*b)[N]);
int main(){
int i,j;
float a[N], b[N][N];
init(N,b);
for(i=0; i<N; i++) a[i]=0.0e0;
#pragma omp parallel for reduction(+:a[0:N]) private(j)
for(i=0; i<N; i++){
for(j=0; j<N; j++){
a[j] += b[i][j];
}
}
printf(" a[0] a[N-1]: %f %f\n", a[0], a[N-1]);
return 0;
}