Files
llvm/offload/test/offloading/nested_parallel_reduction.c
Nick Sarnie 2078cc8bfe [offload][lit] Fix failing/hanging/XPASSing tests on Intel GPU (#222342)
The buildbot was down for a few days due to changes that broke it and we
saw some required changes come up during that time. With this PR merged
we can reenable the buildbot as everything consistently passes.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-09-11 15:18:16 +00:00

41 lines
1.0 KiB
C

// Both parallel regions have to be nested for this to reproduce, and only at
// -O2 and above; either one alone is correct at every optimization level.
// RUN: %libomptarget-compileopt-generic
// RUN: %libomptarget-run-generic | %fcheck-generic
// REQUIRES: gpu
// XFAIL: intelgpu
#include <stdio.h>
#define N 5
int main(void) {
long aa = 0;
int ng = 6, cmom = 4, nxyz = 5;
#pragma omp target teams distribute num_teams(nxyz) thread_limit(4) \
map(tofrom : aa)
for (int gid = 0; gid < nxyz; gid++) {
#pragma omp parallel for collapse(2)
for (unsigned g = 0; g < ng; g++)
for (unsigned l = 0; l < cmom - 1; l++) {
int a = 0;
for (int ii = 0; ii < N + 2; ii++) {
#pragma omp parallel for reduction(+ : a)
for (int i = 0; i < N; i++)
a += i;
}
#pragma omp atomic
aa += a;
}
}
long expected = (long)ng * (cmom - 1) * nxyz * (N * (N - 1) / 2) * (N + 2);
printf("aa = %ld, expected %ld\n", aa, expected);
return aa != expected;
}
// CHECK: aa = 6300, expected 6300