llvm-project/offload/test/offloading/strided_multiple_update.c
Nick Sarnie 26b777444b
[offload][lit] XFAIL all failing tests on the Level Zero plugin (#174804)
We finally got our buildbot added (to staging, at least) so we want to
start running L0 tests in CI.
We need `check-offload` to pass though, so XFAIL everything failing.
There's a couple `UNSUPPORTED` as well, those are for sporadic fails.

Also make set the `gpu` and `intelgpu` LIT variables when testing the
`spirv64-intel` triple.

We have no DeviceRTL yet so basically everything fails, but we manage to
get

```
Total Discovered Tests: 432
Unsupported      : 169 (39.12%)
Passed           :  67 (15.51%)
Expectedly Failed: 196 (45.37%)
```

We still don't build the level zero plugin by default and these tests
don't run unless the plugin was built, so this has no effect on most
builds.

---------

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-01-07 19:20:30 +00:00

64 lines
1.7 KiB
C

// This test checks that #pragma omp target update from(data1[0:3:4],
// data2[0:2:5]) correctly updates disjoint strided sections of multiple arrays
// from the device to the host.
// RUN: %libomptarget-compile-run-and-check-generic
// XFAIL: intelgpu
#include <omp.h>
#include <stdio.h>
int main() {
int len = 12;
double data1[len], data2[len];
// Initial values
#pragma omp target map(tofrom : data1[0 : len], data2[0 : len])
{
for (int i = 0; i < len; i++) {
data1[i] = i;
data2[i] = i * 10;
}
}
printf("original host array values:\n");
printf("data1: ");
for (int i = 0; i < len; i++)
printf("%.1f ", data1[i]);
printf("\ndata2: ");
for (int i = 0; i < len; i++)
printf("%.1f ", data2[i]);
printf("\n\n");
#pragma omp target data map(to : data1[0 : len], data2[0 : len])
{
// Modify arrays on device
#pragma omp target
{
for (int i = 0; i < len; i++)
data1[i] += i;
for (int i = 0; i < len; i++)
data2[i] += 100;
}
// data1[0:3:4] // indices 0,4,8
// data2[0:2:5] // indices 0,5
#pragma omp target update from(data1[0 : 3 : 4], data2[0 : 2 : 5])
}
printf("device array values after update from:\n");
printf("data1: ");
for (int i = 0; i < len; i++)
printf("%.1f ", data1[i]);
printf("\ndata2: ");
for (int i = 0; i < len; i++)
printf("%.1f ", data2[i]);
printf("\n\n");
// CHECK: data1: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0
// CHECK: data2: 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 110.0
// CHECK: data1: 0.0 1.0 2.0 3.0 8.0 5.0 6.0 7.0 16.0 9.0 10.0 11.0
// CHECK: data2: 100.0 10.0 20.0 30.0 40.0 150.0 60.0 70.0 80.0 90.0 100.0
// 110.0
}