llvm-project/offload/test/mapping/map_both_pointer_pointee.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

63 lines
1.4 KiB
C

// RUN: %libomptarget-compile-run-and-check-generic
// REQUIRES: unified_shared_memory
// UNSUPPORTED: amdgcn-amd-amdhsa
//
// FIXME: https://github.com/llvm/llvm-project/issues/161265
// XFAIL: nvidiagpu
// XFAIL: intelgpu
#pragma omp declare target
int *ptr1;
#pragma omp end declare target
int a[10];
#include <stdio.h>
#include <stdlib.h>
int main() {
ptr1 = (int *)malloc(sizeof(int) * 100);
int *ptr2;
ptr2 = (int *)malloc(sizeof(int) * 100);
#pragma omp target map(ptr1, ptr1[ : 100])
{ ptr1[1] = 6; }
// CHECK: 6
printf(" %d \n", ptr1[1]);
#pragma omp target data map(ptr1[ : 5])
{
#pragma omp target map(ptr1[2], ptr1, ptr1[3]) map(ptr2, ptr2[2])
{
ptr1[2] = 7;
ptr1[3] = 9;
ptr2[2] = 7;
}
}
// CHECK: 7 7 9
printf(" %d %d %d \n", ptr2[2], ptr1[2], ptr1[3]);
free(ptr1);
#pragma omp target map(ptr2, ptr2[ : 100])
{ ptr2[1] = 6; }
// CHECK: 6
printf(" %d \n", ptr2[1]);
free(ptr2);
a[1] = 111;
int *p = &a[0];
// CHECK: 111
printf("%d %p %p\n", p[1], p, &p); // 111 hst_p1 hst_p2
#pragma omp target data map(to : p[1 : 3]) map(p)
#pragma omp target data use_device_addr(p)
{
#pragma omp target has_device_addr(p)
{
// CHECK: 111
printf("%d %p %p\n", p[1], p, &p); // 111 dev_p1 dev_p2
p[1] = 222;
// CHECK: 222
printf("%d %p %p\n", p[1], p, &p); // 222 dev_p1 dev_p2
}
}
// CHECK: 111
printf("%d %p %p\n", p[1], p, &p); // 111 hst_p1 hst_p2
return 0;
}