diff options
Diffstat (limited to 'libgomp/testsuite/libgomp.c++/task-reduction-1.C')
-rw-r--r-- | libgomp/testsuite/libgomp.c++/task-reduction-1.C | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/task-reduction-1.C b/libgomp/testsuite/libgomp.c++/task-reduction-1.C new file mode 100644 index 0000000..b3e228e --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/task-reduction-1.C @@ -0,0 +1,63 @@ +extern "C" void abort (); + +int as; +int &a = as; +long int bs = 1; +long int &b = bs; + +void +foo (int &c, long long int &d) +{ + int i; + for (i = 0; i < 2; i++) + #pragma omp task in_reduction (*: d) in_reduction (+: c) \ + in_reduction (+: a) in_reduction (*: b) + { + a += 7; + b *= 2; + c += 9; + d *= 3; + } +} + +int +main () +{ + int cs = 0; + int &c = cs; + long long int ds = 1; + #pragma omp parallel + #pragma omp single + { + long long int &d = ds; + #pragma omp taskgroup task_reduction (+: a, c) task_reduction (*: b, d) + { + int i; + for (i = 0; i < 4; i++) + #pragma omp task in_reduction (+: a, c) in_reduction (*: b, d) + { + int j; + a += 7; + b *= 2; + for (j = 0; j < 2; j++) + #pragma omp task in_reduction (+: a, c) in_reduction (*: b, d) + { + a += 7; + b *= 2; + c += 9; + d *= 3; + foo (c, d); + } + c += 9; + d *= 3; + } + } +#define THREEP4 (3LL * 3LL * 3LL * 3LL) + if (d != (THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4 + * THREEP4)) + abort (); + } + if (a != 28 * 7 || b != (1L << 28) || c != 28 * 9) + abort (); + return 0; +} |