1 /* acc_present_or_create, acc_present_or_copyin, etc. */
2 /* See also Fortran variants in "../libgomp.oacc-fortran/lib-32*". */
9 main (int argc
, char **argv
)
13 const int S
= N
* sizeof *h
;
16 h
= (int *) malloc (S
);
19 for (int i
= 0; i
< N
; ++i
)
22 shared_mem
= acc_is_present (h
, S
);
24 d
= (int *) acc_present_or_create (h
, S
);
30 if (!acc_is_present (h
, S
))
33 #pragma acc parallel loop deviceptr (d)
34 for (int i
= 0; i
< N
; ++i
)
39 for (int i
= 0; i
< N
; ++i
)
41 if (h
[i
] != i
+ (shared_mem
? 1 : 0))
47 int *d_
= (int *) acc_present_or_create (h
, S
);
52 #pragma acc parallel loop deviceptr (d)
53 for (int i
= 0; i
< N
; ++i
)
55 if (d
[i
] != i
+ (shared_mem
? 2 : 1))
60 for (int i
= 0; i
< N
; ++i
)
62 if (h
[i
] != i
+ (shared_mem
? 3 : 2))
68 int *d_
= (int *) acc_pcreate (h
, S
);
73 #pragma acc parallel loop deviceptr (d)
74 for (int i
= 0; i
< N
; ++i
)
76 if (d
[i
] != i
+ (shared_mem
? 4 : 3))
81 for (int i
= 0; i
< N
; ++i
)
83 if (h
[i
] != i
+ (shared_mem
? 5 : 4))
89 int *d_
= (int *) acc_present_or_copyin (h
, S
);
94 #pragma acc parallel loop deviceptr (d)
95 for (int i
= 0; i
< N
; ++i
)
97 if (d
[i
] != i
+ (shared_mem
? 6 : 5))
102 for (int i
= 0; i
< N
; ++i
)
104 if (h
[i
] != i
+ (shared_mem
? 7 : 6))
110 int *d_
= (int *) acc_pcopyin (h
, S
);
115 #pragma acc parallel loop deviceptr (d)
116 for (int i
= 0; i
< N
; ++i
)
118 if (d
[i
] != i
+ (shared_mem
? 8 : 7))
123 for (int i
= 0; i
< N
; ++i
)
125 if (h
[i
] != i
+ (shared_mem
? 9 : 8))
130 acc_copyout_finalize (h
, S
);
133 if (acc_is_present (h
, S
))
136 for (int i
= 0; i
< N
; ++i
)
138 if (h
[i
] != i
+ (shared_mem
? 10 : 9))
142 d
= (int *) acc_pcopyin (h
, S
);
148 if (!acc_is_present (h
, S
))
151 #pragma acc parallel loop deviceptr (d)
152 for (int i
= 0; i
< N
; ++i
)
154 if (d
[i
] != i
+ (shared_mem
? 10 : 9))
159 for (int i
= 0; i
< N
; ++i
)
161 if (h
[i
] != i
+ (shared_mem
? 11 : 9))
167 int *d_
= (int *) acc_pcopyin (h
, S
);
172 #pragma acc parallel loop deviceptr (d)
173 for (int i
= 0; i
< N
; ++i
)
175 if (d
[i
] != i
+ (shared_mem
? 12 : 11))
180 for (int i
= 0; i
< N
; ++i
)
182 if (h
[i
] != i
+ (shared_mem
? 13 : 12))
188 int *d_
= (int *) acc_pcreate (h
, S
);
193 #pragma acc parallel loop deviceptr (d)
194 for (int i
= 0; i
< N
; ++i
)
196 if (d
[i
] != i
+ (shared_mem
? 14 : 13))
201 for (int i
= 0; i
< N
; ++i
)
203 if (h
[i
] != i
+ (shared_mem
? 15 : 14))
209 int *d_
= (int *) acc_pcreate (h
, S
);
214 #pragma acc parallel loop deviceptr (d)
215 for (int i
= 0; i
< N
; ++i
)
217 if (d
[i
] != i
+ (shared_mem
? 16 : 15))
222 for (int i
= 0; i
< N
; ++i
)
224 if (h
[i
] != i
+ (shared_mem
? 17 : 16))
229 acc_update_self (h
, S
);
230 if (!acc_is_present (h
, S
))
233 for (int i
= 0; i
< N
; ++i
)
235 if (h
[i
] != i
+ (shared_mem
? 18 : 17))
239 acc_delete_finalize (h
, S
);
242 if (acc_is_present (h
, S
))