(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
structured-dynamic-lifetimes-5.c
       1  /* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
       2  
       3  #include <openacc.h>
       4  #include <assert.h>
       5  #include <stdlib.h>
       6  
       7  #define SIZE 1024
       8  
       9  int
      10  main (int argc, char *argv[])
      11  {
      12    char *block1 = (char *) malloc (SIZE);
      13    char *block2 = (char *) malloc (SIZE);
      14    char *block3 = (char *) malloc (SIZE);
      15  
      16  #ifdef OPENACC_API
      17    acc_copyin (block1, SIZE);
      18  #else
      19  #pragma acc enter data copyin(block1[0:SIZE])
      20  #endif
      21  
      22  #pragma acc data copy(block1[0:SIZE], block2[0:SIZE], block3[0:SIZE])
      23    {
      24    /* The first copyin of block2 is the enclosing data region.  This
      25       "enter data" should make it live beyond the end of this region.  */
      26  #ifdef OPENACC_API
      27      acc_copyin (block2, SIZE);
      28  #else
      29  #pragma acc enter data copyin(block2[0:SIZE])
      30  #endif
      31    }
      32  
      33    assert (acc_is_present (block1, SIZE));
      34    assert (acc_is_present (block2, SIZE));
      35    assert (!acc_is_present (block3, SIZE));
      36  
      37  #ifdef OPENACC_API
      38    acc_copyout (block1, SIZE);
      39    assert (!acc_is_present (block1, SIZE));
      40  
      41    acc_copyout (block2, SIZE);
      42    assert (!acc_is_present (block2, SIZE));
      43  #else
      44  #pragma acc exit data copyout(block1[0:SIZE])
      45    assert (!acc_is_present (block1, SIZE));
      46  
      47  #pragma acc exit data copyout(block2[0:SIZE])
      48    assert (!acc_is_present (block2, SIZE));
      49  #endif
      50  
      51    free (block1);
      52    free (block2);
      53    free (block3);
      54  
      55    return 0;
      56  }