| 1 |
/* { dg-require-effective-target lto } */ |
| 2 |
/* { dg-additional-options "-flto" } */ |
| 3 |
/* { dg-additional-options "-foffload-options=nvptx-none=-misa=sm_35" { target { offload_target_nvptx } } } */ |
| 4 |
/* { dg-additional-sources requires-4-aux.c } */ |
| 5 |
|
| 6 |
/* Same as requires-4.c, but uses heap memory for 'a'. */ |
| 7 |
|
| 8 |
/* Check no diagnostic by device-compiler's or host compiler's lto1. |
| 9 |
Other file uses: 'requires reverse_offload', but that's inactive as |
| 10 |
there are no declare target directives, device constructs nor device routines */ |
| 11 |
|
| 12 |
/* Depending on offload device capabilities, it may print something like the |
| 13 |
following (only) if GOMP_DEBUG=1: |
| 14 |
"devices present but 'omp requires unified_address, unified_shared_memory, reverse_offload' cannot be fulfilled" |
| 15 |
and in that case does host-fallback execution. |
| 16 |
|
| 17 |
No offload devices support USM at present, so we may verify host-fallback |
| 18 |
execution by presence of separate memory spaces. */ |
| 19 |
|
| 20 |
#pragma omp requires unified_address,unified_shared_memory |
| 21 |
|
| 22 |
int *a; |
| 23 |
extern void foo (void); |
| 24 |
|
| 25 |
int |
| 26 |
main (void) |
| 27 |
{ |
| 28 |
a = (int *) __builtin_calloc (sizeof (int), 10); |
| 29 |
#pragma omp target map(to: a) |
| 30 |
for (int i = 0; i < 10; i++) |
| 31 |
a[i] = i; |
| 32 |
|
| 33 |
for (int i = 0; i < 10; i++) |
| 34 |
if (a[i] != i) |
| 35 |
__builtin_abort (); |
| 36 |
|
| 37 |
foo (); |
| 38 |
__builtin_free (a); |
| 39 |
return 0; |
| 40 |
} |