1 /* Test behavior of 'firstprivate' lexically vs. dynamically nested inside a
14 /* This is basically and extended version of 't2' from 'firstprivate-1.c'. */
16 int lexically_nested_val
= 2;
22 copy (lexically_nested_val)
24 VERIFY (lexically_nested_val
== 2);
26 #pragma acc parallel \
27 present (lexically_nested_val)
29 VERIFY (lexically_nested_val
== 2);
31 /* This updates the device copy, or shared variable. */
32 lexically_nested_val
= 7;
36 VERIFY (lexically_nested_val
== 7);
38 VERIFY (lexically_nested_val
== 2);
41 /* This only updates the local/shared variable, but not the device
43 lexically_nested_val
= 5;
45 #pragma acc parallel \
46 firstprivate (lexically_nested_val)
48 #if 1 /* Current behavior. */
49 /* The 'firstprivate' copy is initialized from the device copy, or
52 VERIFY (lexically_nested_val
== 5);
54 VERIFY (lexically_nested_val
== 7);
56 #else /* Expected behavior per PR92036. */
57 /* The 'firstprivate' copy is initialized from the local thread. */
58 VERIFY (lexically_nested_val
== 5);
61 /* This updates the 'firstprivate' copy only, but not the shared
63 lexically_nested_val
= 9;
66 VERIFY (lexically_nested_val
== 5);
68 /* If not shared, the device copy has now been copied back. */
71 VERIFY (lexically_nested_val
== 5);
73 VERIFY (lexically_nested_val
== 7);
78 int dynamically_nested_val
= 2;
80 /* Same as above, but compute construct 1 broken out, so no longer lexically
81 nested inside 'data' region. */
84 dynamically_nested_compute_1 ()
86 #pragma acc parallel \
87 present (dynamically_nested_val)
89 VERIFY (dynamically_nested_val
== 2);
91 /* This updates the device copy, or shared variable. */
92 dynamically_nested_val
= 7;
96 /* Same as above, but compute construct 2 broken out, so no longer lexically
97 nested inside 'data' region. */
100 dynamically_nested_compute_2 ()
102 #pragma acc parallel \
103 firstprivate (dynamically_nested_val)
105 #if 1 /* Current behavior. */
106 /* The 'firstprivate' copy is initialized from the device copy, or shared
109 VERIFY (dynamically_nested_val
== 5);
111 VERIFY (dynamically_nested_val
== 7);
113 #else /* Expected behavior per PR92036. */
114 /* The 'firstprivate' copy is initialized from the local thread. */
115 VERIFY (dynamically_nested_val
== 5);
118 /* This updates the 'firstprivate' copy only, but not the shared
120 dynamically_nested_val
= 9;
125 dynamically_nested ()
128 copy (dynamically_nested_val)
130 VERIFY (dynamically_nested_val
== 2);
132 dynamically_nested_compute_1 ();
135 VERIFY (dynamically_nested_val
== 7);
137 VERIFY (dynamically_nested_val
== 2);
140 /* This only updates the local/shared variable, but not the device
142 dynamically_nested_val
= 5;
144 dynamically_nested_compute_2 ();
146 VERIFY (dynamically_nested_val
== 5);
148 /* If not shared, the device copy has now been copied back. */
151 VERIFY (dynamically_nested_val
== 5);
153 VERIFY (dynamically_nested_val
== 7);
162 dynamically_nested ();