llvm-project/openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
Jon Chesterfield 27177b82d4 [OpenMP] Lower printf to __llvm_omp_vprintf
Extension of D112504. Lower amdgpu printf to `__llvm_omp_vprintf`
which takes the same const char*, void* arguments as cuda vprintf and also
passes the size of the void* alloca which will be needed by a non-stub
implementation of `__llvm_omp_vprintf` for amdgpu.

This removes the amdgpu link error on any printf in a target region in favour
of silently compiling code that doesn't print anything to stdout.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D112680
2021-11-10 15:30:56 +00:00

26 lines
587 B
C++

// RUN: %libomptarget-compilexx-run-and-check-generic
#include <stdio.h>
void sum(int* input, int size, int* output)
{
#pragma omp target teams distribute parallel for reduction(+:output[0]) \
map(to:input[0:size])
for (int i = 0; i < size; i++)
output[0] += input[i];
}
int main()
{
const int size = 100;
int *array = new int[size];
int result = 0;
for (int i = 0; i < size; i++)
array[i] = i + 1;
sum(array, size, &result);
// CHECK: Result=5050
printf("Result=%d\n", result);
delete[] array;
return 0;
}