llvm-project/offload/test/mapping/reduction_implicit_map.cpp
fineg74 2890f9883c
[OFFLOAD] Improve handling of synchronization errors in L0 plugin and reenable tests (#186927)
This change improves handling of errors during synchronization in Level
Zero plugin by ensuring cleanup of queues and events in case of an
synchronization error. As a result multiple tests stopped hanging.

---------

Co-authored-by: Duran, Alex <alejandro.duran@intel.com>
2026-03-18 05:50:06 +01:00

24 lines
571 B
C++

// RUN: %libomptarget-compilexx-run-and-check-generic
// XFAIL: intelgpu
#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;
}