X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=libgomp%2Ftestsuite%2Flibgomp.c%2B%2B%2Ffor-2.C;fp=libgomp%2Ftestsuite%2Flibgomp.c%2B%2B%2Ffor-2.C;h=98ffa1ae6f00163bf821c1cda2fd377f827e2484;hb=6fed43773c9b0ce596dca5686f37ac3fc0fa11c0;hp=0000000000000000000000000000000000000000;hpb=27b11d56b743098deb193d510b337ba22dc52e5c;p=msp430-gcc.git diff --git a/libgomp/testsuite/libgomp.c++/for-2.C b/libgomp/testsuite/libgomp.c++/for-2.C new file mode 100644 index 00000000..98ffa1ae --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/for-2.C @@ -0,0 +1,182 @@ +// { dg-do run } + +extern "C" void abort (); + +template +class J +{ +public: + J(T x, T y) : b (x), e (y) {} + T begin (); + T end (); +private: + T b, e; +}; + +template T J::begin () { return b; } +template T J::end () { return e; } + +int results[2000]; + +void +baz (int i) +{ + if (i < 0 || i >= 2000) + abort (); + results[i]++; +} + +void +f1 (int x, int y) +{ +#pragma omp parallel for + for (int i = x; i <= y; i += 6) + baz (i); +} + +void +f2 (int x, int y) +{ + int i; +#pragma omp parallel for private(i) + for (i = x; i < y - 1; i = 1 - 6 + 7 + i) + baz (i); +} + +template +void +f3 (int x, int y) +{ +#pragma omp parallel for + for (int i = x; i <= y; i = i + 9 - 8) + baz (i); +} + +template +void +f4 (int x, int y) +{ + int i; +#pragma omp parallel for lastprivate(i) + for (i = x + 2000 - 64; i > y + 10; --i) + baz (i); +} + +void +f5 (int x, int y) +{ +#pragma omp parallel for + for (int i = x + 2000 - 64; i > y + 10L; i -= 10L) + baz (i); +} + +template +void +f6 (int x, int y) +{ +#pragma omp parallel for + for (int i = x + 2000 - 64; i > y + 10L; i = i - 12 + 2L) + baz (i + N); +} + +template +void +f7 (int i, int x, int y) +{ +#pragma omp parallel for + for (i = x - 10; i <= y + 10; i += N) + baz (i); +} + +template +void +f8 (J j) +{ + int i; +#pragma omp parallel for + for (i = j.begin (); i <= j.end () + N; i += 2) + baz (i); +} + +template +void +f9 (T x, T y) +{ +#pragma omp parallel for + for (T i = x; i <= y; i = i + N) + baz (i); +} + +template +void +f10 (T x, T y) +{ + T i; +#pragma omp parallel for + for (i = x; i > y; i = i + N) + baz (i); +} + +template +void +f11 (T x, long y) +{ +#pragma omp parallel + { +#pragma omp for nowait + for (T i = x; i <= y; i += 3L) + baz (i); +#pragma omp single + baz (y + 3); + } +} + +template +void +f12 (T x, T y) +{ + T i; +#pragma omp parallel for + for (i = x; i > y; --i) + baz (i); +} + +#define check(expr) \ + for (int i = 0; i < 2000; i++) \ + if (expr) \ + { \ + if (results[i] != 1) \ + abort (); \ + results[i] = 0; \ + } \ + else if (results[i]) \ + abort () + +int +main () +{ + f1 (10, 1990); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (0, 1999); + check (i < 1998 && (i & 1) == 0); + f3 (20, 1837); + check (i >= 20 && i <= 1837); + f4 (0, 30); + check (i > 40 && i <= 2000 - 64); + f5 (0, 100); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (10, 110); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f7<6> (0, 12, 1800); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + f8<121> (J (14, 1803)); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9 (33, 1967); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (1939, 17); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11 (16, 1981); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12 (1761, 37); + check (i > 37 && i <= 1761); +}