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
This commit is contained in:
parent
7d02047320
commit
6effebe10b
2 changed files with 55 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
2019-12-09 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* 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.
|
||||
|
||||
|
|
53
libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c
Normal file
53
libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c
Normal file
|
@ -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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <openacc.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Add table
Reference in a new issue