OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/gcc-4.5.1/gcc-4.5.1-or32-1.0rc1/libgomp/testsuite/libgomp.c++
    from Rev 273 to Rev 338
    Reverse comparison

Rev 273 → Rev 338

/copyin-1.C
0,0 → 1,34
// { dg-do run }
// { dg-require-effective-target tls_runtime }
 
#include <omp.h>
 
extern "C" void abort (void);
 
int thr = 32;
#pragma omp threadprivate (thr)
 
int
main (void)
{
int l = 0;
 
omp_set_dynamic (0);
omp_set_num_threads (6);
 
#pragma omp parallel copyin (thr) reduction (||:l)
{
l = thr != 32;
thr = omp_get_thread_num () + 11;
}
 
if (l || thr != 11)
abort ();
 
#pragma omp parallel reduction (||:l)
l = thr != omp_get_thread_num () + 11;
 
if (l)
abort ();
return 0;
}
copyin-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-1.C =================================================================== --- task-1.C (nonexistent) +++ task-1.C (revision 338) @@ -0,0 +1,83 @@ +extern "C" void abort (); + +int a = 18; + +void +f1 (int i, int j, int k) +{ + int l = 6, m = 7, n = 8; +#pragma omp task private(j, m) shared(k, n) + { + j = 6; + m = 5; + if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9) + #pragma omp atomic + k++; + } +#pragma omp taskwait + if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9) + abort (); +} + +int v1 = 1, v2 = 2, v5 = 5; +int e; + +void +f2 (void) +{ + int v3 = 3; +#pragma omp sections private (v1) firstprivate (v2) + { + #pragma omp section + { + int v4 = 4; + v1 = 7; + #pragma omp task + { + if (++v1 != 8 || ++v2 != 3 || ++v3 != 4 || ++v4 != 5 || ++v5 != 6) + e = 1; + } + #pragma omp taskwait + if (v1 != 7 || v2 != 2 || v3 != 3 || v4 != 4 || v5 != 6) + abort (); + if (e) + abort (); + } + } +} + +void +f3 (int i, int j, int k) +{ + int l = 6, m = 7, n = 8; +#pragma omp task private(j, m) shared(k, n) untied + { + j = 6; + m = 5; + if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9) + #pragma omp atomic + k++; + } +#pragma omp taskwait + if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9) + abort (); +} + +int +main () +{ + f1 (8, 26, 0); + f2 (); + a = 18; + f3 (8, 26, 0); + a = 18; +#pragma omp parallel num_threads(4) + { + #pragma omp master + { + f1 (8, 26, 0); + a = 18; + f3 (8, 26, 0); + } + } +}
task-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-3.C =================================================================== --- task-3.C (nonexistent) +++ task-3.C (revision 338) @@ -0,0 +1,90 @@ +// { dg-do run } + +extern "C" void abort (); + +struct A +{ + A (); + ~A (); + A (const A &); + unsigned long l; +}; + +int e; + +A::A () +{ + l = 17; +} + +A::~A () +{ + if (l > 30) + #pragma omp atomic + e++; +} + +A::A (const A &r) +{ + l = r.l; +} + +void +check (int i, A &a, int j, A &b) +{ + if (i != 6 || a.l != 21 || j != 0 || b.l != 23) + #pragma omp atomic + e++; +} + +A b; +int j; + +void +foo (int i) +{ + A a; + a.l = 21; + #pragma omp task firstprivate (i, a, j, b) + check (i, a, j, b); +} + +void +bar (int i, A a) +{ + a.l = 21; + #pragma omp task firstprivate (i, a, j, b) + check (i, a, j, b); +} + +A +baz () +{ + A a, c; + a.l = 21; + c.l = 23; + #pragma omp task firstprivate (a, c) + check (6, a, 0, c); + return a; +} + +int +main () +{ + b.l = 23; + foo (6); + bar (6, A ()); + baz (); + #pragma omp parallel num_threads (4) + { + #pragma omp single + for (int i = 0; i < 64; i++) + { + foo (6); + bar (6, A ()); + baz (); + } + } + if (e) + abort (); +}
task-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-5.C =================================================================== --- task-5.C (nonexistent) +++ task-5.C (revision 338) @@ -0,0 +1,90 @@ +// { dg-do run } + +extern "C" void abort (); + +struct A +{ + A (); + ~A (); + A (const A &); + unsigned long l; +}; + +int e; + +A::A () +{ + l = 17; +} + +A::~A () +{ + if (l > 130) + #pragma omp atomic + e++; +} + +A::A (const A &r) +{ + l = r.l + 64; +} + +void +check (int i, A &a, int j, A &b) +{ + if (i != 6 || a.l != 21 + 64 || j != 0 || b.l != 23 + 64) + #pragma omp atomic + e++; +} + +A b; +int j; + +void +foo (int i) +{ + A a; + a.l = 21; + #pragma omp task firstprivate (j, b) + check (i, a, j, b); +} + +void +bar (int i, A a) +{ + a.l = 21; + #pragma omp task firstprivate (j, b) + check (i, a, j, b); +} + +A +baz () +{ + A a, c; + a.l = 21; + c.l = 23; + #pragma omp task firstprivate (a, c) + check (6, a, 0, c); + return a; +} + +int +main () +{ + b.l = 23; + foo (6); + bar (6, A ()); + baz (); + #pragma omp parallel num_threads (4) + { + #pragma omp single + for (int i = 0; i < 64; i++) + { + foo (6); + bar (6, A ()); + baz (); + } + } + if (e) + abort (); +}
task-5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: shared-1.C =================================================================== --- shared-1.C (nonexistent) +++ shared-1.C (revision 338) @@ -0,0 +1,60 @@ +#include + +extern "C" void abort (void); + +struct Y +{ + int l[5][10]; +}; + +struct X +{ + struct Y y; + float b[10]; +}; + +void +parallel (int a, int b) +{ + int i, j; + struct X A[10][5]; + a = b = 3; + + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + A[i][j].y.l[3][3] = -10; + + #pragma omp parallel shared (a, b, A) num_threads (5) + { + int i, j; + + #pragma omp atomic + a += omp_get_num_threads (); + + #pragma omp atomic + b += omp_get_num_threads (); + + #pragma omp for private (j) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + A[i][j].y.l[3][3] += 20; + + } + + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + if (A[i][j].y.l[3][3] != 10) + abort (); + + if (a != 28) + abort (); + + if (b != 28) + abort (); +} + +main() +{ + parallel (1, 2); + return 0; +}
shared-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-7.C =================================================================== --- task-7.C (nonexistent) +++ task-7.C (revision 338) @@ -0,0 +1,18 @@ +// PR c++/36523 +// { dg-do run } + +template +struct A +{ + A() { } + A(const A&) { } + void foo() { } +}; + +int main() +{ + A a; + #pragma omp task firstprivate (a) + a.foo(); + return 0; +}
task-7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-1.C =================================================================== --- loop-1.C (nonexistent) +++ loop-1.C (revision 338) @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +#define MAX 1000 + +void main1() +{ + int i, N1, N2, step; + int a[MAX], b[MAX]; + + N1 = rand () % 13; + N2 = rand () % (MAX - 51) + 50; + step = rand () % 7 + 1; + + printf ("N1 = %d\nN2 = %d\nstep = %d\n", N1, N2, step); + + for (i = N1; i <= N2; i += step) + a[i] = 42+ i; + + /* COUNTING UP (<). Fill in array 'b' in parallel. */ + memset (b, 0, sizeof b); +#pragma omp parallel shared(a,b,N1,N2,step) private(i) + { +#pragma omp for + for (i = N1; i < N2; i += step) + b[i] = a[i]; + } + + /* COUNTING UP (<). Check that all the cells were filled in properly. */ + for (i = N1; i < N2; i += step) + if (a[i] != b[i]) + abort (); + + printf ("for (i = %d; i < %d; i += %d) [OK]\n", N1, N2, step); + + /* COUNTING UP (<=). Fill in array 'b' in parallel. */ + memset (b, 0, sizeof b); +#pragma omp parallel shared(a,b,N1,N2,step) private(i) + { +#pragma omp for + for (i = N1; i <= N2; i += step) + b[i] = a[i]; + } + + /* COUNTING UP (<=). Check that all the cells were filled in properly. */ + for (i = N1; i <= N2; i += step) + if (a[i] != b[i]) + abort (); + + printf ("for (i = %d; i <= %d; i += %d) [OK]\n", N1, N2, step); + + /* COUNTING DOWN (>). Fill in array 'b' in parallel. */ + memset (b, 0, sizeof b); +#pragma omp parallel shared(a,b,N1,N2,step) private(i) + { +#pragma omp for + for (i = N2; i > N1; i -= step) + b[i] = a[i]; + } + + /* COUNTING DOWN (>). Check that all the cells were filled in properly. */ + for (i = N2; i > N1; i -= step) + if (a[i] != b[i]) + abort (); + + printf ("for (i = %d; i > %d; i -= %d) [OK]\n", N2, N1, step); + + /* COUNTING DOWN (>=). Fill in array 'b' in parallel. */ + memset (b, 0, sizeof b); +#pragma omp parallel shared(a,b,N1,N2,step) private(i) + { +#pragma omp for + for (i = N2; i >= N1; i -= step) + b[i] = a[i]; + } + + /* COUNTING DOWN (>=). Check that all the cells were filled in properly. */ + for (i = N2; i >= N1; i -= step) + if (a[i] != b[i]) + abort (); + + printf ("for (i = %d; i >= %d; i -= %d) [OK]\n", N2, N1, step); +} + +int +main () +{ + int i; + + srand (0); + for (i = 0; i < 10; ++i) + main1(); + return 0; +}
loop-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-3.C =================================================================== --- loop-3.C (nonexistent) +++ loop-3.C (revision 338) @@ -0,0 +1,26 @@ +extern "C" void abort (void); +int a; + +void +foo () +{ + int i; + a = 30; +#pragma omp barrier +#pragma omp for lastprivate (a) + for (i = 0; i < 1024; i++) + { + a = i; + } + if (a != 1023) + abort (); +} + +int +main (void) +{ +#pragma omp parallel num_threads (64) + foo (); + + return 0; +}
loop-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-5.C =================================================================== --- loop-5.C (nonexistent) +++ loop-5.C (revision 338) @@ -0,0 +1,19 @@ +extern "C" void abort (); + +int check; +int f1() { check |= 1; return 1; } +int f2() { check |= 2; return 11; } +int f3() { check |= 4; return 2; } + +int a[12]; + +int main() +{ + #pragma omp for + for (int i = f1(); i <= f2(); i += f3()) + a[i] = 1; + + for (int i = 0; i < 12; ++i) + if (a[i] != (i & 1)) + abort (); +}
loop-5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-7.C =================================================================== --- loop-7.C (nonexistent) +++ loop-7.C (revision 338) @@ -0,0 +1,22 @@ +// PR c++/24502 +// { dg-do run } + +extern "C" void abort (); + +template T +foo (T r) +{ + T i; +#pragma omp for + for (i = 0; i < 10; i++) + r += i; + return r; +} + +int +main () +{ + if (foo (0) != 10 * 9 / 2 || foo (2L) != 10L * 9 / 2 + 2) + abort (); + return 0; +}
loop-7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-9.C =================================================================== --- loop-9.C (nonexistent) +++ loop-9.C (revision 338) @@ -0,0 +1,387 @@ +// { dg-do run } + +#include + +extern "C" void abort (); + +#define LLONG_MAX __LONG_LONG_MAX__ +#define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +#define INT_MAX __INT_MAX__ + +int arr[6 * 5]; + +void +set (int loopidx, int idx) +{ +#pragma omp atomic + arr[loopidx * 5 + idx]++; +} + +#define check(var, val, loopidx, idx) \ + if (var == (val)) set (loopidx, idx); else +#define test(loopidx, count) \ + for (idx = 0; idx < 5; idx++) \ + if (arr[loopidx * 5 + idx] != idx < count) \ + abort (); \ + else \ + arr[loopidx * 5 + idx] = 0 + +int +test1 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(dynamic,1) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test2 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(guided,1) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test3 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(static) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(static) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(static) nowait + for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test4 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(static,1) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test5 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(runtime) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = LLONG_MAX - 20000ULL; j <= LLONG_MAX + 10000ULL; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (i = -3LL * INT_MAX - 20000LL; i <= INT_MAX + 10000LL; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +main () +{ + if (2 * sizeof (int) != sizeof (long long)) + return 0; + test1 (); + test2 (); + test3 (); + test4 (); + omp_set_schedule (omp_sched_static, 0); + test5 (); + omp_set_schedule (omp_sched_static, 3); + test5 (); + omp_set_schedule (omp_sched_dynamic, 5); + test5 (); + omp_set_schedule (omp_sched_guided, 2); + test5 (); + return 0; +}
loop-9.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: single-1.C =================================================================== --- single-1.C (nonexistent) +++ single-1.C (revision 338) @@ -0,0 +1,19 @@ +extern "C" void abort (void); + +main() +{ + int i = 0; + + #pragma omp parallel shared (i) + { + #pragma omp single + { + i++; + } + } + + if (i != 1) + abort (); + + return 0; +}
single-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: single-3.C =================================================================== --- single-3.C (nonexistent) +++ single-3.C (revision 338) @@ -0,0 +1,21 @@ +extern "C" void abort (void); + +void +single (int a, int b) +{ + #pragma omp single copyprivate(a) copyprivate(b) + { + a = b = 5; + } + + if (a != b) + abort (); +} + +int main() +{ + #pragma omp parallel + single (1, 2); + + return 0; +}
single-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-2.C =================================================================== --- for-2.C (nonexistent) +++ for-2.C (revision 338) @@ -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); +}
for-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-11.C =================================================================== --- ctor-11.C (nonexistent) +++ ctor-11.C (revision 338) @@ -0,0 +1,100 @@ +// PR c++/36308 +// { dg-do run } + +#include +#include + +#define N 10 + +struct B +{ + static int icount; + static int ccount; + static int dcount; + static int xcount; + + B (); + B (const B &); + virtual ~B (); + B& operator= (const B &); + void doit (); + static void clear () { icount = ccount = dcount = xcount = 0; } +}; + +int B::icount; +int B::ccount; +int B::dcount; +int B::xcount; + +B::B () +{ + #pragma omp atomic + icount++; +} + +B::B (const B &) +{ + #pragma omp atomic + ccount++; +} + +B::~B () +{ + #pragma omp atomic + dcount++; +} + +void +B::doit () +{ + #pragma omp atomic + xcount++; +} + +static int nthreads; + +void +test1 () +{ + B b[N]; + #pragma omp parallel private (b) + { + #pragma omp master + nthreads = omp_get_num_threads (); + b[0].doit (); + } +} + +void +test2 () +{ + B b; + #pragma omp parallel firstprivate (b) + { + #pragma omp single + nthreads = omp_get_num_threads (); + b.doit (); + } +} + +int +main () +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + + B::clear (); + test1 (); + assert (B::xcount == nthreads); + assert (B::ccount == 0); + assert (B::icount == (nthreads + 1) * N); + assert (B::dcount == (nthreads + 1) * N); + + B::clear (); + test2 (); + assert (B::xcount == nthreads); + assert (B::ccount == nthreads); + assert (B::icount == 1); + assert (B::dcount == nthreads + 1); + return 0; +}
ctor-11.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr27337.C =================================================================== --- pr27337.C (nonexistent) +++ pr27337.C (revision 338) @@ -0,0 +1,87 @@ +// PR middle-end/27337 +// { dg-do run } + +#include + +extern "C" void abort (void); + +struct S +{ + S (); + ~S (); + S (const S &); + int i; +}; + +int n[3]; + +S::S () : i(18) +{ + if (omp_get_thread_num () != 0) +#pragma omp atomic + n[0]++; +} + +S::~S () +{ + if (omp_get_thread_num () != 0) +#pragma omp atomic + n[1]++; +} + +S::S (const S &x) +{ + if (x.i != 18) + abort (); + i = 118; + if (omp_get_thread_num () != 0) +#pragma omp atomic + n[2]++; +} + +S +foo () +{ + int i; + S ret; + +#pragma omp parallel for firstprivate (ret) lastprivate (ret) \ + schedule (static, 1) num_threads (4) + for (i = 0; i < 4; i++) + ret.i += omp_get_thread_num (); + + return ret; +} + +S +bar () +{ + int i; + S ret; + +#pragma omp parallel for num_threads (4) + for (i = 0; i < 4; i++) +#pragma omp atomic + ret.i += omp_get_thread_num () + 1; + + return ret; +} + +S x; + +int +main (void) +{ + omp_set_dynamic (false); + x = foo (); + if (n[0] != 0 || n[1] != 3 || n[2] != 3) + abort (); + if (x.i != 118 + 3) + abort (); + x = bar (); + if (n[0] != 0 || n[1] != 3 || n[2] != 3) + abort (); + if (x.i != 18 + 0 + 1 + 2 + 3 + 4) + abort (); + return 0; +}
pr27337.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-4.C =================================================================== --- for-4.C (nonexistent) +++ for-4.C (revision 338) @@ -0,0 +1,225 @@ +// { dg-do run } + +#include +#include + +template +class J +{ +public: + typedef typename std::basic_string::iterator iterator; + J(const iterator &x, const iterator &y) : b (x), e (y) {} + const iterator &begin (); + const iterator &end (); +private: + iterator b, e; +}; + +template +const typename std::basic_string::iterator &J::begin () { return b; } +template +const typename std::basic_string::iterator &J::end () { return e; } + +template +void +baz (T &i) +{ + if (*i < L'a' || *i >= L'a' + 2000) + std::abort (); + (*i)++; +} + +void +f1 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ +#pragma omp parallel for + for (std::basic_string::iterator i = x; i <= y; i += 6) + baz (i); +} + +void +f2 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ + std::basic_string::iterator i; +#pragma omp parallel for private(i) + for (i = x; i < y - 1; i = 1 - 6 + 7 + i) + baz (i); +} + +template +void +f3 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ +#pragma omp parallel for schedule (dynamic, 6) + for (std::basic_string::iterator i = x; i <= y; i = i + 9 - 8) + baz (i); +} + +template +void +f4 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ + std::basic_string::iterator i; +#pragma omp parallel for lastprivate(i) + for (i = x + 2000 - 64; i > y + 10; --i) + baz (i); +} + +void +f5 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ +#pragma omp parallel for schedule (static, 10) + for (std::basic_string::iterator i = x + 2000 - 64; + i > y + 10; i -= 10) + baz (i); +} + +template +void +f6 (const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ +#pragma omp parallel for schedule (runtime) + for (std::basic_string::iterator i = x + 2000 - 64; + i > y + 10; i = i - 12 + 2) + { + std::basic_string::iterator j = i + N; + baz (j); + } +} + +template +void +f7 (std::basic_string::iterator i, + const std::basic_string::iterator &x, + const std::basic_string::iterator &y) +{ +#pragma omp parallel for schedule (dynamic, 6) + for (i = x - 10; i <= y + 10; i += N) + baz (i); +} + +template +void +f8 (J j) +{ + std::basic_string::iterator i; +#pragma omp parallel for schedule (dynamic, 40) + for (i = j.begin (); i <= j.end () + N; i += 2) + baz (i); +} + +template +void +f9 (const typename std::basic_string::iterator &x, + const typename std::basic_string::iterator &y) +{ +#pragma omp parallel for schedule (static, 25) + for (typename std::basic_string::iterator i = x; i <= y; i = i + N) + baz (i); +} + +template +void +f10 (const typename std::basic_string::iterator &x, + const typename std::basic_string::iterator &y) +{ + typename std::basic_string::iterator i; +#pragma omp parallel for + for (i = x; i > y; i = i + N) + baz (i); +} + +template +void +f11 (const T &x, const T &y) +{ +#pragma omp parallel + { +#pragma omp for nowait schedule (static, 2) + for (T i = x; i <= y; i += 3) + baz (i); +#pragma omp single + { + T j = y + 3; + baz (j); + } + } +} + +template +void +f12 (const T &x, const T &y) +{ + T i; +#pragma omp parallel for schedule (dynamic, 130) + for (i = x; i > y; --i) + baz (i); +} + +template +struct K +{ + template + static void + f13 (const T &x, const T &y) + { +#pragma omp parallel for schedule (runtime) + for (T i = x; i <= y + N; i += N) + baz (i); + } +}; + +#define check(expr) \ + for (int i = 0; i < 2000; i++) \ + if (expr) \ + { \ + if (a[i] != L'a' + i + 1) \ + std::abort (); \ + a[i] = L'a' + i; \ + } \ + else if (a[i] != L'a' + i) \ + std::abort () + +int +main () +{ + std::basic_string a = L""; + for (int i = 0; i < 2000; i++) + a += L'a' + i; + f1 (a.begin () + 10, a.begin () + 1990); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (a.begin () + 0, a.begin () + 1999); + check (i < 1998 && (i & 1) == 0); + f3 (a.begin () + 20, a.begin () + 1837); + check (i >= 20 && i <= 1837); + f4 (a.begin () + 0, a.begin () + 30); + check (i > 40 && i <= 2000 - 64); + f5 (a.begin () + 0, a.begin () + 100); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (a.begin () + 10, a.begin () + 110); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f7<6> (std::basic_string::iterator (), a.begin () + 12, + a.begin () + 1800); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + f8<121> (J (a.begin () + 14, a.begin () + 1803)); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9 (a.begin () + 33, a.begin () + 1967); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (a.begin () + 1939, a.begin () + 17); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11::iterator > (a.begin () + 16, + a.begin () + 1981); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12::iterator > (a.begin () + 1761, + a.begin () + 37); + check (i > 37 && i <= 1761); + K<5>::f13::iterator > (a.begin () + 1, + a.begin () + 1935); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); +}
for-4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: master-1.C =================================================================== --- master-1.C (nonexistent) +++ master-1.C (revision 338) @@ -0,0 +1,24 @@ +// PR c++/24734 +// { dg-do run } + +extern "C" void abort (); +int i; + +template void +foo () +{ + #pragma omp parallel + { + #pragma omp master + i++; + } +} + +int +main () +{ + foo<0> (); + if (i != 1) + abort (); + return 0; +}
master-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-6.C =================================================================== --- for-6.C (nonexistent) +++ for-6.C (revision 338) @@ -0,0 +1,109 @@ +// PR c++/38348 +// { dg-do run } + +extern "C" void abort (); +int cnt; + +template +void +f0 (T, int) +{ + abort (); +} + +template <> +void +f0 (int, int type) +{ + if (type != 0) + abort (); +#pragma omp atomic + cnt++; +} + +template <> +void +f0 (const char *, int type) +{ + if (type != 1) + abort (); +#pragma omp atomic + cnt++; +} + +template +void +f1 () +{ +#pragma omp parallel for + for (int i = 0; i < 10; i++) + f0 (i, 0); +} + +template +void +f2 () +{ +#pragma omp parallel for + for (T i = T (0); i < T (10); i += T (1)) + f0 (i, 0); +} + +void +f3 () +{ +#pragma omp parallel for + for (int i = 0; i < 10; i++) + f0 (i, 0); +} + +const char *p = "abcdefghij"; + +template +void +f4 () +{ +#pragma omp parallel for + for (const char *i = p; i < p + 10; i += 1) + f0 (i, 1); +} + +template +void +f5 () +{ +#pragma omp parallel for + for (T i = T (p); i < T (p + 10); i += 1) + f0 (i, 1); +} + +void +f6 () +{ +#pragma omp parallel for + for (const char *i = p; i < p + 10; i++) + f0 (i, 1); +} + +int +main () +{ + f1 (); + if (cnt != 10) + abort (); + f2 (); + if (cnt != 20) + abort (); + f3 (); + if (cnt != 30) + abort (); + f4 (); + if (cnt != 40) + abort (); + f5 (); + if (cnt != 50) + abort (); + f6 (); + if (cnt != 60) + abort (); +}
for-6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: reduction-1.C =================================================================== --- reduction-1.C (nonexistent) +++ reduction-1.C (revision 338) @@ -0,0 +1,36 @@ +#include +#include + +int +main (void) +{ + int i = 0, j = 0, k = ~0; + double d = 1.0; +#pragma omp parallel num_threads(4) reduction(+:i) reduction(*:d) reduction(&:k) + { + if (i != 0 || d != 1.0 || k != ~0) +#pragma omp atomic + j |= 1; + + if (omp_get_num_threads () != 4) +#pragma omp atomic + j |= 2; + + i = omp_get_thread_num (); + d = i + 1; + k = ~(1 << (2 * i)); + } + + if (j & 1) + abort (); + if ((j & 2) == 0) + { + if (i != (0 + 1 + 2 + 3)) + abort (); + if (d != (1.0 * 2.0 * 3.0 * 4.0)) + abort (); + if (k != (~0 ^ 0x55)) + abort (); + } + return 0; +}
reduction-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: parallel-1.C =================================================================== --- parallel-1.C (nonexistent) +++ parallel-1.C (revision 338) @@ -0,0 +1,40 @@ +#include + +extern "C" void abort (void); + +int +foo (void) +{ + return 10; +} + +main () +{ + int A = 0; + + #pragma omp parallel if (foo () > 10) shared (A) + { + A = omp_get_num_threads (); + } + + if (A != 1) + abort (); + + #pragma omp parallel if (foo () == 10) num_threads (3) shared (A) + { + A = omp_get_num_threads (); + } + + if (A != 3) + abort (); + + #pragma omp parallel if (foo () == 10) num_threads (foo ()) shared (A) + { + A = omp_get_num_threads (); + } + + if (A != 10) + abort (); + + return 0; +}
parallel-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-8.C =================================================================== --- for-8.C (nonexistent) +++ for-8.C (revision 338) @@ -0,0 +1,291 @@ +// { dg-do run } + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +extern "C" void abort (); + +template +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template friend bool operator == (I &, I &); + template friend bool operator == (const I &, const I &); + template friend bool operator < (I &, I &); + template friend bool operator < (const I &, const I &); + template friend bool operator <= (I &, I &); + template friend bool operator <= (const I &, const I &); + template friend bool operator > (I &, I &); + template friend bool operator > (const I &, const I &); + template friend bool operator >= (I &, I &); + template friend bool operator >= (const I &, const I &); + template friend typename I::difference_type operator - (I &, I &); + template friend typename I::difference_type operator - (const I &, const I &); + template friend I operator + (typename I::difference_type , const I &); +private: + T *p; +}; +template I::I () : p (0) {} +template I::~I () {} +template I::I (T *x) : p (x) {} +template I::I (const I &x) : p (x.p) {} +template T &I::operator * () { return *p; } +template T *I::operator -> () { return p; } +template T &I::operator [] (const difference_type &x) const { return p[x]; } +template I &I::operator = (const I &x) { p = x.p; return *this; } +template I &I::operator ++ () { ++p; return *this; } +template I I::operator ++ (int) { return I (p++); } +template I &I::operator -- () { --p; return *this; } +template I I::operator -- (int) { return I (p--); } +template I &I::operator += (const difference_type &x) { p += x; return *this; } +template I &I::operator -= (const difference_type &x) { p -= x; return *this; } +template I I::operator + (const difference_type &x) const { return I (p + x); } +template I I::operator - (const difference_type &x) const { return I (p - x); } +template bool operator == (I &x, I &y) { return x.p == y.p; } +template bool operator == (const I &x, const I &y) { return x.p == y.p; } +template bool operator != (I &x, I &y) { return !(x == y); } +template bool operator != (const I &x, const I &y) { return !(x == y); } +template bool operator < (I &x, I &y) { return x.p < y.p; } +template bool operator < (const I &x, const I &y) { return x.p < y.p; } +template bool operator <= (I &x, I &y) { return x.p <= y.p; } +template bool operator <= (const I &x, const I &y) { return x.p <= y.p; } +template bool operator > (I &x, I &y) { return x.p > y.p; } +template bool operator > (const I &x, const I &y) { return x.p > y.p; } +template bool operator >= (I &x, I &y) { return x.p >= y.p; } +template bool operator >= (const I &x, const I &y) { return x.p >= y.p; } +template typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; } +template typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; } +template I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); } + +template +class J +{ +public: + J(const I &x, const I &y) : b (x), e (y) {} + const I &begin (); + const I &end (); +private: + I b, e; +}; + +template const I &J::begin () { return b; } +template const I &J::end () { return e; } + +int results[2000]; + +template +void +baz (I &i) +{ + if (*i < 0 || *i >= 2000) + abort (); + results[*i]++; +} + +void +f1 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; y >= i; i += 6) + baz (i); +} + +void +f2 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for private(i) + for (i = x; y - 1 > i; i = 1 - 6 + 7 + i) + baz (i); +} + +template +void +f3 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; y >= i; i = i + 9 - 8) + baz (i); +} + +template +void +f4 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate(i) + for (i = x + 2000 - 64; y + 10 < i; --i) + baz (i); +} + +void +f5 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x + 2000 - 64; y + 10 < i; i -= 10) + baz (i); +} + +template +void +f6 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x + 2000 - 64; y + 10 < i; i = i - 12 + 2) + { + I j = i + N; + baz (j); + } +} + +template +void +f7 (I i, const I &x, const I &y) +{ +#pragma omp parallel for + for (i = x - 10; y + 10 >= i; i += N) + baz (i); +} + +template +void +f8 (J j) +{ + I i; +#pragma omp parallel for + for (i = j.begin (); j.end () + N >= i; i += 2) + baz (i); +} + +template +void +f9 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; y >= i; i = i + N) + baz (i); +} + +template +void +f10 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for + for (i = x; y < i; i = i + N) + baz (i); +} + +template +void +f11 (const T &x, const T &y) +{ +#pragma omp parallel + { +#pragma omp for nowait + for (T i = x; y >= i; i += 3) + baz (i); +#pragma omp single + { + T j = y + 3; + baz (j); + } + } +} + +template +void +f12 (const T &x, const T &y) +{ + T i; +#pragma omp parallel for + for (i = x; y < i; --i) + baz (i); +} + +template +struct K +{ + template + static void + f13 (const T &x, const T &y) + { +#pragma omp parallel for + for (T i = x; y + N >= i; i += N) + 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 () +{ + int a[2000]; + long b[2000]; + for (int i = 0; i < 2000; i++) + { + a[i] = i; + b[i] = i; + } + f1 (&a[10], &a[1990]); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (&a[0], &a[1999]); + check (i < 1998 && (i & 1) == 0); + f3 (&a[20], &a[1837]); + check (i >= 20 && i <= 1837); + f4 (&a[0], &a[30]); + check (i > 40 && i <= 2000 - 64); + f5 (&a[0], &a[100]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (&a[10], &a[110]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f7<6> (I (), &a[12], &a[1800]); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + f8<121> (J (&a[14], &a[1803])); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9 (&a[33], &a[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (&a[1939], &a[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11 > (&a[16], &a[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12 > (&a[1761], &a[37]); + check (i > 37 && i <= 1761); + K<5>::f13 > (&a[1], &a[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); + f9 (&b[33], &b[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (&b[1939], &b[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11 > (&b[16], &b[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12 > (&b[1761], &b[37]); + check (i > 37 && i <= 1761); + K<5>::f13 > (&b[1], &b[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); +}
for-8.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: reduction-3.C =================================================================== --- reduction-3.C (nonexistent) +++ reduction-3.C (revision 338) @@ -0,0 +1,51 @@ +#include +#include + +int +main (void) +{ + int i = 0, j = 0, k = ~0, l; + double d = 1.0; +#pragma omp parallel num_threads(4) + { +#pragma omp single + { + i = 16; + k ^= (1 << 16); + d += 32.0; + } + +#pragma omp for reduction(+:i) reduction(*:d) reduction(&:k) nowait + for (l = 0; l < 4; l++) + { + if (omp_get_num_threads () == 4 && (i != 0 || d != 1.0 || k != ~0)) +#pragma omp atomic + j |= 1; + + if (l == omp_get_thread_num ()) + { + i = omp_get_thread_num (); + d = i + 1; + k = ~(1 << (2 * i)); + } + } + + if (omp_get_num_threads () == 4) + { +#pragma omp barrier + if (i != (16 + 0 + 1 + 2 + 3)) +#pragma omp atomic + j |= 2; + if (d != (33.0 * 1.0 * 2.0 * 3.0 * 4.0)) +#pragma omp atomic + j |= 4; + if (k != (~0 ^ 0x55 ^ (1 << 16))) +#pragma omp atomic + j |= 8; + } + } + + if (j) + abort (); + return 0; +}
reduction-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr39573.C =================================================================== --- pr39573.C (nonexistent) +++ pr39573.C (revision 338) @@ -0,0 +1,39 @@ +// PR middle-end/39573 +// { dg-do run } + +int z; + +void __attribute__((noinline)) +bar (int *x) +{ + #pragma omp atomic + z += x[2]; + x[2] += x[3]; +} + +int +main () +{ + int i; +#pragma omp parallel for + for (i = 0; i < 65536; i++) + { + int x[] = + { + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, + }; + bar (x); + } +}
pr39573.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: collapse-1.C =================================================================== --- collapse-1.C (nonexistent) +++ collapse-1.C (revision 338) @@ -0,0 +1,29 @@ +// { dg-do run } + +#include +#include + +int +main () +{ + int i, j, k, l = 0; + int a[3][3][3]; + + memset (a, '\0', sizeof (a)); + #pragma omp parallel for collapse(4 - 1) schedule(static, 4) + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 2; k++) + a[i][j][k] = i + j * 4 + k * 16; + #pragma omp parallel + { + #pragma omp for collapse(2) reduction(|:l) private (k) + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 2; k++) + if (a[i][j][k] != i + j * 4 + k * 16) + l = 1; + } + if (l) + abort (); +}
collapse-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-2.C =================================================================== --- ctor-2.C (nonexistent) +++ ctor-2.C (revision 338) @@ -0,0 +1,76 @@ +// { dg-do run } + +#include +#include + +struct B +{ + static int ccount; + static int dcount; + static int xcount; + static B *expected; + + B(); + B(int); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +int B::ccount; +int B::dcount; +int B::xcount; +B * B::expected; + +B::B(int) +{ + expected = this; +} + +B::B(const B &b) +{ + #pragma omp atomic + ccount++; + assert (&b == expected); +} + +B::~B() +{ + #pragma omp atomic + dcount++; +} + +void B::doit() +{ + #pragma omp atomic + xcount++; + assert (this != expected); +} + +static int nthreads; + +void foo() +{ + B b(0); + + #pragma omp parallel firstprivate(b) + { + #pragma omp master + nthreads = omp_get_num_threads (); + b.doit(); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::xcount == nthreads); + assert (B::ccount == nthreads); + assert (B::dcount == nthreads+1); + + return 0; +}
ctor-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-4.C =================================================================== --- ctor-4.C (nonexistent) +++ ctor-4.C (revision 338) @@ -0,0 +1,90 @@ +// { dg-do run } + +#include +#include + +struct B +{ + static int ccount; + static int dcount; + static int ecount; + static B *e_inner; + static B *e_outer; + + B(); + B(int); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +int B::ccount; +int B::dcount; +int B::ecount; +B * B::e_inner; +B * B::e_outer; + +B::B(int) +{ + e_outer = this; +} + +B::B(const B &b) +{ + assert (&b == e_outer); + #pragma omp atomic + ccount++; +} + +B::~B() +{ + #pragma omp atomic + dcount++; +} + +B& B::operator= (const B &b) +{ + assert (&b == e_inner); + assert (this == e_outer); + #pragma omp atomic + ecount++; + return *this; +} + +void B::doit() +{ + #pragma omp critical + { + assert (e_inner == 0); + e_inner = this; + } +} + +static int nthreads; + +void foo() +{ + B b(0); + + #pragma omp parallel sections firstprivate(b) lastprivate(b) + { + #pragma omp section + nthreads = omp_get_num_threads (); + #pragma omp section + b.doit (); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::ecount == 1); + assert (B::ccount == nthreads); + assert (B::dcount == nthreads+1); + + return 0; +}
ctor-4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-6.C =================================================================== --- ctor-6.C (nonexistent) +++ ctor-6.C (revision 338) @@ -0,0 +1,50 @@ +// { dg-do run } + +#include +#include + +struct B +{ + static int count; + static B *expected; + + B& operator=(const B &); +}; + +int B::count; +B * B::expected; + +B& B::operator= (const B &b) +{ + assert (&b == expected); + assert (this != expected); + #pragma omp atomic + count++; + return *this; +} + +static int nthreads; + +void foo() +{ + #pragma omp parallel + { + B b; + #pragma omp single copyprivate(b) + { + nthreads = omp_get_num_threads (); + B::expected = &b; + } + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::count == nthreads-1); + + return 0; +}
ctor-6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-8.C =================================================================== --- ctor-8.C (nonexistent) +++ ctor-8.C (revision 338) @@ -0,0 +1,77 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include +#include + +#define N 10 +#define THR 4 + +struct B +{ + B(); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +static B *base; +static B *threadbase; +static unsigned cmask[THR]; +static unsigned dmask[THR]; + +#pragma omp threadprivate(threadbase) + +B::B() +{ + assert (base == 0); +} + +B::B(const B &b) +{ + unsigned index = &b - base; + assert (index < N); + cmask[omp_get_thread_num()] |= 1u << index; +} + +B::~B() +{ + if (threadbase) + { + unsigned index = this - threadbase; + assert (index < N); + dmask[omp_get_thread_num()] |= 1u << index; + } +} + +void foo() +{ + B b[N]; + + base = b; + + #pragma omp parallel firstprivate(b) + { + assert (omp_get_num_threads () == THR); + threadbase = b; + } + + threadbase = 0; +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (THR); + foo(); + + for (int i = 0; i < THR; ++i) + { + unsigned xmask = (1u << N) - 1; + assert (cmask[i] == xmask); + assert (dmask[i] == xmask); + } + + return 0; +}
ctor-8.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: nested-1.C =================================================================== --- nested-1.C (nonexistent) +++ nested-1.C (revision 338) @@ -0,0 +1,28 @@ +// { dg-do run } + +extern "C" void abort(void); +#define N 1000 + +int foo() +{ + int i = 0, j; + + #pragma omp parallel for num_threads(2) shared (i) + for (j = 0; j < N; ++j) + { + #pragma omp parallel num_threads(1) shared (i) + { + #pragma omp atomic + i++; + } + } + + return i; +} + +int main() +{ + if (foo() != N) + abort (); + return 0; +}
nested-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr34513.C =================================================================== --- pr34513.C (nonexistent) +++ pr34513.C (revision 338) @@ -0,0 +1,32 @@ +// PR c++/34513 +// { dg-do run } + +#include + +extern "C" void abort (); + +static int errors = 0; +static int thrs = 4; + +int +main () +{ + omp_set_dynamic (0); + + #pragma omp parallel num_threads (thrs) + { + static int shrd = 0; + + #pragma omp atomic + shrd += 1; + + #pragma omp barrier + + if (shrd != thrs) + #pragma omp atomic + errors += 1; + } + + if (errors) + abort (); +}
pr34513.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sections-1.C =================================================================== --- sections-1.C (nonexistent) +++ sections-1.C (revision 338) @@ -0,0 +1,64 @@ +/****************************************************************************** +* FILE: omp_workshare2.c +* DESCRIPTION: +* OpenMP Example - Sections Work-sharing - C/C++ Version +* In this example, the OpenMP SECTION directive is used to assign +* different array operations to threads that execute a SECTION. Each +* thread receives its own copy of the result array to work with. +* AUTHOR: Blaise Barney 5/99 +* LAST REVISED: 04/06/05 +******************************************************************************/ +#include +#include +#include +#define N 50 + +int main (int argc, char *argv[]) { + +int i, nthreads, tid; +float a[N], b[N], c[N]; + +/* Some initializations */ +for (i=0; i
sections-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-10.C =================================================================== --- loop-10.C (nonexistent) +++ loop-10.C (revision 338) @@ -0,0 +1,105 @@ +// { dg-do run } + +#include + +extern "C" void abort (void); + +#define LLONG_MAX __LONG_LONG_MAX__ +#define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +#define INT_MAX __INT_MAX__ + +int v; + +int +test1 (void) +{ + int e = 0, cnt = 0; + long long i; + unsigned long long j; + char buf[6], *p; + + #pragma omp for schedule(dynamic,1) collapse(2) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL) + if ((i != LLONG_MAX - 30001 + && i != LLONG_MAX - 20001 + && i != LLONG_MAX - 10001) + || j != 20) + e = 1; + else + cnt++; + if (e || cnt != 3) + abort (); + else + cnt = 0; + + #pragma omp for schedule(guided,1) collapse(2) nowait + for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000) + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + if ((i != -LLONG_MAX + 30000 + && i != -LLONG_MAX + 20000 + && i != -LLONG_MAX + 10000) + || j != ULLONG_MAX - 3) + e = 1; + else + cnt++; + if (e || cnt != 3) + abort (); + else + cnt = 0; + + #pragma omp for schedule(static,1) collapse(2) nowait + for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000) + for (j = 20; j <= LLONG_MAX - 70 + v; j += LLONG_MAX + 50ULL) + if ((i != LLONG_MAX - 30001 + && i != LLONG_MAX - 20001 + && i != LLONG_MAX - 10001) + || j != 20) + e = 1; + else + cnt++; + if (e || cnt != 3) + abort (); + else + cnt = 0; + + #pragma omp for schedule(static) collapse(2) nowait + for (i = -LLONG_MAX + 30000 + v; i >= -LLONG_MAX + 10000; i -= 10000) + for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL) + if ((i != -LLONG_MAX + 30000 + && i != -LLONG_MAX + 20000 + && i != -LLONG_MAX + 10000) + || j != ULLONG_MAX - 3) + e = 1; + else + cnt++; + if (e || cnt != 3) + abort (); + else + cnt = 0; + + #pragma omp for schedule(runtime) collapse(2) nowait + for (i = 10; i < 30; i++) + for (p = buf; p <= buf + 4; p += 2) + if (i < 10 || i >= 30 || (p != buf && p != buf + 2 && p != buf + 4)) + e = 1; + else + cnt++; + if (e || cnt != 60) + abort (); + else + cnt = 0; + + return 0; +} + +int +main (void) +{ + if (2 * sizeof (int) != sizeof (long long)) + return 0; + asm volatile ("" : "+r" (v)); + omp_set_schedule (omp_sched_dynamic, 1); + test1 (); + return 0; +}
loop-10.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-12.C =================================================================== --- loop-12.C (nonexistent) +++ loop-12.C (revision 338) @@ -0,0 +1,387 @@ +// { dg-do run } + +#include + +extern "C" void abort (); + +#define LLONG_MAX __LONG_LONG_MAX__ +#define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +#define INT_MAX __INT_MAX__ + +int arr[6 * 5]; + +void +set (int loopidx, int idx) +{ +#pragma omp atomic + arr[loopidx * 5 + idx]++; +} + +#define check(var, val, loopidx, idx) \ + if (var == (val)) set (loopidx, idx); else +#define test(loopidx, count) \ + for (idx = 0; idx < 5; idx++) \ + if (arr[loopidx * 5 + idx] != idx < count) \ + abort (); \ + else \ + arr[loopidx * 5 + idx] = 0 + +int +test1 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(dynamic,1) nowait + for (i = LLONG_MAX - 30001; LLONG_MAX - 10001 >= i; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (i = -LLONG_MAX + 30000; -LLONG_MAX + 10000 <= i; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = 20; LLONG_MAX - 70 >= j; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = ULLONG_MAX - 3; LLONG_MAX + 70ULL <= j; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (j = LLONG_MAX - 20000ULL; LLONG_MAX + 10000ULL >= j; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(dynamic,1) nowait + for (i = -3LL * INT_MAX - 20000LL; INT_MAX + 10000LL >= i; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test2 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(guided,1) nowait + for (i = LLONG_MAX - 30001; LLONG_MAX - 10001 >= i; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (i = -LLONG_MAX + 30000; -LLONG_MAX + 10000 <= i; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = 20; LLONG_MAX - 70 >= j; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = ULLONG_MAX - 3; LLONG_MAX + 70ULL <= j; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (j = LLONG_MAX - 20000ULL; LLONG_MAX + 10000ULL >= j; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(guided,1) nowait + for (i = -3LL * INT_MAX - 20000LL; INT_MAX + 10000LL >= i; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test3 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(static) nowait + for (i = LLONG_MAX - 30001; LLONG_MAX - 10001 >= i; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(static) nowait + for (i = -LLONG_MAX + 30000; -LLONG_MAX + 10000 <= i; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = 20; LLONG_MAX - 70 >= j; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = ULLONG_MAX - 3; LLONG_MAX + 70ULL <= j; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(static) nowait + for (j = LLONG_MAX - 20000ULL; LLONG_MAX + 10000ULL >= j; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(static) nowait + for (i = -3LL * INT_MAX - 20000LL; INT_MAX + 10000LL >= i; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test4 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(static,1) nowait + for (i = LLONG_MAX - 30001; LLONG_MAX - 10001 >= i; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (i = -LLONG_MAX + 30000; -LLONG_MAX + 10000 <= i; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = 20; LLONG_MAX - 70 >= j; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = ULLONG_MAX - 3; LLONG_MAX + 70ULL <= j; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (j = LLONG_MAX - 20000ULL; LLONG_MAX + 10000ULL >= j; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(static,1) nowait + for (i = -3LL * INT_MAX - 20000LL; INT_MAX + 10000LL >= i; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +test5 () +{ + int e = 0, idx; + +#pragma omp parallel reduction(+:e) + { + long long i; + unsigned long long j; + #pragma omp for schedule(runtime) nowait + for (i = LLONG_MAX - 30001; LLONG_MAX - 10001 >= i; i += 10000) + { + check (i, LLONG_MAX - 30001, 0, 0) + check (i, LLONG_MAX - 20001, 0, 1) + check (i, LLONG_MAX - 10001, 0, 2) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (i = -LLONG_MAX + 30000; -LLONG_MAX + 10000 <= i; i -= 10000) + { + check (i, -LLONG_MAX + 30000, 1, 0) + check (i, -LLONG_MAX + 20000, 1, 1) + check (i, -LLONG_MAX + 10000, 1, 2) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = 20; LLONG_MAX - 70 >= j; j += LLONG_MAX + 50ULL) + { + check (j, 20, 2, 0) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = ULLONG_MAX - 3; LLONG_MAX + 70ULL <= j; j -= LLONG_MAX + 50ULL) + { + check (j, ULLONG_MAX - 3, 3, 0) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (j = LLONG_MAX - 20000ULL; LLONG_MAX + 10000ULL >= j; j += 10000ULL) + { + check (j, LLONG_MAX - 20000ULL, 4, 0) + check (j, LLONG_MAX - 10000ULL, 4, 1) + check (j, LLONG_MAX, 4, 2) + check (j, LLONG_MAX + 10000ULL, 4, 3) + e = 1; + } + #pragma omp for schedule(runtime) nowait + for (i = -3LL * INT_MAX - 20000LL; INT_MAX + 10000LL >= i; i += INT_MAX + 200LL) + { + check (i, -3LL * INT_MAX - 20000LL, 5, 0) + check (i, -2LL * INT_MAX - 20000LL + 200LL, 5, 1) + check (i, -INT_MAX - 20000LL + 400LL, 5, 2) + check (i, -20000LL + 600LL, 5, 3) + check (i, INT_MAX - 20000LL + 800LL, 5, 4) + e = 1; + } + } + if (e) + abort (); + test (0, 3); + test (1, 3); + test (2, 1); + test (3, 1); + test (4, 4); + test (5, 5); + return 0; +} + +int +main () +{ + if (2 * sizeof (int) != sizeof (long long)) + return 0; + test1 (); + test2 (); + test3 (); + test4 (); + omp_set_schedule (omp_sched_static, 0); + test5 (); + omp_set_schedule (omp_sched_static, 3); + test5 (); + omp_set_schedule (omp_sched_dynamic, 5); + test5 (); + omp_set_schedule (omp_sched_guided, 2); + test5 (); + return 0; +}
loop-12.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr26691.C =================================================================== --- pr26691.C (nonexistent) +++ pr26691.C (revision 338) @@ -0,0 +1,20 @@ +// PR c++/26691 + +struct A +{ + int n; + A (int i = 3) : n (i) {} +}; + +int +main () +{ + A a; + int err = 0; +#pragma omp parallel private (a) reduction (+:err) + if (a.n != 3) + err++; + + return err; + } +
pr26691.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: copyin-2.C =================================================================== --- copyin-2.C (nonexistent) +++ copyin-2.C (revision 338) @@ -0,0 +1,34 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include + +extern "C" void abort (void); + +struct S { int t; char buf[64]; } thr = { 32, "" }; +#pragma omp threadprivate (thr) + +int +main (void) +{ + int l = 0; + + omp_set_dynamic (0); + omp_set_num_threads (6); + +#pragma omp parallel copyin (thr) reduction (||:l) + { + l = thr.t != 32; + thr.t = omp_get_thread_num () + 11; + } + + if (l || thr.t != 11) + abort (); + +#pragma omp parallel reduction (||:l) + l = thr.t != omp_get_thread_num () + 11; + + if (l) + abort (); + return 0; +}
copyin-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-2.C =================================================================== --- task-2.C (nonexistent) +++ task-2.C (revision 338) @@ -0,0 +1,70 @@ +// { dg-do run } + +#include +extern "C" void abort (); + +int l = 5; + +int +foo (int i) +{ + int j = 7; + const int k = 8; + #pragma omp task firstprivate (i) shared (j, l) + { + #pragma omp critical + { + j += i; + l += k; + } + } + i++; + #pragma omp task firstprivate (i) shared (j, l) + { + #pragma omp critical + { + j += i; + l += k; + } + } + i++; + #pragma omp task firstprivate (i) shared (j, l) + { + #pragma omp critical + { + j += i; + l += k; + } + } + i++; + #pragma omp task firstprivate (i) shared (j, l) + { + #pragma omp critical + { + j += i; + l += k; + } + } + i++; + #pragma omp taskwait + return (i != 8 * omp_get_thread_num () + 4 + || j != 4 * i - 3 + || k != 8); +} + +int +main (void) +{ + int r = 0; + #pragma omp parallel num_threads (4) reduction(+:r) + if (omp_get_num_threads () != 4) + { + #pragma omp master + l = 133; + } + else if (foo (8 * omp_get_thread_num ())) + r++; + if (r || l != 133) + abort (); + return 0; +}
task-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-4.C =================================================================== --- task-4.C (nonexistent) +++ task-4.C (revision 338) @@ -0,0 +1,37 @@ +#include +extern "C" void *memset (void *, int, __SIZE_TYPE__); +extern "C" void abort (void); + +int e; + +void +baz (int i, int *p, int j, int *q) +{ + if (p[0] != 1 || p[i] != 3 || q[0] != 2 || q[j] != 4) + #pragma omp atomic + e++; +} + +void +foo (int i, int j) +{ + int p[i + 1]; + int q[j + 1]; + memset (p, 0, sizeof (p)); + memset (q, 0, sizeof (q)); + p[0] = 1; + p[i] = 3; + q[0] = 2; + q[j] = 4; + #pragma omp task firstprivate (p, q) + baz (i, p, j, q); +} + +int +main () +{ + #pragma omp parallel num_threads (4) + foo (5 + omp_get_thread_num (), 7 + omp_get_thread_num ()); + if (e) + abort (); +}
task-4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: task-6.C =================================================================== --- task-6.C (nonexistent) +++ task-6.C (revision 338) @@ -0,0 +1,86 @@ +extern "C" void abort (); + +int a = 18; + +template +void +f1 (T i, T j, T k) +{ + T l = 6, m = 7, n = 8; +#pragma omp task private(j, m) shared(k, n) + { + j = 6; + m = 5; + if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9) + #pragma omp atomic + k++; + } +#pragma omp taskwait + if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9) + abort (); +} + +int v1 = 1, v2 = 2, v5 = 5; +int e; + +template +void +f2 (void) +{ + T v3 = 3; +#pragma omp sections private (v1) firstprivate (v2) + { + #pragma omp section + { + T v4 = 4; + v1 = 7; + #pragma omp task + { + if (++v1 != 8 || ++v2 != 3 || ++v3 != 4 || ++v4 != 5 || ++v5 != 6) + e = 1; + } + #pragma omp taskwait + if (v1 != 7 || v2 != 2 || v3 != 3 || v4 != 4 || v5 != 6) + abort (); + if (e) + abort (); + } + } +} + +template +void +f3 (T i, T j, T k) +{ + T l = 6, m = 7, n = 8; +#pragma omp task private(j, m) shared(k, n) untied + { + j = 6; + m = 5; + if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9) + #pragma omp atomic + k++; + } +#pragma omp taskwait + if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9) + abort (); +} + +int +main () +{ + f1 (8, 26, 0); + f2 (); + a = 18; + f3 (8, 26, 0); + a = 18; +#pragma omp parallel num_threads(4) + { + #pragma omp master + { + f1 (8, 26, 0); + a = 18; + f3 (8, 26, 0); + } + } +}
task-6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: shared-2.C =================================================================== --- shared-2.C (nonexistent) +++ shared-2.C (revision 338) @@ -0,0 +1,47 @@ +extern "C" void abort (void); + +void +parallel (int a, int b) +{ + int bad, LASTPRIV, LASTPRIV_SEC; + int i; + + a = b = 3; + + bad = 0; + + #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5) + { + if (a != 3 || b != 3) + bad = 1; + + #pragma omp for lastprivate (LASTPRIV) + for (i = 0; i < 10; i++) + LASTPRIV = i; + + #pragma omp sections lastprivate (LASTPRIV_SEC) + { + #pragma omp section + { LASTPRIV_SEC = 3; } + + #pragma omp section + { LASTPRIV_SEC = 42; } + } + + } + + if (LASTPRIV != 9) + abort (); + + if (LASTPRIV_SEC != 42) + abort (); + + if (bad) + abort (); +} + +int main() +{ + parallel (1, 2); + return 0; +}
shared-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-2.C =================================================================== --- loop-2.C (nonexistent) +++ loop-2.C (revision 338) @@ -0,0 +1,32 @@ +#include + +/* Orphaned work sharing. */ + +extern "C" void abort (void); + +#define N 10 + +void parloop (int *a) +{ + int i; + +#pragma omp for + for (i = 0; i < N; i++) + a[i] = i + 3; +} + +main() +{ + int i, a[N]; + +#pragma omp parallel shared(a) + { + parloop (a); + } + + for (i = 0; i < N; i++) + if (a[i] != i + 3) + abort (); + + return 0; +}
loop-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: atomic-1.C =================================================================== --- atomic-1.C (nonexistent) +++ atomic-1.C (revision 338) @@ -0,0 +1,53 @@ +// PR c++/33894 +// { dg-do run } +// { dg-options "-O2" } + +extern "C" void abort (); + +int check; + +template void +foo () +{ + #pragma omp atomic + check |= sizeof (T); +} + +template void +bar (T *x, T y) +{ + #pragma omp atomic + *x += y; +} + +template void +baz () +{ + #pragma omp atomic + check++; +} + +int +main () +{ + int i = 0; + long l = 0; + + check = 0; + foo (); + if (check != sizeof (char)) + abort (); + foo (); + if (check != (sizeof (char) | sizeof (short))) + abort (); + bar(&i, 4); + bar(&l, 8L); + if (i != 4 || l != 8L) + abort (); + baz (); + if (check != (sizeof (char) | sizeof (short)) + 1) + abort (); + baz (); + if (check != (sizeof (char) | sizeof (short)) + 2) + abort (); +}
atomic-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-4.C =================================================================== --- loop-4.C (nonexistent) +++ loop-4.C (revision 338) @@ -0,0 +1,20 @@ +extern "C" void abort (void); + +main() +{ + int i, a; + + a = 30; + +#pragma omp parallel for firstprivate (a) lastprivate (a) \ + num_threads (2) schedule(static) + for (i = 0; i < 10; i++) + a = a + i; + + /* The thread that owns the last iteration will have computed + 30 + 5 + 6 + 7 + 8 + 9 = 65. */ + if (a != 65) + abort (); + + return 0; +}
loop-4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-6.C =================================================================== --- loop-6.C (nonexistent) +++ loop-6.C (revision 338) @@ -0,0 +1,25 @@ +// { dg-do run } + +extern "C" void abort (void); + +volatile int count; +static int test(void) +{ + return ++count > 0; +} + +int i; + +int main() +{ + #pragma omp for lastprivate (i) + for (i = 0; i < 10; ++i) + { + if (test()) + continue; + abort (); + } + if (i != count) + abort (); + return 0; +}
loop-6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-8.C =================================================================== --- loop-8.C (nonexistent) +++ loop-8.C (revision 338) @@ -0,0 +1,276 @@ +#include +#include +#include + +int +test1 () +{ + short int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[10]; p < &buf[54]; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[3]; p <= &buf[63]; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[16]; p < &buf[51]; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[16]; p <= &buf[40]; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[53]; p > &buf[9]; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[63]; p >= &buf[3]; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[48]; p > &buf[15]; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[40]; p >= &buf[16]; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test2 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[10]; p < &buf[54]; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[3]; p <= &buf[63]; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[16]; p < &buf[51]; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[16]; p <= &buf[40]; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[53]; p > &buf[9]; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[63]; p >= &buf[3]; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[48]; p > &buf[15]; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[40]; p >= &buf[16]; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test3 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[10]; p < &buf[54]; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[3]; p <= &buf[63]; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[16]; p < &buf[51]; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[16]; p <= &buf[40]; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[53]; p > &buf[9]; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[63]; p >= &buf[3]; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[48]; p > &buf[15]; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[40]; p >= &buf[16]; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test4 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[10]; p < &buf[54]; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[3]; p <= &buf[63]; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[16]; p < &buf[51]; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[16]; p <= &buf[40]; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[53]; p > &buf[9]; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[63]; p >= &buf[3]; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[48]; p > &buf[15]; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[40]; p >= &buf[16]; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +main () +{ + test1 (); + test2 (); + test3 (); + omp_set_schedule (omp_sched_static, 0); + test4 (); + omp_set_schedule (omp_sched_static, 3); + test4 (); + omp_set_schedule (omp_sched_dynamic, 5); + test4 (); + omp_set_schedule (omp_sched_guided, 2); + test4 (); + return 0; +}
loop-8.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr30703.C =================================================================== --- pr30703.C (nonexistent) +++ pr30703.C (revision 338) @@ -0,0 +1,73 @@ +// PR c++/30703 +// { dg-do run } + +#include + +extern "C" void abort (); + +int ctor, cctor, dtor; + +struct A +{ + A(); + A(const A &); + ~A(); + int i; +}; + +A::A() +{ +#pragma omp atomic + ctor++; +} + +A::A(const A &r) +{ + i = r.i; +#pragma omp atomic + cctor++; +} + +A::~A() +{ +#pragma omp atomic + dtor++; +} + +void +foo (A a, A b) +{ + int i, j = 0; +#pragma omp parallel for firstprivate (a) lastprivate (a) private (b) schedule (static, 1) num_threads (5) + for (i = 0; i < 5; i++) + { + b.i = 5; + if (a.i != 6) + #pragma omp atomic + j += 1; + a.i = b.i + i + 6; + } + + if (j || a.i != 15) + abort (); +} + +void +bar () +{ + A a, b; + a.i = 6; + b.i = 7; + foo (a, b); +} + +int +main () +{ + omp_set_dynamic (false); + if (ctor || cctor || dtor) + abort (); + bar (); + if (ctor + cctor != dtor) + abort (); +}
pr30703.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: single-2.C =================================================================== --- single-2.C (nonexistent) +++ single-2.C (revision 338) @@ -0,0 +1,36 @@ +extern "C" void abort (void); + +struct X +{ + int a; + char b; + int c; +}; + +main() +{ + int i = 0; + struct X x; + int bad = 0; + + #pragma omp parallel private (i, x) shared (bad) + { + i = 5; + + #pragma omp single copyprivate (i, x) + { + i++; + x.a = 23; + x.b = 42; + x.c = 26; + } + + if (i != 6 || x.a != 23 || x.b != 42 || x.c != 26) + bad = 1; + } + + if (bad) + abort (); + + return 0; +}
single-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: c++.exp =================================================================== --- c++.exp (nonexistent) +++ c++.exp (revision 338) @@ -0,0 +1,60 @@ +load_lib libgomp-dg.exp + +global shlib_ext + +set shlib_ext [get_shlib_extension] +set lang_link_flags "-lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +# Initialize dg. +dg-init + +set blddir [lookfor_file [get_multilibs] libgomp] + + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libgomp.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + +if { $lang_test_file_found } { + # Gather a list of all tests. + set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] + + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Main loop. + gfortran-dg-runtest $tests $libstdcxx_includes +} + +# All done. +dg-finish Index: for-1.C =================================================================== --- for-1.C (nonexistent) +++ for-1.C (revision 338) @@ -0,0 +1,291 @@ +// { dg-do run } + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +extern "C" void abort (); + +template +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template friend bool operator == (I &, I &); + template friend bool operator == (const I &, const I &); + template friend bool operator < (I &, I &); + template friend bool operator < (const I &, const I &); + template friend bool operator <= (I &, I &); + template friend bool operator <= (const I &, const I &); + template friend bool operator > (I &, I &); + template friend bool operator > (const I &, const I &); + template friend bool operator >= (I &, I &); + template friend bool operator >= (const I &, const I &); + template friend typename I::difference_type operator - (I &, I &); + template friend typename I::difference_type operator - (const I &, const I &); + template friend I operator + (typename I::difference_type , const I &); +private: + T *p; +}; +template I::I () : p (0) {} +template I::~I () {} +template I::I (T *x) : p (x) {} +template I::I (const I &x) : p (x.p) {} +template T &I::operator * () { return *p; } +template T *I::operator -> () { return p; } +template T &I::operator [] (const difference_type &x) const { return p[x]; } +template I &I::operator = (const I &x) { p = x.p; return *this; } +template I &I::operator ++ () { ++p; return *this; } +template I I::operator ++ (int) { return I (p++); } +template I &I::operator -- () { --p; return *this; } +template I I::operator -- (int) { return I (p--); } +template I &I::operator += (const difference_type &x) { p += x; return *this; } +template I &I::operator -= (const difference_type &x) { p -= x; return *this; } +template I I::operator + (const difference_type &x) const { return I (p + x); } +template I I::operator - (const difference_type &x) const { return I (p - x); } +template bool operator == (I &x, I &y) { return x.p == y.p; } +template bool operator == (const I &x, const I &y) { return x.p == y.p; } +template bool operator != (I &x, I &y) { return !(x == y); } +template bool operator != (const I &x, const I &y) { return !(x == y); } +template bool operator < (I &x, I &y) { return x.p < y.p; } +template bool operator < (const I &x, const I &y) { return x.p < y.p; } +template bool operator <= (I &x, I &y) { return x.p <= y.p; } +template bool operator <= (const I &x, const I &y) { return x.p <= y.p; } +template bool operator > (I &x, I &y) { return x.p > y.p; } +template bool operator > (const I &x, const I &y) { return x.p > y.p; } +template bool operator >= (I &x, I &y) { return x.p >= y.p; } +template bool operator >= (const I &x, const I &y) { return x.p >= y.p; } +template typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; } +template typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; } +template I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); } + +template +class J +{ +public: + J(const I &x, const I &y) : b (x), e (y) {} + const I &begin (); + const I &end (); +private: + I b, e; +}; + +template const I &J::begin () { return b; } +template const I &J::end () { return e; } + +int results[2000]; + +template +void +baz (I &i) +{ + if (*i < 0 || *i >= 2000) + abort (); + results[*i]++; +} + +void +f1 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; i <= y; i += 6) + baz (i); +} + +void +f2 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for private(i) + for (i = x; i < y - 1; i = 1 - 6 + 7 + i) + baz (i); +} + +template +void +f3 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; i <= y; i = i + 9 - 8) + baz (i); +} + +template +void +f4 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate(i) + for (i = x + 2000 - 64; i > y + 10; --i) + baz (i); +} + +void +f5 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x + 2000 - 64; i > y + 10; i -= 10) + baz (i); +} + +template +void +f6 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x + 2000 - 64; i > y + 10; i = i - 12 + 2) + { + I j = i + N; + baz (j); + } +} + +template +void +f7 (I i, const I &x, const I &y) +{ +#pragma omp parallel for + for (i = x - 10; i <= y + 10; i += N) + baz (i); +} + +template +void +f8 (J j) +{ + I i; +#pragma omp parallel for + for (i = j.begin (); i <= j.end () + N; i += 2) + baz (i); +} + +template +void +f9 (const I &x, const I &y) +{ +#pragma omp parallel for + for (I i = x; i <= y; i = i + N) + baz (i); +} + +template +void +f10 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for + for (i = x; i > y; i = i + N) + baz (i); +} + +template +void +f11 (const T &x, const T &y) +{ +#pragma omp parallel + { +#pragma omp for nowait + for (T i = x; i <= y; i += 3) + baz (i); +#pragma omp single + { + T j = y + 3; + baz (j); + } + } +} + +template +void +f12 (const T &x, const T &y) +{ + T i; +#pragma omp parallel for + for (i = x; i > y; --i) + baz (i); +} + +template +struct K +{ + template + static void + f13 (const T &x, const T &y) + { +#pragma omp parallel for + for (T i = x; i <= y + N; i += N) + 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 () +{ + int a[2000]; + long b[2000]; + for (int i = 0; i < 2000; i++) + { + a[i] = i; + b[i] = i; + } + f1 (&a[10], &a[1990]); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (&a[0], &a[1999]); + check (i < 1998 && (i & 1) == 0); + f3 (&a[20], &a[1837]); + check (i >= 20 && i <= 1837); + f4 (&a[0], &a[30]); + check (i > 40 && i <= 2000 - 64); + f5 (&a[0], &a[100]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (&a[10], &a[110]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f7<6> (I (), &a[12], &a[1800]); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + f8<121> (J (&a[14], &a[1803])); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9 (&a[33], &a[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (&a[1939], &a[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11 > (&a[16], &a[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12 > (&a[1761], &a[37]); + check (i > 37 && i <= 1761); + K<5>::f13 > (&a[1], &a[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); + f9 (&b[33], &b[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (&b[1939], &b[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11 > (&b[16], &b[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12 > (&b[1761], &b[37]); + check (i > 37 && i <= 1761); + K<5>::f13 > (&b[1], &b[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); +}
for-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-10.C =================================================================== --- ctor-10.C (nonexistent) +++ ctor-10.C (revision 338) @@ -0,0 +1,78 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include +#include + +#define N 10 +#define THR 4 + +struct B +{ + B(); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); + static B *base; + static B *threadbase; +#pragma omp threadprivate(threadbase) +}; + +B *B::base; +B *B::threadbase; +static unsigned cmask[THR]; +static unsigned dmask[THR]; + +B::B() +{ + assert (base == 0); +} + +B::B(const B &b) +{ + unsigned index = &b - base; + assert (index < N); + cmask[omp_get_thread_num()] |= 1u << index; +} + +B::~B() +{ + if (threadbase) + { + unsigned index = this - threadbase; + assert (index < N); + dmask[omp_get_thread_num()] |= 1u << index; + } +} + +void foo() +{ + B b[N]; + + B::base = b; + + #pragma omp parallel firstprivate(b) + { + assert (omp_get_num_threads () == THR); + B::threadbase = b; + } + + B::threadbase = 0; +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (THR); + foo(); + + for (int i = 0; i < THR; ++i) + { + unsigned xmask = (1u << N) - 1; + assert (cmask[i] == xmask); + assert (dmask[i] == xmask); + } + + return 0; +}
ctor-10.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-3.C =================================================================== --- for-3.C (nonexistent) +++ for-3.C (revision 338) @@ -0,0 +1,239 @@ +// { dg-do run } + +#include +#include + +template +class J +{ +public: + typedef typename std::vector::const_iterator const_iterator; + J(const const_iterator &x, const const_iterator &y) : b (x), e (y) {} + const const_iterator &begin (); + const const_iterator &end (); +private: + const_iterator b, e; +}; + +template +const typename std::vector::const_iterator &J::begin () { return b; } +template +const typename std::vector::const_iterator &J::end () { return e; } + +int results[2000]; + +template +void +baz (T &i) +{ + if (*i < 0 || *i >= 2000) + std::abort (); + results[*i]++; +} + +void +f1 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ +#pragma omp parallel for + for (std::vector::const_iterator i = x; i <= y; i += 6) + baz (i); +} + +void +f2 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ + std::vector::const_iterator i; +#pragma omp parallel for private(i) + for (i = x; i < y - 1; i = 1 - 6 + 7 + i) + baz (i); +} + +template +void +f3 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ +#pragma omp parallel for schedule (dynamic, 6) + for (std::vector::const_iterator i = x; i <= y; i = i + 9 - 8) + baz (i); +} + +template +void +f4 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ + std::vector::const_iterator i; +#pragma omp parallel for lastprivate(i) + for (i = x + 2000 - 64; i > y + 10; --i) + baz (i); +} + +void +f5 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ +#pragma omp parallel for schedule (static, 10) + for (std::vector::const_iterator i = x + 2000 - 64; i > y + 10; i -= 10) + baz (i); +} + +template +void +f6 (const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ +#pragma omp parallel for schedule (runtime) + for (std::vector::const_iterator i = x + 2000 - 64; + i > y + 10; i = i - 12 + 2) + { + std::vector::const_iterator j = i + N; + baz (j); + } +} + +template +void +f7 (std::vector::const_iterator i, + const std::vector::const_iterator &x, + const std::vector::const_iterator &y) +{ +#pragma omp parallel for schedule (dynamic, 6) + for (i = x - 10; i <= y + 10; i += N) + baz (i); +} + +template +void +f8 (J j) +{ + std::vector::const_iterator i; +#pragma omp parallel for schedule (dynamic, 40) + for (i = j.begin (); i <= j.end () + N; i += 2) + baz (i); +} + +template +void +f9 (const typename std::vector::const_iterator &x, + const typename std::vector::const_iterator &y) +{ +#pragma omp parallel for schedule (static, 25) + for (typename std::vector::const_iterator i = x; i <= y; i = i + N) + baz (i); +} + +template +void +f10 (const typename std::vector::const_iterator &x, + const typename std::vector::const_iterator &y) +{ + typename std::vector::const_iterator i; +#pragma omp parallel for + for (i = x; i > y; i = i + N) + baz (i); +} + +template +void +f11 (const T &x, const T &y) +{ +#pragma omp parallel + { +#pragma omp for nowait schedule (static, 2) + for (T i = x; i <= y; i += 3) + baz (i); +#pragma omp single + { + T j = y + 3; + baz (j); + } + } +} + +template +void +f12 (const T &x, const T &y) +{ + T i; +#pragma omp parallel for schedule (dynamic, 130) + for (i = x; i > y; --i) + baz (i); +} + +template +struct K +{ + template + static void + f13 (const T &x, const T &y) + { +#pragma omp parallel for schedule (runtime) + for (T i = x; i <= y + N; i += N) + baz (i); + } +}; + +#define check(expr) \ + for (int i = 0; i < 2000; i++) \ + if (expr) \ + { \ + if (results[i] != 1) \ + std::abort (); \ + results[i] = 0; \ + } \ + else if (results[i]) \ + std::abort () + +int +main () +{ + std::vector a(2000); + std::vector b(2000); + for (int i = 0; i < 2000; i++) + { + a[i] = i; + b[i] = i; + } + f1 (a.begin () + 10, a.begin () + 1990); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (a.begin () + 0, a.begin () + 1999); + check (i < 1998 && (i & 1) == 0); + f3 (a.begin () + 20, a.begin () + 1837); + check (i >= 20 && i <= 1837); + f4 (a.begin () + 0, a.begin () + 30); + check (i > 40 && i <= 2000 - 64); + f5 (a.begin () + 0, a.begin () + 100); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (a.begin () + 10, a.begin () + 110); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f7<6> (std::vector::const_iterator (), a.begin () + 12, + a.begin () + 1800); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + f8<121> (J (a.begin () + 14, a.begin () + 1803)); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9 (a.begin () + 33, a.begin () + 1967); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (a.begin () + 1939, a.begin () + 17); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11::const_iterator > (a.begin () + 16, a.begin () + 1981); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12::const_iterator > (a.begin () + 1761, a.begin () + 37); + check (i > 37 && i <= 1761); + K<5>::f13::const_iterator > (a.begin () + 1, + a.begin () + 1935); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); + f9 (b.begin () + 33, b.begin () + 1967); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10 (b.begin () + 1939, b.begin () + 17); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11::const_iterator > (b.begin () + 16, b.begin () + 1981); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12::const_iterator > (b.begin () + 1761, b.begin () + 37); + check (i > 37 && i <= 1761); + K<5>::f13::const_iterator > (b.begin () + 1, + b.begin () + 1935); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); +}
for-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-12.C =================================================================== --- ctor-12.C (nonexistent) +++ ctor-12.C (revision 338) @@ -0,0 +1,65 @@ +// PR c++/36308 +// { dg-do run } + +extern "C" void abort (); + +static int n; + +struct A +{ + A () + { + l = 0; + #pragma omp atomic + ctors++; + } + A (const A &x) + { + l = x.l; + #pragma omp atomic + copyctors++; + } + virtual A& operator= (const A &x) + { + l = x.l; + #pragma omp atomic + assignops++; + return *this; + } + virtual ~A () + { + #pragma omp atomic + dtors++; + } + int l; + static int ctors, dtors, copyctors, assignops; +}; + +int A::ctors; +int A::dtors; +int A::copyctors; +int A::assignops; + +int +main () +{ + A a; +#pragma omp parallel private (a) + { + a.l = 6; + #pragma omp single copyprivate (a) + { + a.l = 3; + } + if (a.l != 3) + abort (); + #pragma omp atomic + n++; + } + if (A::ctors != n + 1 + || A::copyctors != 0 + || A::dtors != n + || A::assignops != n - 1) + abort (); + return 0; +}
ctor-12.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-5.C =================================================================== --- for-5.C (nonexistent) +++ for-5.C (revision 338) @@ -0,0 +1,303 @@ +// { dg-do run } + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +extern "C" void abort (); + +template +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template friend bool operator == (I &, I &); + template friend bool operator == (const I &, const I &); + template friend bool operator < (I &, I &); + template friend bool operator < (const I &, const I &); + template friend bool operator <= (I &, I &); + template friend bool operator <= (const I &, const I &); + template friend bool operator > (I &, I &); + template friend bool operator > (const I &, const I &); + template friend bool operator >= (I &, I &); + template friend bool operator >= (const I &, const I &); + template friend typename I::difference_type operator - (I &, I &); + template friend typename I::difference_type operator - (const I &, const I &); + template friend I operator + (typename I::difference_type , const I &); +private: + T *p; +}; +template I::I () : p (0) {} +template I::~I () { p = (T *) 0; } +template I::I (T *x) : p (x) {} +template I::I (const I &x) : p (x.p) {} +template T &I::operator * () { return *p; } +template T *I::operator -> () { return p; } +template T &I::operator [] (const difference_type &x) const { return p[x]; } +template I &I::operator = (const I &x) { p = x.p; return *this; } +template I &I::operator ++ () { ++p; return *this; } +template I I::operator ++ (int) { return I (p++); } +template I &I::operator -- () { --p; return *this; } +template I I::operator -- (int) { return I (p--); } +template I &I::operator += (const difference_type &x) { p += x; return *this; } +template I &I::operator -= (const difference_type &x) { p -= x; return *this; } +template I I::operator + (const difference_type &x) const { return I (p + x); } +template I I::operator - (const difference_type &x) const { return I (p - x); } +template bool operator == (I &x, I &y) { return x.p == y.p; } +template bool operator == (const I &x, const I &y) { return x.p == y.p; } +template bool operator != (I &x, I &y) { return !(x == y); } +template bool operator != (const I &x, const I &y) { return !(x == y); } +template bool operator < (I &x, I &y) { return x.p < y.p; } +template bool operator < (const I &x, const I &y) { return x.p < y.p; } +template bool operator <= (I &x, I &y) { return x.p <= y.p; } +template bool operator <= (const I &x, const I &y) { return x.p <= y.p; } +template bool operator > (I &x, I &y) { return x.p > y.p; } +template bool operator > (const I &x, const I &y) { return x.p > y.p; } +template bool operator >= (I &x, I &y) { return x.p >= y.p; } +template bool operator >= (const I &x, const I &y) { return x.p >= y.p; } +template typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; } +template typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; } +template I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); } + +template +class J +{ +public: + J(const I &x, const I &y) : b (x), e (y) {} + const I &begin (); + const I &end (); +private: + I b, e; +}; + +template const I &J::begin () { return b; } +template const I &J::end () { return e; } + +int results[2000]; + +template +void +baz (I &i) +{ + if (*i < 0 || *i >= 2000) + abort (); + results[*i]++; +} + +I +f1 (const I &x, const I &y) +{ + I i; +#pragma omp parallel shared (i) + { + #pragma omp for lastprivate (i) schedule(runtime) + for (i = x; i < y - 1; ++i) + baz (i); + #pragma omp single + i += 3; + } + return I (i); +} + +I +f2 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate (i) + for (i = x; i < y - 1; i = 1 - 6 + 7 + i) + baz (i); + return I (i); +} + +template +I +f3 (const I &x, const I &y) +{ + I i; +#pragma omp parallel + #pragma omp for lastprivate (i) + for (i = x + 1000 - 64; i <= y - 10; i++) + baz (i); + return i; +} + +template +I +f4 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate (i) + for (i = x + 2000 - 64; i > y + 10; --i) + baz (i); + return I (i); +} + +template +I +f5 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate (i) + for (i = x; i > y + T (6); i--) + baz (i); + return i; +} + +template +I +f6 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate (i) + for (i = x - T (7); i > y; i -= T (2)) + baz (i); + return I (i); +} + +template +I +f7 (I i, const I &x, const I &y) +{ +#pragma omp parallel for lastprivate (i) + for (i = x - 10; i <= y + 10; i += N) + baz (i); + return I (i); +} + +template +I +f8 (J j) +{ + I i; +#pragma omp parallel shared (i) + #pragma omp for lastprivate (i) + for (i = j.begin (); i <= j.end () + N; i += 2) + baz (i); + return i; +} + +I i9; + +template +I & +f9 (J j) +{ +#pragma omp parallel for lastprivate (i9) + for (i9 = j.begin () + N; i9 <= j.end () - N; i9 = i9 - N) + baz (i9); + return i9; +} + +template +I +f10 (const I &x, const I &y) +{ + I i; +#pragma omp parallel for lastprivate (i) + for (i = x; i > y; i = i + N) + baz (i); + return i; +} + +template +T +f11 (T i, const T &x, const T &y) +{ +#pragma omp parallel + #pragma omp for lastprivate (i) + for (i = x + U (2); i <= y + U (1); i = U (2) + U (3) + i) + baz (i); + return T (i); +} + +template +T +f12 (const T &x, const T &y) +{ + T i; +#pragma omp parallel for lastprivate (i) + for (i = x; i > y; --i) + baz (i); + return 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 () +{ + int a[2000]; + long b[2000]; + for (int i = 0; i < 2000; i++) + { + a[i] = i; + b[i] = i; + } + if (*f1 (&a[10], &a[1873]) != 1875) + abort (); + check (i >= 10 && i < 1872); + if (*f2 (&a[0], &a[1998]) != 1998) + abort (); + check (i < 1997 && (i & 1) == 0); + if (*f3 (&a[10], &a[1971]) != 1962) + abort (); + check (i >= 946 && i <= 1961); + if (*f4 (&a[0], &a[30]) != 40) + abort (); + check (i > 40 && i <= 2000 - 64); + if (*f5 (&a[1931], &a[17]) != 23) + abort (); + check (i > 23 && i <= 1931); + if (*f6 (&a[1931], &a[17]) != 16) + abort (); + check (i > 17 && i <= 1924 && (i & 1) == 0); + if (*f7<6> (I (), &a[12], &a[1800]) != 1814) + abort (); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + if (*f8<121> (J (&a[14], &a[1803])) != 1926) + abort (); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + if (*f9<-3L> (J (&a[27], &a[1761])) != 1767) + abort (); + check (i >= 24 && i <= 1764 && (i % 3) == 0); + if (*f10 (&a[1939], &a[17]) != 14) + abort (); + check (i >= 21 && i <= 1939 && i % 7 == 0); + if (*f11, short> (I (), &a[71], &a[1941]) != 1943) + abort (); + check (i >= 73 && i <= 1938 && (i - 73) % 5 == 0); + if (*f12 > (&a[1761], &a[37]) != 37) + abort (); + check (i > 37 && i <= 1761); + if (*f10 (&b[1939], &b[17]) != 14) + abort (); + check (i >= 21 && i <= 1939 && i % 7 == 0); + if (*f11, short> (I (), &b[71], &b[1941]) != 1943) + abort (); + check (i >= 73 && i <= 1938 && (i - 73) % 5 == 0); + if (*f12 > (&b[1761], &b[37]) != 37) + abort (); + check (i > 37 && i <= 1761); +}
for-5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr26943.C =================================================================== --- pr26943.C (nonexistent) +++ pr26943.C (revision 338) @@ -0,0 +1,62 @@ +// PR c++/26943 +// { dg-do run } + +#include +#include + +struct S +{ + public: + int x; + S () : x(-1) { } + S (const S &); + S& operator= (const S &); + void test (); +}; + +static volatile int hold; + +S::S (const S &s) +{ + #pragma omp master + sleep (1); + + assert (s.x == -1); + x = 0; +} + +S& +S::operator= (const S& s) +{ + assert (s.x == 1); + x = 2; + return *this; +} + +void +S::test () +{ + assert (x == 0); + x = 1; +} + +static S x; + +void +foo () +{ + #pragma omp sections firstprivate(x) lastprivate(x) + { + x.test(); + } +} + +int +main () +{ + #pragma omp parallel num_threads(2) + foo(); + + assert (x.x == 2); + return 0; +}
pr26943.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: for-7.C =================================================================== --- for-7.C (nonexistent) +++ for-7.C (revision 338) @@ -0,0 +1,110 @@ +// PR c++/ +// { dg-do run } +// { dg-options "-std=c++0x -fopenmp" } + +extern "C" void abort (); +int cnt; + +template +void +f0 (T, int) +{ + abort (); +} + +template <> +void +f0 (int, int type) +{ + if (type != 0) + abort (); +#pragma omp atomic + cnt++; +} + +template <> +void +f0 (const char *, int type) +{ + if (type != 1) + abort (); +#pragma omp atomic + cnt++; +} + +template +void +f1 () +{ +#pragma omp parallel for + for (auto i = 0; i < 10; i++) + f0 (i, 0); +} + +template +void +f2 () +{ +#pragma omp parallel for + for (auto i = T (0); i < T (10); i += T (1)) + f0 (i, 0); +} + +void +f3 () +{ +#pragma omp parallel for + for (auto i = 0; i < 10; i++) + f0 (i, 0); +} + +const char *p = "abcdefghij"; + +template +void +f4 () +{ +#pragma omp parallel for + for (auto i = p; i < p + 10; i++) + f0 (i, 1); +} + +template +void +f5 () +{ +#pragma omp parallel for + for (auto i = T (p); i < T (p + 10); i++) + f0 (i, 1); +} + +void +f6 () +{ +#pragma omp parallel for + for (auto i = p; i < p + 10; i++) + f0 (i, 1); +} + +int +main () +{ + f1 (); + if (cnt != 10) + abort (); + f2 (); + if (cnt != 20) + abort (); + f3 (); + if (cnt != 30) + abort (); + f4 (); + if (cnt != 40) + abort (); + f5 (); + if (cnt != 50) + abort (); + f6 (); + if (cnt != 60) + abort (); +}
for-7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: reduction-2.C =================================================================== --- reduction-2.C (nonexistent) +++ reduction-2.C (revision 338) @@ -0,0 +1,50 @@ +#include +#include + +int +main (void) +{ + int i = 0, j = 0, k = ~0, l; + double d = 1.0; +#pragma omp parallel num_threads(4) + { +#pragma omp single + { + i = 16; + k ^= (1 << 16); + d += 32.0; + } + +#pragma omp for reduction(+:i) reduction(*:d) reduction(&:k) + for (l = 0; l < 4; l++) + { + if (omp_get_num_threads () == 4 && (i != 0 || d != 1.0 || k != ~0)) +#pragma omp atomic + j |= 1; + + if (l == omp_get_thread_num ()) + { + i = omp_get_thread_num (); + d = i + 1; + k = ~(1 << (2 * i)); + } + } + + if (omp_get_num_threads () == 4) + { + if (i != (16 + 0 + 1 + 2 + 3)) +#pragma omp atomic + j |= 2; + if (d != (33.0 * 1.0 * 2.0 * 3.0 * 4.0)) +#pragma omp atomic + j |= 4; + if (k != (~0 ^ 0x55 ^ (1 << 16))) +#pragma omp atomic + j |= 8; + } + } + + if (j) + abort (); + return 0; +}
reduction-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr43893.C =================================================================== --- pr43893.C (nonexistent) +++ pr43893.C (revision 338) @@ -0,0 +1,125 @@ +// PR c/43893 +// { dg-do run } + +extern "C" void abort (); + +template +void +f1 () +{ + int c; + T i; + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = M; i < N; i++) + c++; + if (c != 1) + abort (); +} + +template +void +f2 () +{ + int c; + T i; + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = M; i <= N; i++) + c++; + if (c != 1) + abort (); +} + +template +void +f3 () +{ + int c; + T i; + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = M; i > N; i--) + c++; + if (c != 1) + abort (); +} + +template +void +f4 () +{ + int c; + T i; + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = M; i >= N; i--) + c++; + if (c != 1) + abort (); +} + +int +main () +{ + int c; + unsigned int i; + int j; + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = 0; i < 1; i++) + c++; + if (c != 1) + abort (); + f1 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = 0; i <= 0; i++) + c++; + if (c != 1) + abort (); + f2 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (j = - __INT_MAX__ - 1; j < - __INT_MAX__; j++) + c++; + if (c != 1) + abort (); + f1 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (j = - __INT_MAX__ - 1; j <= - __INT_MAX__ - 1; j++) + c++; + if (c != 1) + abort (); + f2 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = 2U * __INT_MAX__ + 1; i > 2U * __INT_MAX__; i--) + c++; + if (c != 1) + abort (); + f3 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (i = 2U * __INT_MAX__ + 1; i >= 2U * __INT_MAX__ + 1; i--) + c++; + if (c != 1) + abort (); + f4 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (j = __INT_MAX__; j > __INT_MAX__ - 1; j--) + c++; + if (c != 1) + abort (); + f3 (); + c = 0; +#pragma omp parallel for reduction(+:c) + for (j = __INT_MAX__; j >= __INT_MAX__; j--) + c++; + if (c != 1) + abort (); + f4 (); + return 0; +}
pr43893.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: collapse-2.C =================================================================== --- collapse-2.C (nonexistent) +++ collapse-2.C (revision 338) @@ -0,0 +1,371 @@ +// { dg-do run } + +#include +typedef __PTRDIFF_TYPE__ ptrdiff_t; +extern "C" void abort (); + +template +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template friend bool operator == (I &, I &); + template friend bool operator == (const I &, const I &); + template friend bool operator < (I &, I &); + template friend bool operator < (const I &, const I &); + template friend bool operator <= (I &, I &); + template friend bool operator <= (const I &, const I &); + template friend bool operator > (I &, I &); + template friend bool operator > (const I &, const I &); + template friend bool operator >= (I &, I &); + template friend bool operator >= (const I &, const I &); + template friend typename I::difference_type operator - (I &, I &); + template friend typename I::difference_type operator - (const I &, const I &); + template friend I operator + (typename I::difference_type , const I &); +private: + T *p; +}; +template I::I () : p (0) {} +template I::~I () { p = (T *) 0; } +template I::I (T *x) : p (x) {} +template I::I (const I &x) : p (x.p) {} +template T &I::operator * () { return *p; } +template T *I::operator -> () { return p; } +template T &I::operator [] (const difference_type &x) const { return p[x]; } +template I &I::operator = (const I &x) { p = x.p; return *this; } +template I &I::operator ++ () { ++p; return *this; } +template I I::operator ++ (int) { return I (p++); } +template I &I::operator -- () { --p; return *this; } +template I I::operator -- (int) { return I (p--); } +template I &I::operator += (const difference_type &x) { p += x; return *this; } +template I &I::operator -= (const difference_type &x) { p -= x; return *this; } +template I I::operator + (const difference_type &x) const { return I (p + x); } +template I I::operator - (const difference_type &x) const { return I (p - x); } +template bool operator == (I &x, I &y) { return x.p == y.p; } +template bool operator == (const I &x, const I &y) { return x.p == y.p; } +template bool operator != (I &x, I &y) { return !(x == y); } +template bool operator != (const I &x, const I &y) { return !(x == y); } +template bool operator < (I &x, I &y) { return x.p < y.p; } +template bool operator < (const I &x, const I &y) { return x.p < y.p; } +template bool operator <= (I &x, I &y) { return x.p <= y.p; } +template bool operator <= (const I &x, const I &y) { return x.p <= y.p; } +template bool operator > (I &x, I &y) { return x.p > y.p; } +template bool operator > (const I &x, const I &y) { return x.p > y.p; } +template bool operator >= (I &x, I &y) { return x.p >= y.p; } +template bool operator >= (const I &x, const I &y) { return x.p >= y.p; } +template typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; } +template typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; } +template I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); } + +template +class J +{ +public: + J(const I &x, const I &y) : b (x), e (y) {} + const I &begin (); + const I &end (); +private: + I b, e; +}; + +template const I &J::begin () { return b; } +template const I &J::end () { return e; } + +int results[2000]; + +void +f1 (J x, J y, J z) +{ + I i, j, k; + int l, f = 0, n = 0, m = 0; +#pragma omp parallel shared (i, j, k, l) firstprivate (f) \ + reduction (+:n, m) num_threads (8) + { + #pragma omp for lastprivate (i, j, k, l) schedule (static, 9) \ + collapse (4) + for (i = x.begin (); i < x.end (); ++i) + for (j = y.begin (); j <= y.end (); j += 1) + for (l = 0; l < 1; l++) + for (k = z.begin () + 3; k < z.end () - 3; k++) + if (omp_get_num_threads () == 8 + && ((*i + 2) * 12 + (*j + 5) * 4 + (*k - 13) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || i != x.end () || j != y.end () + 1 || k != z.end () - 3 + || m != 72 || l != 1) + abort (); +} + +void +f2 (J x, J y, J z) +{ + int f = 0, n = 0, m = 0; +#pragma omp parallel for firstprivate (f) reduction (+:n, m) \ + num_threads (8) schedule (static, 9) \ + collapse (6 - 2) + for (I i = x.end () - 1; i >= x.begin (); --i) + for (int l = -131; l >= -131; l--) + for (I j = y.end (); j > y.begin () - 1; j -= 1) + { + for (I k = z.end () - 4; k >= z.begin () + 3; k--) + if (omp_get_num_threads () == 8 + && ((3 - *i) * 12 + (-3 - *j) * 4 + (16 - *k) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || m != 72) + abort (); +} + +template +void +f3 (J x, J y, J z) +{ + I i, j, k; + int l, f = 0, n = 0, m = 0; +#pragma omp parallel shared (i, j, k, l) firstprivate (f) \ + reduction (+:n, m) num_threads (8) + { + #pragma omp for lastprivate (i, j, k, l) schedule (static, 9) \ + collapse (4) + for (i = x.begin (); i < x.end (); ++i) + for (j = y.begin (); j <= y.end (); j += 1) + for (k = z.begin () + 3; k < z.end () - 3; k++) + for (l = 7; l <= 7; l++) + if (omp_get_num_threads () == 8 + && ((*i + 2) * 12 + (*j + 5) * 4 + (*k - 13) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || i != x.end () || j != y.end () + 1 || k != z.end () - 3 + || m != 72 || l != 8) + abort (); +} + +template +void +f4 (J x, J y, J z) +{ + int f = 0, n = 0, m = 0; +#pragma omp parallel for firstprivate (f) reduction (+:n, m) \ + num_threads (8) schedule (static, 9) \ + collapse (5 - 2) + for (I i = x.end () - 1; i >= x.begin (); --i) + { + for (I j = y.end (); j > y.begin () - 1; j -= 1) + { + for (I k = z.end () - 4; k >= z.begin () + 3; k--) + if (omp_get_num_threads () == 8 + && ((3 - *i) * 12 + (-3 - *j) * 4 + (16 - *k) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + } + if (n || m != 72) + abort (); +} + +template +void +f5 (J x, J y, J z) +{ + I i, j, k; + int f = 0, n = 0, m = 0; +#pragma omp parallel shared (i, j, k) firstprivate (f) \ + reduction (+:n, m) num_threads (8) + { + #pragma omp for lastprivate (i, j, k) schedule (static, 9) \ + collapse (3) + for (i = x.begin (); i < x.end (); ++i) + for (j = y.begin (); j <= y.end (); j += (T) 1) + { + for (k = z.begin () + 3; k < z.end () - 3; k++) + if (omp_get_num_threads () == 8 + && ((*i + 2) * 12 + (*j + 5) * 4 + (*k - 13) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + } + if (n || i != x.end () || j != y.end () + 1 || k != z.end () - 3 + || m != 72) + abort (); +} + +template +void +f6 (J x, J y, J z) +{ + int f = 0, n = 0, m = 0; +#pragma omp parallel for firstprivate (f) reduction (+:n, m) \ + num_threads (8) schedule (static, 9) \ + collapse (5 - 2) + for (I i = x.end () - 1; i >= x.begin (); --i) + { + for (I j = y.end (); j > y.begin () - 1; j -= 1) + { + for (I k = z.end () - 4; k >= z.begin () + (T) 3; k--) + if (omp_get_num_threads () == 8 + && ((3 - *i) * 12 + (-3 - *j) * 4 + (16 - *k) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + } + if (n || m != 72) + abort (); +} + +template +void +f7 (J x, J y, J z) +{ + I i, j, k, o = y.begin (); + T l, f = 0, n = 0, m = 0; +#pragma omp parallel shared (i, j, k, l) firstprivate (f) \ + reduction (+:n, m) num_threads (8) + { + #pragma omp for lastprivate (i, j, k, l) schedule (static, 9) \ + collapse (4) + for (i = x.begin (); i < x.end (); ++i) + for (j = y.begin (); j <= y.end (); j += 1) + for (l = *o; l <= *o; l = 1 + l) + for (k = z.begin () + 3; k < z.end () - 3; k++) + if (omp_get_num_threads () == 8 + && ((*i + 2) * 12 + (*j + 5) * 4 + (*k - 13) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || i != x.end () || j != y.end () + 1 || k != z.end () - 3 + || m != 72 || l != *o + 1) + abort (); +} + +template +void +f8 (J x, J y, J z) +{ + T f = 0, n = 0, m = 0; +#pragma omp parallel for firstprivate (f) reduction (+:n, m) \ + num_threads (8) schedule (static, 9) \ + collapse (6 - 2) + for (I i = x.end () - 1; i >= x.begin (); --i) + for (T l = 0; l < 1; l++) + for (I j = y.end (); j > y.begin () - 1; j -= 1) + { + for (I k = z.end () - 4; k >= z.begin () + 3; k--) + if (omp_get_num_threads () == 8 + && ((3 - *i) * 12 + (-3 - *j) * 4 + (16 - *k) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || m != 72) + abort (); +} + +template +void +f9 (J x, J y, J z) +{ + S i, j, k, o = y.begin (); + T l, f = 0, n = 0, m = 0; +#pragma omp parallel shared (i, j, k, l) firstprivate (f) \ + reduction (+:n, m) num_threads (8) + { + #pragma omp for lastprivate (i, j, k, l) schedule (static, 9) \ + collapse (4) + for (i = x.begin (); i < x.end (); ++i) + for (j = y.begin (); j <= y.end (); j += 1) + for (l = *o; l <= *o; l = 1 + l) + for (k = z.begin () + 3; k < z.end () - 3; k++) + if (omp_get_num_threads () == 8 + && ((*i + 2) * 12 + (*j + 5) * 4 + (*k - 13) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || i != x.end () || j != y.end () + 1 || k != z.end () - 3 + || m != 72 || l != *o + 1) + abort (); +} + +template +void +f10 (J x, J y, J z) +{ + T f = 0, n = 0, m = 0; +#pragma omp parallel for firstprivate (f) reduction (+:n, m) \ + num_threads (8) schedule (static, 9) \ + collapse (6 - 2) + for (S i = x.end () - 1; i >= x.begin (); --i) + for (T l = 0; l < 1; l++) + for (S j = y.end (); j > y.begin () - 1; j -= 1) + { + for (S k = z.end () - 4; k >= z.begin () + 3; k--) + if (omp_get_num_threads () == 8 + && ((3 - *i) * 12 + (-3 - *j) * 4 + (16 - *k) + != (omp_get_thread_num () * 9 + f++))) + n++; + else + m++; + } + if (n || m != 72) + abort (); +} + +int +main () +{ + int a[2000]; + long b[2000]; + for (int i = 0; i < 2000; i++) + { + a[i] = i - 1000; + b[i] = i - 1000; + } + J x (&a[998], &a[1004]); + J y (&a[995], &a[997]); + J z (&a[1010], &a[1020]); + f1 (x, y, z); + f2 (x, y, z); + f3 (x, y, z); + f4 (x, y, z); + f5 (x, y, z); + f6 (x, y, z); + f7 (x, y, z); + f8 (x, y, z); + f9 , int> (x, y, z); + f10 , int> (x, y, z); +}
collapse-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-1.C =================================================================== --- ctor-1.C (nonexistent) +++ ctor-1.C (revision 338) @@ -0,0 +1,65 @@ +// { dg-do run } + +#include +#include + +struct B +{ + static int icount; + static int dcount; + static int xcount; + + B(); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +int B::icount; +int B::dcount; +int B::xcount; + +B::B() +{ + #pragma omp atomic + icount++; +} + +B::~B() +{ + #pragma omp atomic + dcount++; +} + +void B::doit() +{ + #pragma omp atomic + xcount++; +} + +static int nthreads; + +void foo() +{ + B b; + #pragma omp parallel private(b) + { + #pragma omp master + nthreads = omp_get_num_threads (); + b.doit(); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::xcount == nthreads); + assert (B::icount == nthreads+1); + assert (B::dcount == nthreads+1); + + return 0; +}
ctor-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-3.C =================================================================== --- ctor-3.C (nonexistent) +++ ctor-3.C (revision 338) @@ -0,0 +1,89 @@ +// { dg-do run } + +#include +#include + +struct B +{ + static int icount; + static int dcount; + static int ccount; + static B *e_inner; + static B *e_outer; + + B(); + B(int); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +int B::icount; +int B::dcount; +int B::ccount; +B * B::e_inner; +B * B::e_outer; + +B::B() +{ + #pragma omp atomic + icount++; +} + +B::B(int) +{ + e_outer = this; +} + +B::~B() +{ + #pragma omp atomic + dcount++; +} + +B& B::operator= (const B &b) +{ + assert (&b == e_inner); + assert (this == e_outer); + #pragma omp atomic + ccount++; + return *this; +} + +void B::doit() +{ + #pragma omp critical + { + assert (e_inner == 0); + e_inner = this; + } +} + +static int nthreads; + +void foo() +{ + B b(0); + + #pragma omp parallel sections lastprivate(b) + { + #pragma omp section + nthreads = omp_get_num_threads (); + #pragma omp section + b.doit (); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::ccount == 1); + assert (B::icount == nthreads); + assert (B::dcount == nthreads+1); + + return 0; +}
ctor-3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-5.C =================================================================== --- ctor-5.C (nonexistent) +++ ctor-5.C (revision 338) @@ -0,0 +1,52 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include +#include + +struct B +{ + static int count; + static B *expected; + + B& operator=(const B &); +}; + +int B::count; +B * B::expected; + +static B thr; +#pragma omp threadprivate(thr) + +B& B::operator= (const B &b) +{ + assert (&b == expected); + assert (this != expected); + #pragma omp atomic + count++; + return *this; +} + +static int nthreads; + +void foo() +{ + B::expected = &thr; + + #pragma omp parallel copyin(thr) + { + #pragma omp master + nthreads = omp_get_num_threads (); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::count == nthreads-1); + + return 0; +}
ctor-5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-7.C =================================================================== --- ctor-7.C (nonexistent) +++ ctor-7.C (revision 338) @@ -0,0 +1,67 @@ +// { dg-do run } + +#include +#include + +#define N 10 + +struct B +{ + static int icount; + static int dcount; + static int xcount; + + B(); + B(const B &); + ~B(); + B& operator=(const B &); + void doit(); +}; + +int B::icount; +int B::dcount; +int B::xcount; + +B::B() +{ + #pragma omp atomic + icount++; +} + +B::~B() +{ + #pragma omp atomic + dcount++; +} + +void B::doit() +{ + #pragma omp atomic + xcount++; +} + +static int nthreads; + +void foo() +{ + B b[N]; + #pragma omp parallel private(b) + { + #pragma omp master + nthreads = omp_get_num_threads (); + b[0].doit(); + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (4); + foo(); + + assert (B::xcount == nthreads); + assert (B::icount == (nthreads+1)*N); + assert (B::dcount == (nthreads+1)*N); + + return 0; +}
ctor-7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor-9.C =================================================================== --- ctor-9.C (nonexistent) +++ ctor-9.C (revision 338) @@ -0,0 +1,60 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include +#include + +#define N 10 +#define THR 4 + +struct B +{ + B& operator=(const B &); +}; + +static B *base; +static B *threadbase; +static int singlethread; +#pragma omp threadprivate(threadbase) + +static unsigned cmask[THR]; + +B& B::operator= (const B &b) +{ + unsigned sindex = &b - base; + unsigned tindex = this - threadbase; + assert(sindex < N); + assert(sindex == tindex); + cmask[omp_get_thread_num ()] |= 1u << tindex; + return *this; +} + +void foo() +{ + #pragma omp parallel + { + B b[N]; + threadbase = b; + #pragma omp single copyprivate(b) + { + assert(omp_get_num_threads () == THR); + singlethread = omp_get_thread_num (); + base = b; + } + } +} + +int main() +{ + omp_set_dynamic (0); + omp_set_num_threads (THR); + foo(); + + for (int i = 0; i < THR; ++i) + if (i == singlethread) + assert(cmask[singlethread] == 0); + else + assert(cmask[i] == (1u << N) - 1); + + return 0; +}
ctor-9.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr24455-1.C =================================================================== --- pr24455-1.C (nonexistent) +++ pr24455-1.C (revision 338) @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-require-effective-target tls } +extern int i; +#pragma omp threadprivate (i) + +int i;
pr24455-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr24455.C =================================================================== --- pr24455.C (nonexistent) +++ pr24455.C (revision 338) @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-additional-sources pr24455-1.C } +// { dg-require-effective-target tls_runtime } + +extern "C" void abort (void); + +extern int i; +#pragma omp threadprivate(i) + +int main() +{ + i = 0; + +#pragma omp parallel default(none) num_threads(10) copyin(i) + { + i++; +#pragma omp barrier + if (i != 1) + abort (); + } + + return 0; +}
pr24455.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr38650.C =================================================================== --- pr38650.C (nonexistent) +++ pr38650.C (revision 338) @@ -0,0 +1,49 @@ +// PR c++/38650 +// { dg-do run } + +#include + +int e; + +int +main () +{ + volatile int i, j = 10; + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < j; i += 1) + e++; + if (e != 10) + std::abort (); + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < j; ++i) + e++; + if (e != 10) + std::abort (); + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < j; i++) + e++; + if (e != 10) + std::abort (); + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < 10; i += 1) + e++; + if (e != 10) + std::abort (); + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < 10; ++i) + e++; + if (e != 10) + std::abort (); + e = 0; +#pragma omp parallel for reduction(+:e) + for (i = 0; i < 10; i++) + e++; + if (e != 10) + std::abort (); + return 0; +}
pr38650.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr35185.C =================================================================== --- pr35185.C (nonexistent) +++ pr35185.C (revision 338) @@ -0,0 +1,33 @@ +// PR middle-end/35185 +// { dg-do run } + +extern "C" void abort (); + +struct S +{ + S () : s (6) {} + ~S () {} + int s; +}; + +__attribute__((noinline)) +bool +bar (S s) +{ + return s.s != 6; +} + +int +main () +{ + S s; + int err = 0; +#pragma omp parallel shared (s) + { + if (bar (s)) + #pragma omp atomic + err++; + } + if (err) + abort (); +}
pr35185.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: loop-11.C =================================================================== --- loop-11.C (nonexistent) +++ loop-11.C (revision 338) @@ -0,0 +1,276 @@ +#include +#include +#include + +int +test1 () +{ + short int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[10]; &buf[54] > p; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[3]; &buf[63] >= p; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[16]; &buf[51] > p; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[53]; &buf[9] < p; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[63]; &buf[3] <= p; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[48]; &buf[15] < p; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for + for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test2 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[10]; &buf[54] > p; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[3]; &buf[63] >= p; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[16]; &buf[51] > p; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[53]; &buf[9] < p; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[63]; &buf[3] <= p; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[48]; &buf[15] < p; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (static, 3) + for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test3 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[10]; &buf[54] > p; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[3]; &buf[63] >= p; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[16]; &buf[51] > p; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[53]; &buf[9] < p; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[63]; &buf[3] <= p; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[48]; &buf[15] < p; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (dynamic, 3) + for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +test4 () +{ + int buf[64], *p; + int i; + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[10]; &buf[54] > p; p++) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[3]; &buf[63] >= p; p += 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[16]; &buf[51] > p; p = 4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[53]; &buf[9] < p; --p) + *p = 5; + for (i = 0; i < 64; i++) + if (buf[i] != 5 * (i >= 10 && i < 54)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[63]; &buf[3] <= p; p -= 2) + p[-2] = 6; + for (i = 0; i < 64; i++) + if (buf[i] != 6 * ((i & 1) && i <= 61)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[48]; &buf[15] < p; p = -4 + p) + p[2] = 7; + for (i = 0; i < 64; i++) + if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) + abort (); + memset (buf, '\0', sizeof (buf)); +#pragma omp parallel for schedule (runtime) + for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) + p[2] = -7; + for (i = 0; i < 64; i++) + if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) + abort (); + return 0; +} + +int +main () +{ + test1 (); + test2 (); + test3 (); + omp_set_schedule (omp_sched_static, 0); + test4 (); + omp_set_schedule (omp_sched_static, 3); + test4 (); + omp_set_schedule (omp_sched_dynamic, 5); + test4 (); + omp_set_schedule (omp_sched_guided, 2); + test4 (); + return 0; +}
loop-11.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.