Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / private_mapping.c
blob1329a66a5da3a903231bf5a9b9bbc25c8f1f2a4f
1 // RUN: %libomptarget-compile-run-and-check-generic
2 // UNSUPPORTED: amdgcn-amd-amdhsa
4 #include <assert.h>
5 #include <stdio.h>
7 int 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};
13 for (int i=0; i<16; i++) sum[i] = 10000;
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];
25 int correct = 1;
26 for (int i = 0; i < 16; ++i) {
27 if (sum[i] != 10888) {
28 correct = 0;
29 printf("ERROR: The sum for index %d is %d\n", i, sum[i]);
30 printf("ERROR: data1 = {%d, %d, %d}\n", data1[0], data1[1], data1[2]);
31 printf("ERROR: data2 = {%d, %d, %d}\n", data2[0], data2[1], data2[2]);
32 printf("ERROR: data3 = {%d, %d, %d}\n", data3[0], data3[1], data3[2]);
33 break;
36 fflush(stdout);
37 assert(correct);
39 printf("PASS\n");
41 return 0;
44 // CHECK: PASS