1 | // RUN: %libomptarget-compilexx-run-and-check-generic |
2 | |
3 | #include <stdio.h> |
4 | |
5 | void sum(int *input, int size, int *output) { |
6 | #pragma omp target teams distribute parallel for reduction(+ : output[0]) \ |
7 | map(to : input[0 : size]) |
8 | for (int i = 0; i < size; i++) |
9 | output[0] += input[i]; |
10 | } |
11 | int main() { |
12 | const int size = 100; |
13 | int *array = new int[size]; |
14 | int result = 0; |
15 | for (int i = 0; i < size; i++) |
16 | array[i] = i + 1; |
17 | sum(input: array, size, output: &result); |
18 | // CHECK: Result=5050 |
19 | printf(format: "Result=%d\n" , result); |
20 | delete[] array; |
21 | return 0; |
22 | } |
23 | |