diff options
Diffstat (limited to 'gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++')
37 files changed, 1727 insertions, 0 deletions
diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/c++.exp b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/c++.exp new file mode 100644 index 000000000..d42dc8ccd --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/c++.exp @@ -0,0 +1,47 @@ +# APPLE LOCAL file mainline +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] + +# 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 +# APPLE LOCAL begin mainline candidate +# We may be testing an installed compiler, if $blddir is blank look for 'g++' +} elseif { $blddir == "" } { + verbose -log "Testing an installed compiler - you'd better have installed g++" + set GCC_UNDER_TEST [transform "g++"] + set lang_test_file_found 1 +# APPLE LOCAL end mainline candidate +} else { + puts "No libstdc++ library found, will not execute c++ tests" +} + +if { $lang_test_file_found } { + # Gather a list of all tests. + set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] + + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + set_ld_library_path_env_vars + + # Main loop. + gfortran-dg-runtest $tests "" +} + +# All done. +dg-finish diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/copyin-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/copyin-1.C new file mode 100644 index 000000000..bc12be2d2 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/copyin-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/copyin-2.C new file mode 100644 index 000000000..024f59980 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/copyin-2.C @@ -0,0 +1,34 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include <omp.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-1.C new file mode 100644 index 000000000..2ad3b3a6e --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-1.C @@ -0,0 +1,65 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-2.C new file mode 100644 index 000000000..6611c592f --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-2.C @@ -0,0 +1,76 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-3.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-3.C new file mode 100644 index 000000000..e65e4ea52 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-3.C @@ -0,0 +1,89 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-4.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-4.C new file mode 100644 index 000000000..e4f8f82db --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-4.C @@ -0,0 +1,90 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-5.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-5.C new file mode 100644 index 000000000..d99a1d462 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-5.C @@ -0,0 +1,52 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-6.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-6.C new file mode 100644 index 000000000..eab74e089 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-6.C @@ -0,0 +1,50 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-7.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-7.C new file mode 100644 index 000000000..3d669a707 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-7.C @@ -0,0 +1,67 @@ +// { dg-do run } + +#include <omp.h> +#include <assert.h> + +#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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-8.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-8.C new file mode 100644 index 000000000..5c0d81b73 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-8.C @@ -0,0 +1,77 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include <omp.h> +#include <assert.h> + +#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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-9.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-9.C new file mode 100644 index 000000000..215a901f8 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/ctor-9.C @@ -0,0 +1,60 @@ +// { dg-do run } +// { dg-require-effective-target tls_runtime } + +#include <omp.h> +#include <assert.h> + +#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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-1.C new file mode 100644 index 000000000..0e83c9583 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-1.C @@ -0,0 +1,96 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <omp.h> + +#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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-2.C new file mode 100644 index 000000000..ea3dc588a --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-2.C @@ -0,0 +1,32 @@ +#include <omp.h> + +/* 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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-3.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-3.C new file mode 100644 index 000000000..fa50f099f --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-3.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-4.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-4.C new file mode 100644 index 000000000..731f23450 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-4.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-5.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-5.C new file mode 100644 index 000000000..c427efa85 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-5.C @@ -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 (); +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-6.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-6.C new file mode 100644 index 000000000..fa26c6892 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-6.C @@ -0,0 +1,24 @@ +// { dg-do run } + +extern "C" void abort (void); + +volatile int count; +static int test(void) +{ + return ++count > 0; +} + +int main() +{ + int i; + #pragma omp for + for (i = 0; i < 10; ++i) + { + if (test()) + continue; + abort (); + } + if (i != count) + abort (); + return 0; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-7.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-7.C new file mode 100644 index 000000000..4eccb7fca --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/loop-7.C @@ -0,0 +1,22 @@ +// PR c++/24502 +// { dg-do run } + +extern "C" void abort (); + +template <typename T> 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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/master-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/master-1.C new file mode 100644 index 000000000..734b4e2cd --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/master-1.C @@ -0,0 +1,24 @@ +// PR c++/24734 +// { dg-do run } + +extern "C" void abort (); +int i; + +template<int> void +foo () +{ + #pragma omp parallel + { + #pragma omp master + i++; + } +} + +int +main () +{ + foo<0> (); + if (i != 1) + abort (); + return 0; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/nested-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/nested-1.C new file mode 100644 index 000000000..8d0e397bd --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/nested-1.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/parallel-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/parallel-1.C new file mode 100644 index 000000000..3c9314713 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/parallel-1.C @@ -0,0 +1,40 @@ +#include <omp.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455-1.C new file mode 100644 index 000000000..e7f38f8ab --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455-1.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-require-effective-target tls } +extern int i; +#pragma omp threadprivate (i) + +int i; diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455.C new file mode 100644 index 000000000..ad43b47b2 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr24455.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26691.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26691.C new file mode 100644 index 000000000..776b31e24 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26691.C @@ -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; + } + diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26943.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26943.C new file mode 100644 index 000000000..07b7b5dbf --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26943.C @@ -0,0 +1,62 @@ +// PR c++/26943 +// { dg-do run } + +#include <assert.h> +#include <unistd.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr27337.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr27337.C new file mode 100644 index 000000000..6db2465ec --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr27337.C @@ -0,0 +1,87 @@ +// PR middle-end/27337 +// { dg-do run } + +#include <omp.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr30703.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr30703.C new file mode 100644 index 000000000..d48efd952 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr30703.C @@ -0,0 +1,73 @@ +// PR c++/30703 +// { dg-do run } + +#include <omp.h> + +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 (); +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-1.C new file mode 100644 index 000000000..665163af0 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-1.C @@ -0,0 +1,36 @@ +#include <omp.h> +#include <stdlib.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-2.C new file mode 100644 index 000000000..52b3faff7 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-2.C @@ -0,0 +1,50 @@ +#include <omp.h> +#include <stdlib.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-3.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-3.C new file mode 100644 index 000000000..4f8f2fc12 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/reduction-3.C @@ -0,0 +1,51 @@ +#include <omp.h> +#include <stdlib.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/sections-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/sections-1.C new file mode 100644 index 000000000..32c93dbde --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/sections-1.C @@ -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 <omp.h> +#include <stdio.h> +#include <stdlib.h> +#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<N; i++) + a[i] = b[i] = i * 1.0; + +#pragma omp parallel shared(a,b,nthreads) private(c,i,tid) + { + tid = omp_get_thread_num(); + if (tid == 0) + { + nthreads = omp_get_num_threads(); + printf("Number of threads = %d\n", nthreads); + } + printf("Thread %d starting...\n",tid); + + #pragma omp sections nowait + { + #pragma omp section + { + printf("Thread %d doing section 1\n",tid); + for (i=0; i<N; i++) + { + c[i] = a[i] + b[i]; + printf("Thread %d: c[%d]= %f\n",tid,i,c[i]); + } + } + + #pragma omp section + { + printf("Thread %d doing section 2\n",tid); + for (i=0; i<N; i++) + { + c[i] = a[i] * b[i]; + printf("Thread %d: c[%d]= %f\n",tid,i,c[i]); + } + } + + } /* end of sections */ + + printf("Thread %d done.\n",tid); + + } /* end of parallel section */ + + return 0; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-1.C new file mode 100644 index 000000000..334a553ce --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-1.C @@ -0,0 +1,60 @@ +#include <omp.h> + +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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-2.C new file mode 100644 index 000000000..01855fbd4 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/shared-2.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-1.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-1.C new file mode 100644 index 000000000..e318a48ca --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-1.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-2.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-2.C new file mode 100644 index 000000000..c2dd22856 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-2.C @@ -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; +} diff --git a/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-3.C b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-3.C new file mode 100644 index 000000000..abc7f44b3 --- /dev/null +++ b/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/single-3.C @@ -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; +} |