(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
structured-dynamic-lifetimes-4.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    acc_copyin (block1, SIZE);
      19  #else
      20  #pragma acc enter data copyin(block1[0:SIZE])
      21  #pragma acc enter data copyin(block1[0:SIZE])
      22  #endif
      23  
      24  #pragma acc data copy(block1[0:SIZE], block2[0:SIZE], block3[0:SIZE])
      25    {
      26    /* The first copyin of block2 is the enclosing data region.  This
      27       "enter data" should make it live beyond the end of this region.  */
      28  #ifdef OPENACC_API
      29      acc_copyin (block2, SIZE);
      30  #else
      31  #pragma acc enter data copyin(block2[0:SIZE])
      32  #endif
      33    }
      34  
      35    assert (acc_is_present (block1, SIZE));
      36    assert (acc_is_present (block2, SIZE));
      37    assert (!acc_is_present (block3, SIZE));
      38  
      39  #ifdef OPENACC_API
      40    acc_copyout (block1, SIZE);
      41    assert (acc_is_present (block1, SIZE));
      42    acc_copyout (block1, SIZE);
      43    assert (!acc_is_present (block1, SIZE));
      44  
      45    acc_copyout (block2, SIZE);
      46    assert (!acc_is_present (block2, SIZE));
      47  #else
      48  #pragma acc exit data copyout(block1[0:SIZE])
      49    assert (acc_is_present (block1, SIZE));
      50  #pragma acc exit data copyout(block1[0:SIZE])
      51    assert (!acc_is_present (block1, SIZE));
      52  
      53  #pragma acc exit data copyout(block2[0:SIZE])
      54    assert (!acc_is_present (block2, SIZE));
      55  #endif
      56  
      57    free (block1);
      58    free (block2);
      59    free (block3);
      60  
      61    return 0;
      62  }