Improve atomic store implementation on hppa-linux.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / structured-dynamic-lifetimes-5.c
blob9807076d3f4ee9edec10e677e4e2f1c0a75f5933
1 /* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
3 #include <openacc.h>
4 #include <assert.h>
5 #include <stdlib.h>
7 #define SIZE 1024
9 int
10 main (int argc, char *argv[])
12 char *block1 = (char *) malloc (SIZE);
13 char *block2 = (char *) malloc (SIZE);
14 char *block3 = (char *) malloc (SIZE);
16 #ifdef OPENACC_API
17 acc_copyin (block1, SIZE);
18 #else
19 #pragma acc enter data copyin(block1[0:SIZE])
20 #endif
22 #pragma acc data copy(block1[0:SIZE], block2[0:SIZE], block3[0:SIZE])
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
33 assert (acc_is_present (block1, SIZE));
34 assert (acc_is_present (block2, SIZE));
35 assert (!acc_is_present (block3, SIZE));
37 #ifdef OPENACC_API
38 acc_copyout (block1, SIZE);
39 assert (!acc_is_present (block1, SIZE));
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));
47 #pragma acc exit data copyout(block2[0:SIZE])
48 assert (!acc_is_present (block2, SIZE));
49 #endif
51 free (block1);
52 free (block2);
53 free (block3);
55 return 0;