1 | // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic |
2 | |
3 | #include <stdio.h> |
4 | |
5 | // CHECK: rx: 16, ry: 16; |
6 | // CHECK: rx: 16, ry: 16; |
7 | // CHECK: rx: 16, ry: 16; |
8 | // CHECK: rx: 16, ry: 16; |
9 | |
10 | template <bool Aligned> void test() { |
11 | printf(format: "Test %saligned firstprivate\n" , Aligned ? "" : "non-" ); |
12 | char z1[3 + Aligned], z2[3 + Aligned]; |
13 | int x[4]; |
14 | int y[4]; |
15 | y[0] = y[1] = y[2] = y[3] = 4; |
16 | x[0] = x[1] = x[2] = x[3] = 4; |
17 | int rx = -1, ry = -1; |
18 | #pragma omp target firstprivate(z1, y, z2) map(from : ry, rx) map(to : x) |
19 | { |
20 | ry = (y[0] + y[1] + y[2] + y[3]); |
21 | rx = (x[0] + x[1] + x[2] + x[3]); |
22 | } |
23 | printf(format: " rx:%i, ry:%i\n" , rx, ry); |
24 | #pragma omp target firstprivate(z1, y, z2) map(from : ry, rx) map(to : x) |
25 | { |
26 | z1[2] += 5; |
27 | ry = (y[0] + y[1] + y[2] + y[3]); |
28 | rx = (x[0] + x[1] + x[2] + x[3]); |
29 | z2[2] += 7; |
30 | } |
31 | printf(format: " rx:%i, ry:%i\n" , rx, ry); |
32 | } |
33 | |
34 | int main() { |
35 | test<true>(); |
36 | test<false>(); |
37 | } |
38 | |