(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
acc_map_data-device_already-1.c
       1  /* Verify that we refuse 'acc_map_data' when the "device address [...] is
       2     already mapped".  */
       3  
       4  /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
       5  
       6  #include <assert.h>
       7  #include <stdio.h>
       8  #include <stdlib.h>
       9  #include <openacc.h>
      10  
      11  int
      12  main ()
      13  {
      14    const int N = 131;
      15  
      16    char *h1 = (char *) malloc (N);
      17    assert (h1);
      18    void *d = acc_malloc (N);
      19    assert (d);
      20    acc_map_data (h1, d, N);
      21  
      22    char *h2 = (char *) malloc (N);
      23    assert (h2);
      24    /* Try to arrange a setting such that a later 'acc_unmap_data' would find the
      25       device memory object still referenced elsewhere.  This is not possible,
      26       given the semantics of 'acc_map_data'.  */
      27    fprintf (stderr, "CheCKpOInT\n");
      28    acc_map_data (h2, d, N);
      29  
      30    return 0;
      31  }
      32  
      33  
      34  /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
      35  /* { dg-output "device address \\\[\[0-9a-fA-FxX\]+, \\\+131\\\] is already mapped" } */
      36  /* { dg-shouldfail "" } */