(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
lib-60.c
       1  /* { dg-do run } */
       2  /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
       3  
       4  #include <string.h>
       5  #include <stdlib.h>
       6  #include <openacc.h>
       7  
       8  int
       9  main (int argc, char **argv)
      10  {
      11    const int N = 256;
      12    int i;
      13    unsigned char *h;
      14    void *d;
      15  
      16    h = (unsigned char *) malloc (N);
      17  
      18    for (i = 0; i < N; i++)
      19      {
      20        h[i] = i;
      21      }
      22  
      23    d = acc_malloc (N);
      24  
      25    acc_memcpy_to_device (d, h, N);
      26  
      27    for (i = 0; i < N; i++)
      28      {
      29        if (acc_is_present (h + i, 1) != 0)
      30  	abort ();
      31      }
      32  
      33    memset (&h[0], 0, N);
      34  
      35    acc_memcpy_from_device (h, d, N);
      36  
      37    for (i = 0; i < N; i++)
      38      {
      39        if (h[i] != i)
      40  	abort ();
      41      }
      42  
      43    for (i = 0; i < N; i++)
      44      {
      45        if (acc_is_present (h + i, 1) != 0)
      46  	abort ();
      47      }
      48  
      49    acc_free (d);
      50  
      51    free (h);
      52  
      53    return 0;
      54  }