diff options
Diffstat (limited to 'libgomp/testsuite')
24 files changed, 1814 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/atomic-2.C b/libgomp/testsuite/libgomp.c++/atomic-2.C new file mode 100644 index 0000000..e721759 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-2.C @@ -0,0 +1,156 @@ +// { dg-do run } + +extern "C" void abort (void); +int x = 6; +float y; + +int +main (void) +{ + int v; + float f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-3.C b/libgomp/testsuite/libgomp.c++/atomic-3.C new file mode 100644 index 0000000..660b260 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-3.C @@ -0,0 +1,74 @@ +// { dg-do run } + +extern "C" void abort (void); +bool v, x1, x2, x3, x4, x5, x6; + +void +foo () +{ + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic read + v = x3; + if (!v) + abort (); + #pragma omp atomic read + v = x4; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +void +bar () +{ + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); +} + +int +main () +{ + #pragma omp atomic write + x3 = true; + #pragma omp atomic write + x4 = true; + foo (); + bar (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-4.C b/libgomp/testsuite/libgomp.c++/atomic-4.C new file mode 100644 index 0000000..82439df --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-4.C @@ -0,0 +1,166 @@ +// { dg-do run } + +extern "C" void abort (void); +template <typename T, typename T2> +int +foo (void) +{ + extern T x; + extern T2 y; + T v; + T2 f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} + +int x = 6; +float y; + +int +main () +{ + foo <int, float> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-5.C b/libgomp/testsuite/libgomp.c++/atomic-5.C new file mode 100644 index 0000000..e9bd2cc --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-5.C @@ -0,0 +1,79 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename T> +void +foo () +{ + extern T v, x1, x2, x3, x4, x5, x6; + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic read + v = x3; + if (!v) + abort (); + #pragma omp atomic read + v = x4; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +template <typename T> +void +bar () +{ + extern T v, x1, x2; + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); +} + +bool v, x1, x2, x3, x4, x5, x6; + +int +main () +{ + #pragma omp atomic write + x3 = true; + #pragma omp atomic write + x4 = true; + foo <bool> (); + bar <bool> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-6.C b/libgomp/testsuite/libgomp.c++/atomic-6.C new file mode 100644 index 0000000..d7d0eb9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-6.C @@ -0,0 +1,58 @@ +// { dg-do run } + +extern "C" void abort (void); +long long l, m; +int i, j; + +void +foo (void) +{ + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +int +main () +{ + l = 77; + j = 88; + foo (); +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-7.C b/libgomp/testsuite/libgomp.c++/atomic-7.C new file mode 100644 index 0000000..fe1b4d7 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-7.C @@ -0,0 +1,63 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename S, typename T> +void +foo (void) +{ + extern S l, m; + extern T i, j; + + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +long long l, m; +int i, j; + +int +main () +{ + l = 77; + j = 88; + foo <long long, int> (); +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-8.C b/libgomp/testsuite/libgomp.c++/atomic-8.C new file mode 100644 index 0000000..744b340 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-8.C @@ -0,0 +1,137 @@ +// { dg-do run } + +extern "C" void abort (); +int x = 6, cnt; + +int +foo () +{ + return cnt++; +} + +int +main () +{ + int v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-9.C b/libgomp/testsuite/libgomp.c++/atomic-9.C new file mode 100644 index 0000000..ece1bf3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-9.C @@ -0,0 +1,148 @@ +// { dg-do run } + +extern "C" void abort (); + +int cnt; + +int +foo () +{ + return cnt++; +} + +template <typename T> +void +bar () +{ + extern T x; + T v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); +} + +int x = 6; + +int +main () +{ + bar <int> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/reduction-4.C b/libgomp/testsuite/libgomp.c++/reduction-4.C new file mode 100644 index 0000000..e7ef8a1 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/reduction-4.C @@ -0,0 +1,54 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename I, typename F> +void +foo () +{ + I j = -10000; + F f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); +} + +int +main () +{ + int j = -10000; + float f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); + foo <int, float> (); + foo <long, double> (); + foo <long long, long double> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/task-8.C b/libgomp/testsuite/libgomp.c++/task-8.C new file mode 100644 index 0000000..3e1b469 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/task-8.C @@ -0,0 +1,44 @@ +// { dg-do run } + +#include <omp.h> +#include <cstdlib> + +int err; + +int +main () +{ + int e; +#pragma omp parallel shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + } + #pragma omp task final (1) shared(err) + { + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp taskyield + #pragma omp taskwait + #pragma omp task shared(err) + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + } + } + #pragma omp atomic read + e = err; + if (e) + abort (); +} diff --git a/libgomp/testsuite/libgomp.c/atomic-11.c b/libgomp/testsuite/libgomp.c/atomic-11.c new file mode 100644 index 0000000..d1d6ca5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-11.c @@ -0,0 +1,156 @@ +/* { dg-do run } */ + +extern void abort (void); +int x = 6; +float y; + +int +main (void) +{ + int v; + float f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-12.c b/libgomp/testsuite/libgomp.c/atomic-12.c new file mode 100644 index 0000000..a9fe560 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-12.c @@ -0,0 +1,98 @@ +/* { dg-do run } */ + +extern void abort (void); +_Bool v, x1, x2, x3, x4, x5, x6; + +void +foo (void) +{ + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic capture + v = --x3; + if (v) + abort (); + #pragma omp atomic capture + v = x4--; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +void +bar (void) +{ + #pragma omp atomic write + x1 = 0; + #pragma omp atomic write + x2 = 0; + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic capture + { --x3; v = x3; } + if (v) + abort (); + #pragma omp atomic capture + { v = x4; x4--; } + if (!v) + abort (); + #pragma omp atomic write + x1 = 0; + #pragma omp atomic write + x2 = 0; + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); + #pragma omp atomic capture + { x3--; v = x3; } + if (v) + abort (); + #pragma omp atomic capture + { v = x4; --x4; } + if (!v) + abort (); +} + +int +main () +{ + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + foo (); + bar (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-13.c b/libgomp/testsuite/libgomp.c/atomic-13.c new file mode 100644 index 0000000..52800fc --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-13.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ + +extern void abort (void); +long long l, m; +int i, j; + +void +foo (void) +{ + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +int +main () +{ + l = 77; + j = 88; + foo (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-14.c b/libgomp/testsuite/libgomp.c/atomic-14.c new file mode 100644 index 0000000..5936650 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-14.c @@ -0,0 +1,137 @@ +/* { dg-do run } */ + +extern void abort (void); +int x = 6, cnt; + +int +foo (void) +{ + return cnt++; +} + +int +main () +{ + int v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/reduction-6.c b/libgomp/testsuite/libgomp.c/reduction-6.c new file mode 100644 index 0000000..d378bad --- /dev/null +++ b/libgomp/testsuite/libgomp.c/reduction-6.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +extern void abort (void); +int j; +float f; + +int +main () +{ + j = -10000; + f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/task-5.c b/libgomp/testsuite/libgomp.c/task-5.c new file mode 100644 index 0000000..b152371 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/task-5.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ + +#include <omp.h> +#include <stdlib.h> + +int err; + +int +main () +{ + int e; +#pragma omp parallel shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + } + #pragma omp task final (1) shared(err) + { + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp taskyield + #pragma omp taskwait + #pragma omp task shared(err) + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + } + } + #pragma omp atomic read + e = err; + if (e) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.fortran/allocatable7.f90 b/libgomp/testsuite/libgomp.fortran/allocatable7.f90 new file mode 100644 index 0000000..dc68baa --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/allocatable7.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + + integer, allocatable :: a(:) + logical :: l + l = .false. +!$omp parallel firstprivate (a) reduction (.or.:l) + l = allocated (a) + allocate (a(10)) + l = l .or. .not. allocated (a) + a = 10 + if (any (a .ne. 10)) l = .true. + deallocate (a) + l = l .or. allocated (a) +!$omp end parallel + if (l) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/allocatable8.f90 b/libgomp/testsuite/libgomp.fortran/allocatable8.f90 new file mode 100644 index 0000000..2093782 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/allocatable8.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +! { dg-require-effective-target tls_runtime } +!$ use omp_lib + + integer, save, allocatable :: a(:, :) + logical :: l +!$omp threadprivate (a) + if (allocated (a)) call abort + l = .false. +!$omp parallel copyin (a) num_threads (4) reduction(.or.:l) + l = l.or.allocated (a) +!$omp end parallel + if (l.or.allocated (a)) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/crayptr3.f90 b/libgomp/testsuite/libgomp.fortran/crayptr3.f90 new file mode 100644 index 0000000..9777c6b --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/crayptr3.f90 @@ -0,0 +1,36 @@ +! { dg-do run } +! { dg-options "-fopenmp -fcray-pointer" } + + use omp_lib + integer :: a, b, c, i, p + logical :: l + pointer (ip, p) + a = 1 + b = 2 + c = 3 + l = .false. + ip = loc (a) + +!$omp parallel num_threads (2) reduction (.or.:l) firstprivate (ip) + l = p .ne. 1 + ip = loc (b) + if (omp_get_thread_num () .eq. 1) ip = loc (c) + l = l .or. (p .ne. (2 + omp_get_thread_num ())) +!$omp end parallel + + if (l) call abort + + l = .false. + ip = loc (a) +!$omp parallel do num_threads (2) reduction (.or.:l) & +!$omp & firstprivate (ip) lastprivate (ip) + do i = 0, 1 + l = l .or. (p .ne. 1) + ip = loc (b) + if (i .eq. 1) ip = loc (c) + l = l .or. (p .ne. (2 + i)) + end do + + if (l) call abort + if (p .ne. 3) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 b/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 new file mode 100644 index 0000000..e8923d1 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 @@ -0,0 +1,58 @@ +! { dg-do run } + integer (kind = 4) :: a, a2 + integer (kind = 2) :: b, b2 + real :: c, f + double precision :: d, d2, c2 + integer, dimension (10) :: e +!$omp atomic write + a = 1 +!$omp atomic write + b = 2 +!$omp end atomic +!$omp atomic write + c = 3 +!$omp atomic write + d = 1 + 2 + 3 - 2 + e = 5 +!$omp atomic write + f = 6 +!$omp end atomic +!$omp atomic + a = a + 4 +!$omp end atomic +!$omp atomic update + b = 4 - b +!$omp atomic + c = c * 2 +!$omp atomic update + d = 2 / d +!$omp end atomic +!$omp atomic read + a2 = a +!$omp atomic read + b2 = b +!$omp end atomic +!$omp atomic read + c2 = c +!$omp atomic read + d2 = d + if (a2 .ne. 5 .or. b2 .ne. 2 .or. c2 .ne. 6 .or. d2 .ne. 0.5) call abort +!$omp atomic write + d = 1.2 +!$omp atomic + a = a + c + d +!$omp atomic + b = b - (a + c + d) + if (a .ne. 12 .or. b .ne. -17) call abort +!$omp atomic + a = c + d + a +!$omp atomic + b = a + c + d - b + if (a .ne. 19 .or. b .ne. 43) call abort +!$omp atomic + b = (a + c + d) - b + a = 32 +!$omp atomic + a = a / 3.4 + if (a .ne. 9 .or. b .ne. -16) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 b/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 new file mode 100644 index 0000000..725a3bc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 @@ -0,0 +1,37 @@ +! { dg-do run } + integer (kind = 4) :: a, a2 + integer (kind = 2) :: b, b2 + real :: c + double precision :: d, d2, c2 + integer, dimension (10) :: e +!$omp atomic write + a = 1 +!$omp atomic write + b = 2 +!$omp atomic write + c = 3 +!$omp atomic write + d = 4 +!$omp atomic capture + a2 = a + a = a + 4 +!$omp end atomic +!$omp atomic capture + b = b - 18 + b2 = b +!$omp end atomic +!$omp atomic capture + c2 = c + c = 2.0 * c +!$omp end atomic +!$omp atomic capture + d = d / 2.0 + d2 = d +!$omp end atomic + if (a2 .ne. 1 .or. b2 .ne. -16 .or. c2 .ne. 3 .or. d2 .ne. 2) call abort +!$omp atomic read + a2 = a +!$omp atomic read + c2 = c + if (a2 .ne. 5 .or. b2 .ne. -16 .or. c2 .ne. 6 .or. d2 .ne. 2) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/pointer1.f90 b/libgomp/testsuite/libgomp.fortran/pointer1.f90 new file mode 100644 index 0000000..d55ef35f --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pointer1.f90 @@ -0,0 +1,77 @@ +! { dg-do run } + integer, pointer :: a, c(:) + integer, target :: b, d(10) + b = 0 + a => b + d = 0 + c => d + call foo (a, c) + b = 0 + d = 0 + call bar (a, c) +contains + subroutine foo (a, c) + integer, pointer :: a, c(:), b, d(:) + integer :: r, r2 + r = 0 + !$omp parallel firstprivate (a, c) reduction (+:r) + !$omp atomic + a = a + 1 + !$omp atomic + c(1) = c(1) + 1 + r = r + 1 + !$omp end parallel + if (a.ne.r.or.c(1).ne.r) call abort + r2 = r + b => a + d => c + r = 0 + !$omp parallel firstprivate (b, d) reduction (+:r) + !$omp atomic + b = b + 1 + !$omp atomic + d(1) = d(1) + 1 + r = r + 1 + !$omp end parallel + if (b.ne.r+r2.or.d(1).ne.r+r2) call abort + end subroutine foo + subroutine bar (a, c) + integer, pointer :: a, c(:), b, d(:) + integer, target :: q, r(5) + integer :: i + q = 17 + r = 21 + b => a + d => c + !$omp parallel do firstprivate (a, c) lastprivate (a, c) + do i = 1, 100 + !$omp atomic + a = a + 1 + !$omp atomic + c((i+9)/10) = c((i+9)/10) + 1 + if (i.eq.100) then + a => q + c => r + end if + end do + !$omp end parallel do + if (b.ne.100.or.any(d.ne.10)) call abort + if (a.ne.17.or.any(c.ne.21)) call abort + a => b + c => d + !$omp parallel do firstprivate (b, d) lastprivate (b, d) + do i = 1, 100 + !$omp atomic + b = b + 1 + !$omp atomic + d((i+9)/10) = d((i+9)/10) + 1 + if (i.eq.100) then + b => q + d => r + end if + end do + !$omp end parallel do + if (a.ne.200.or.any(c.ne.20)) call abort + if (b.ne.17.or.any(d.ne.21)) call abort + end subroutine bar +end diff --git a/libgomp/testsuite/libgomp.fortran/pointer2.f90 b/libgomp/testsuite/libgomp.fortran/pointer2.f90 new file mode 100644 index 0000000..f172aed --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pointer2.f90 @@ -0,0 +1,28 @@ +! { dg-do run } +! { dg-require-effective-target tls_runtime } + integer, pointer, save :: thr(:) +!$omp threadprivate (thr) + integer, target :: s(3), t(3), u(3) + integer :: i + logical :: l + s = 2 + t = 7 + u = 13 + thr => t + l = .false. + i = 0 +!$omp parallel copyin (thr) reduction(.or.:l) reduction(+:i) + if (any (thr.ne.7)) l = .true. + thr => s +!$omp master + thr => u +!$omp end master +!$omp atomic + thr(1) = thr(1) + 1 + i = i + 1 +!$omp end parallel + if (l) call abort + if (thr(1).ne.14) call abort + if (s(1).ne.1+i) call abort + if (u(1).ne.14) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/task4.f90 b/libgomp/testsuite/libgomp.fortran/task4.f90 new file mode 100644 index 0000000..9fa67d9 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/task4.f90 @@ -0,0 +1,45 @@ +! { dg-do run } + + use omp_lib + integer :: err, e + +!$omp atomic write + err = 0 +!$omp parallel shared(err) private(e) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp task if (.false.) shared(err) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp task if (.false.) shared(err) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp end task +!$omp end task +!$omp atomic read + e = err +!$omp task final (e .eq. 0) shared(err) + if (.not.omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp taskyield +!$omp taskwait +!$omp task shared(err) + if (.not.omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp end task +!$omp end task +!$omp end parallel +!$omp atomic read + e = err + if (e .ne. 0) call abort +end |