Debian Codegraph @

libgomp/testsuite/libgomp.c-c++-common/target-present-2.c

raw
1 #include <stdio.h>
2
3 #define N 100
4
5 int main (void)
6 {
7 int a[N], b[N], c[N];
8
9 for (int i = 0; i < N; i++) {
10 a[i] = i * 2;
11 b[i] = i * 3 + 1;
12 }
13
14 #pragma omp target enter data map (alloc: a, c)
15 /* a and c have already been allocated, so this should be okay. */
16 #pragma omp target defaultmap (present)
17 for (int i = 0; i < N; i++)
18 c[i] = a[i];
19
20 fprintf (stderr, "CheCKpOInT\n");
21 /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
22
23 /* b has not been allocated, so this should result in an error. */
24 /* { dg-output "libgomp: present clause: not present on the device \\(addr: 0x\[0-9a-f\]+, size: \[0-9\]+ \\(0x\[0-9a-f\]+\\), dev: \[0-9\]+\\\)" { target offload_device_nonshared_as } } */
25 /* { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */
26 #pragma omp target defaultmap (present)
27 for (int i = 0; i < N; i++)
28 c[i] += b[i];
29 #pragma omp target exit data map (from: c)
30 }