1// RUN: %libomptarget-compile-run-and-check-generic
2// UNSUPPORTED: amdgcn-amd-amdhsa
3
4#include <assert.h>
5#include <stdio.h>
6
7int main() {
8 int data1[3] = {1, 2, 5};
9 int data2[3] = {10, 20, 50};
10 int data3[3] = {100, 200, 500};
11 int sum[16] = {0};
12
13 for (int i=0; i<16; i++) sum[i] = 10000;
14
15#pragma omp target teams distribute parallel for map(tofrom : sum[:16]) \
16 firstprivate(data1, data2, data3)
17 for (int i = 0; i < 16; ++i) {
18 for (int j = 0; j < 3; ++j) {
19 sum[i] += data1[j];
20 sum[i] += data2[j];
21 sum[i] += data3[j];
22 }
23 }
24
25 int correct = 1;
26 for (int i = 0; i < 16; ++i) {
27 if (sum[i] != 10888) {
28 correct = 0;
29 printf(format: "ERROR: The sum for index %d is %d\n", i, sum[i]);
30 printf(format: "ERROR: data1 = {%d, %d, %d}\n", data1[0], data1[1], data1[2]);
31 printf(format: "ERROR: data2 = {%d, %d, %d}\n", data2[0], data2[1], data2[2]);
32 printf(format: "ERROR: data3 = {%d, %d, %d}\n", data3[0], data3[1], data3[2]);
33 break;
34 }
35 }
36 fflush(stdout);
37 assert(correct);
38
39 printf(format: "PASS\n");
40
41 return 0;
42}
43
44// CHECK: PASS
45

source code of offload/test/mapping/private_mapping.c