[HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (#117017)
[llvm-project.git] / offload / test / mapping / reduction_implicit_map.cpp
blob329aa43ddf3c09d2e289487c55b239fa83d82a6c
1 // RUN: %libomptarget-compilexx-run-and-check-generic
3 #include <stdio.h>
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];
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(array, size, &result);
18 // CHECK: Result=5050
19 printf("Result=%d\n", result);
20 delete[] array;
21 return 0;