From: Thomas Schwinge Date: Mon, 9 Dec 2019 11:40:27 +0000 (+0100) Subject: Add 'libgomp.oacc-c-c++-common/map-data-1.c' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6effebe10be2c53472db9eb573cdeeac312036c1;p=gcc.git Add 'libgomp.oacc-c-c++-common/map-data-1.c' libgomp/ * testsuite/libgomp.oacc-c-c++-common/map-data-1.c: New file. From-SVN: r279121 --- diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index aac3b1887b0..51a00a3a46c 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,7 @@ 2019-12-09 Thomas Schwinge + * testsuite/libgomp.oacc-c-c++-common/map-data-1.c: New file. + PR libgomp/92854 * testsuite/libgomp.oacc-c-c++-common/pr92854-1.c: New file. diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c new file mode 100644 index 00000000000..d0781dd7f56 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c @@ -0,0 +1,53 @@ +/* Verify that 'acc_map_data' does not copy data to, and 'acc_unmap_data' does + not copy data from the device. */ + +/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */ + +#include +#include +#include + +int +main () +{ + const int c0 = 9; + const int c1 = 40; + const int c2 = 47; + + const size_t N = 256; + + unsigned char *h = (unsigned char *) malloc (N); + + void *d = acc_malloc (N); + + memset (h, c0, N); // H <- c0 + acc_memcpy_to_device (d, h, N); // D <- H = c0 + + memset (h, c1, N); // H <- c1 + acc_map_data (h, d, N); + for (size_t i = 0; i < N; ++i) + if (h[i] != c1) + abort (); + + acc_memcpy_from_device (h, d, N); // H <- D = c0 + for (size_t i = 0; i < N; ++i) + if (h[i] != c0) + abort (); + + memset (h, c2, N); // H <- c2 + acc_unmap_data (h); + for (size_t i = 0; i < N; ++i) + if (h[i] != c2) + abort (); + + acc_memcpy_from_device (h, d, N); // H <- D = c0 + for (size_t i = 0; i < N; ++i) + if (h[i] != c0) + abort (); + + acc_free (d); + + free (h); + + return 0; +}