diff options
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 4 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/loop-1.c | 127 |
2 files changed, 131 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 53125a5..547ce4e 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2019-07-20 Jakub Jelinek <jakub@redhat.com> + + * testsuite/libgomp.c-c++-common/loop-1.c: New test. + 2019-07-08 Jakub Jelinek <jakub@redhat.com> * testsuite/libgomp.c++/scan-13.C: Replace xfail with target x86. diff --git a/libgomp/testsuite/libgomp.c-c++-common/loop-1.c b/libgomp/testsuite/libgomp.c-c++-common/loop-1.c new file mode 100644 index 0000000..de69608 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/loop-1.c @@ -0,0 +1,127 @@ +extern +#ifdef __cplusplus +"C" +#endif +void abort (void); +#define N 256 +int r; + +void +foo (int *a) +{ + int i, j; + #pragma omp loop bind(thread) order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1) + for (i = 0; i < N; i++) + { + j = i - 2; + a[i] = j; + r += j; + } +} + +void +bar (int *a) +{ + int i, j; + #pragma omp loop bind(parallel) order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1) + for (i = 0; i < N; i++) + { + j = i; + a[i] = j; + r += j; + } +} + +void +baz (int *a) +{ + int i, j; + #pragma omp loop bind(teams) order(concurrent) private (j) lastprivate (i) reduction(+:r) + for (i = 0; i < N; i++) + { + j = i + 2; + a[i] = j; + r += j; + } +} + +int +main () +{ + int a[N], i, j; + foo (a); + for (i = 0; i < N; ++i) + if (a[i] != i - 2) + abort (); + else + a[i] = -35; + if (r != N * (N - 5) / 2) + abort (); + else + r = 0; + bar (a); + for (i = 0; i < N; ++i) + if (a[i] != i) + abort (); + else + a[i] = -35; + if (r != N * (N - 1) / 2) + abort (); + else + r = 0; + #pragma omp parallel loop private (j) lastprivate (i) reduction(+:r) + for (i = 0; i < N; i++) + { + j = i + 4; + a[i] = j; + r += j; + } + if (i != N) + abort (); + for (i = 0; i < N; ++i) + if (a[i] != i + 4) + abort (); + else + a[i] = -35; + if (r != N * (N + 7) / 2) + abort (); + else + r = 0; + #pragma omp parallel + bar (a); + for (i = 0; i < N; ++i) + if (a[i] != i) + abort (); + else + a[i] = -35; + if (r != N * (N - 1) / 2) + abort (); + else + r = 0; + #pragma omp teams + baz (a); + for (i = 0; i < N; ++i) + if (a[i] != i + 2) + abort (); + else + a[i] = -35; + if (r != N * (N + 3) / 2) + abort (); + else + r = 0; + #pragma omp teams loop order(concurrent) private (j) lastprivate (i) reduction(+:r) collapse(1) + for (i = 0; i < N; i++) + { + j = i - 4; + a[i] = j; + r += j; + } + if (i != N) + abort (); + for (i = 0; i < N; ++i) + if (a[i] != i - 4) + abort (); + if (r != N * (N - 9) / 2) + abort (); + return 0; +} |