1// RUN: %libomptarget-compilexx-run-and-check-generic
2
3// UNSUPPORTED: x86_64-pc-linux-gnu
4// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
5
6#include <cassert>
7#include <iostream>
8
9int main(int argc, char *argv[]) {
10 constexpr const int num_threads = 64, N = 128;
11 int array[num_threads] = {0};
12
13#pragma omp parallel for
14 for (int i = 0; i < num_threads; ++i) {
15 int tmp[N];
16
17 for (int j = 0; j < N; ++j) {
18 tmp[j] = i;
19 }
20
21#pragma omp target teams distribute parallel for map(tofrom : tmp)
22 for (int j = 0; j < N; ++j) {
23 tmp[j] += j;
24 }
25
26 for (int j = 0; j < N; ++j) {
27 array[i] += tmp[j];
28 }
29 }
30
31 // Verify
32 for (int i = 0; i < num_threads; ++i) {
33 const int ref = (0 + N - 1) * N / 2 + i * N;
34 assert(array[i] == ref);
35 }
36
37 std::cout << "PASS\n";
38
39 return 0;
40}
41
42// CHECK: PASS
43

source code of offload/test/offloading/parallel_offloading_map.cpp