8 fn1 (double *x
, double *y
, int z
)
11 for (i
= 0; i
< z
; i
++)
18 #pragma omp declare target
23 #pragma omp atomic update
27 #pragma omp end declare target
30 fn2 (int x
, int y
, int z
)
32 double b
[1024], c
[1024], s
= 0;
35 #pragma omp target data map(to: b)
37 #pragma omp target map(tofrom: c, s)
38 #pragma omp teams num_teams(y) thread_limit(z) reduction(+:s) firstprivate(x)
39 #pragma omp distribute dist_schedule(static, 4) collapse(1)
40 for (j
=0; j
< x
; j
+= y
)
41 #pragma omp parallel for reduction(+:s)
42 for (i
= j
; i
< j
+ y
; i
++)
43 tgt (), s
+= b
[i
] * c
[i
];
44 #pragma omp target update from(b, tgtv)
52 double b
[1024], c
[1024], s
= 0;
55 #pragma omp target map(to: b, c) map(tofrom:s)
56 #pragma omp parallel for reduction(+:s)
57 for (i
= 0; i
< x
; i
++)
58 tgt (), s
+= b
[i
] * c
[i
];
63 fn4 (int x
, double *p
)
65 double b
[1024], c
[1024], d
[1024], s
= 0;
68 fn1 (d
+ x
, p
+ x
, x
);
69 #pragma omp target map(to: b, c[0:x], d[x:x]) map(to:p[x:64 + (x & 31)]) \
71 #pragma omp parallel for reduction(+:s)
72 for (i
= 0; i
< x
; i
++)
73 s
+= b
[i
] * c
[i
] + d
[x
+ i
] + p
[x
+ i
];
80 double a
= fn2 (128, 4, 6);
83 #pragma omp target update from(tgtv)
86 double f
= fn4 (64, e
);
87 if (a
!= 13888.0 || b
!= 6 + 128 || c
!= 4062.0 || d
!= 6 + 128 + 61