diff options
Diffstat (limited to 'libgomp/testsuite/libgomp.c++')
-rw-r--r-- | libgomp/testsuite/libgomp.c++/c++.exp | 2 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C | 62 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C | 43 |
3 files changed, 106 insertions, 1 deletions
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp index a9cf41aba4b..da42e6213b0 100644 --- a/libgomp/testsuite/libgomp.c++/c++.exp +++ b/libgomp/testsuite/libgomp.c++/c++.exp @@ -42,7 +42,7 @@ if { $blddir != "" } { if { $lang_test_file_found } { # Gather a list of all tests. - set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] + set tests [lsort [find $srcdir/$subdir *.C]] if { $blddir != "" } { set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C b/libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C new file mode 100644 index 00000000000..4298e234217 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C @@ -0,0 +1,62 @@ +// { dg-do run } + +#include <omp.h> + +#define EPS 0.000001 +#define N 1000 + +extern "C" void abort (void); + +void init (float *a1, float *a2, int n) +{ + int s = -1; + for (int i = 0; i < n; i++) + { + a1[i] = s * 0.01; + a2[i] = i; + s = -s; + } +} + +void check (float *a, float *b, int n) +{ + for (int i = 0; i < n; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +void vec_mult_ref (float *&p, float *&v1, float *&v2, int n) +{ + for (int i = 0; i < n; i++) + p[i] = v1[i] * v2[i]; +} + +void vec_mult (float *&p, float *&v1, float *&v2, int n) +{ + #pragma omp target map(to: v1[0:n], v2[:n]) map(from: p[0:n]) + #pragma omp parallel for + for (int i = 0; i < n; i++) + p[i] = v1[i] * v2[i]; +} + +int main () +{ + float *p = new float [N]; + float *p1 = new float [N]; + float *v1 = new float [N]; + float *v2 = new float [N]; + + init (v1, v2, N); + + vec_mult_ref (p, v1, v2, N); + vec_mult (p1, v1, v2, N); + + check (p, p1, N); + + delete [] p; + delete [] p1; + delete [] v1; + delete [] v2; + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C b/libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C new file mode 100644 index 00000000000..75276e7c5c6 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C @@ -0,0 +1,43 @@ +// { dg-do run } +// { dg-require-effective-target offload_device } + +#include <stdlib.h> + +struct typeX +{ + int a; +}; + +class typeY +{ +public: + int foo () { return a^0x01; } + int a; +}; + +#pragma omp declare target +struct typeX varX; +class typeY varY; +#pragma omp end declare target + +int main () +{ + varX.a = 0; + varY.a = 0; + + #pragma omp target + { + varX.a = 100; + varY.a = 100; + } + + if (varX.a != 0 || varY.a != 0) + abort (); + + #pragma omp target update from(varX, varY) + + if (varX.a != 100 || varY.a != 100) + abort (); + + return 0; +} |