2024-11-13 11:07:08 -08:00

25 lines
456 B
C

/*
* @@name: priv_reduction.3
* @@type: C
* @@operation: run
* @@expect: success
* @@version: omp_6.0
*/
#include <stdio.h>
int main(void)
{
int x;
x = 0;
// parallel reduction on shared x
#pragma omp parallel reduction(+: x) num_threads(strict: 4)
{
#pragma omp for reduction(+: x) // reduction on private x
for (int i = 0; i < 10; i++)
x++;
}
printf("x = %d\n", x); // should print 40, with 4 threads
return 0;
}