diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2018-01-09 11:57:00 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2021-07-27 11:16:26 +0200 |
commit | 88c40c36db8a52d2c630aa61ee54e33908e9daec (patch) | |
tree | 47d0f46eed29f9657c347b82bb9429d8dbd8fbb0 | |
parent | 29ddaf43f70e19fd1110b539e8b3d0436c757e34 (diff) | |
download | gcc-88c40c36db8a52d2c630aa61ee54e33908e9daec.zip gcc-88c40c36db8a52d2c630aa61ee54e33908e9daec.tar.gz gcc-88c40c36db8a52d2c630aa61ee54e33908e9daec.tar.bz2 |
Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c'
libgomp/
* testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c: New file.
* testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c: Likewise.
Co-Authored-By: Tom de Vries <tom@codesourcery.com>
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c | 90 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c | 100 |
2 files changed, 190 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c new file mode 100644 index 0000000..cd87aec --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c @@ -0,0 +1,90 @@ +/* Verify back to back 'async' operations, one data mapping. + + Due to one data mapping, this isn't using the libgomp 'cbuf' buffering. +*/ + +/* { dg-xfail-run-if "TODO" { openacc_radeon_accel_selected } } */ + + +#include <stdlib.h> + + +#define N 128 + + +static void +t1 (void) +{ + unsigned int *a; + int i; + int nbytes; + + nbytes = N * sizeof (unsigned int); + + a = (unsigned int *) malloc (nbytes); + + for (i = 0; i < N; i++) + a[i] = 3; + +#pragma acc parallel async copy (a[0:N]) + for (int ii = 0; ii < N; ii++) + a[ii] += 1; + +#pragma acc parallel async copy (a[0:N]) + for (int ii = 0; ii < N; ii++) + a[ii] += 1; + +#pragma acc wait + + for (i = 0; i < N; i++) + if (a[i] != 5) + abort (); +} + + +static void +t2 (void) +{ + unsigned int *a; + int i; + int nbytes; + + nbytes = N * sizeof (unsigned int); + + a = (unsigned int *) malloc (nbytes); + +#pragma acc data copyin (a[0:N]) + { + for (i = 0; i < N; i++) + a[i] = 3; + +#pragma acc update async device (a[0:N]) +#pragma acc parallel async present (a[0:N]) + for (int ii = 0; ii < N; ii++) + a[ii] += 1; +#pragma acc update async host (a[0:N]) + +#pragma acc update async device (a[0:N]) +#pragma acc parallel async present (a[0:N]) + for (int ii = 0; ii < N; ii++) + a[ii] += 1; +#pragma acc update async host (a[0:N]) + +#pragma acc wait + } + + for (i = 0; i < N; i++) + if (a[i] != 5) + abort (); +} + + +int +main (void) +{ + t1 (); + + t2 (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c new file mode 100644 index 0000000..3852376 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c @@ -0,0 +1,100 @@ +/* Verify back to back 'async' operations, two data mappings. + + Due to two data mappings, this is using the libgomp 'cbuf' buffering. +*/ + +/* { dg-xfail-run-if "TODO" { openacc_radeon_accel_selected } } */ + + +#include <stdlib.h> + + +#define N 128 + + +static void +t1 (void) +{ + unsigned int *a, *b; + int i; + int nbytes; + + nbytes = N * sizeof (unsigned int); + + a = (unsigned int *) malloc (nbytes); + b = (unsigned int *) malloc (nbytes); + + for (i = 0; i < N; i++) + b[i] = a[i] = 3; + +#pragma acc parallel async copy (a[0:N], b[0:N]) + for (int ii = 0; ii < N; ii++) + b[ii] += (a[ii] += 1); + +#pragma acc parallel async copy (a[0:N], b[0:N]) + for (int ii = 0; ii < N; ii++) + b[ii] += (a[ii] += 1); + +#pragma acc wait + + for (i = 0; i < N; i++) + { + if (a[i] != 5) + abort (); + if (b[i] != 12) + abort (); + } +} + + +static void +t2 (void) +{ + unsigned int *a, *b; + int i; + int nbytes; + + nbytes = N * sizeof (unsigned int); + + a = (unsigned int *) malloc (nbytes); + b = (unsigned int *) malloc (nbytes); + +#pragma acc data copyin (a[0:N], b[0:N]) + { + for (i = 0; i < N; i++) + b[i] = a[i] = 3; + +#pragma acc update async device (a[0:N], b[0:N]) +#pragma acc parallel async present (a[0:N], b[0:N]) + for (int ii = 0; ii < N; ii++) + b[ii] += (a[ii] += 1); +#pragma acc update async host (a[0:N], b[0:N]) + +#pragma acc update async device (a[0:N], b[0:N]) +#pragma acc parallel async present (a[0:N], b[0:N]) + for (int ii = 0; ii < N; ii++) + b[ii] += (a[ii] += 1); +#pragma acc update async host (a[0:N], b[0:N]) + +#pragma acc wait + } + + for (i = 0; i < N; i++) + { + if (a[i] != 5) + abort (); + if (b[i] != 12) + abort (); + } +} + + +int +main (void) +{ + t1 (); + + t2 (); + + return 0; +} |