|
| 1 | +// clang-format off |
| 2 | +// RUN: %libomptarget-compilexx-generic |
| 3 | +// RUN: env OMPX_APU_MAPS=1 HSA_XNACK=1 LIBOMPTARGET_INFO=30 %libomptarget-run-generic 2>&1 \ |
| 4 | +// RUN: | %fcheck-generic -check-prefix=INFO_ZERO -check-prefix=CHECK |
| 5 | + |
| 6 | +// RUN: %libomptarget-compilexx-generic |
| 7 | +// RUN: env HSA_XNACK=0 LIBOMPTARGET_INFO=30 %libomptarget-run-generic 2>&1 \ |
| 8 | +// RUN: | %fcheck-generic -check-prefix=INFO_COPY -check-prefix=CHECK |
| 9 | + |
| 10 | +// UNSUPPORTED: aarch64-unknown-linux-gnu |
| 11 | +// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO |
| 12 | +// UNSUPPORTED: nvptx64-nvidia-cuda |
| 13 | +// UNSUPPORTED: nvptx64-nvidia-cuda-LTO |
| 14 | +// UNSUPPORTED: x86_64-pc-linux-gnu |
| 15 | +// UNSUPPORTED: x86_64-pc-linux-gnu-LTO |
| 16 | + |
| 17 | +// REQUIRES: unified_shared_memory |
| 18 | + |
| 19 | +// clang-format on |
| 20 | + |
| 21 | +#include <cstdio> |
| 22 | + |
| 23 | +int main() { |
| 24 | + int n = 1024; |
| 25 | + |
| 26 | + // test various mapping types |
| 27 | + int *a = new int[n]; |
| 28 | + int k = 3; |
| 29 | + int b[n]; |
| 30 | + |
| 31 | + for (int i = 0; i < n; i++) |
| 32 | + b[i] = i; |
| 33 | + |
| 34 | + // clang-format off |
| 35 | + // INFO_ZERO: Return HstPtrBegin 0x{{.*}} Size=4096 for unified shared memory |
| 36 | + // INFO_ZERO: Return HstPtrBegin 0x{{.*}} Size=4096 for unified shared memory |
| 37 | + |
| 38 | + // INFO_COPY: Creating new map entry with HstPtrBase=0x{{.*}}, HstPtrBegin=0x{{.*}}, TgtAllocBegin=0x{{.*}}, TgtPtrBegin=0x{{.*}}, Size=4096, |
| 39 | + // INFO_COPY: Creating new map entry with HstPtrBase=0x{{.*}}, HstPtrBegin=0x{{.*}}, TgtAllocBegin=0x{{.*}}, TgtPtrBegin=0x{{.*}}, Size=4096, |
| 40 | + // INFO_COPY: Mapping exists with HstPtrBegin=0x{{.*}}, TgtPtrBegin=0x{{.*}}, Size=4096, DynRefCount=1 (update suppressed) |
| 41 | + // INFO_COPY: Mapping exists with HstPtrBegin=0x{{.*}}, TgtPtrBegin=0x{{.*}}, Size=4096, DynRefCount=1 (update suppressed) |
| 42 | +// clang-format on |
| 43 | +#pragma omp target teams distribute parallel for map(tofrom : a[ : n]) \ |
| 44 | + map(to : b[ : n]) |
| 45 | + for (int i = 0; i < n; i++) |
| 46 | + a[i] = i + b[i] + k; |
| 47 | + |
| 48 | + int err = 0; |
| 49 | + for (int i = 0; i < n; i++) |
| 50 | + if (a[i] != i + b[i] + k) |
| 51 | + err++; |
| 52 | + |
| 53 | + // CHECK: PASS |
| 54 | + if (err == 0) |
| 55 | + printf("PASS\n"); |
| 56 | + return err; |
| 57 | +} |
0 commit comments