2 // { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized" }
3 // { dg-additional-options -foffload-options=-fdump-tree-optimized { target { offload_target_nvptx || offload_target_amdgcn } } }
5 // { dg-final { scan-tree-dump-times "omp_is_initial_device" 1 "gimple" } }
6 // { dg-final { scan-tree-dump-times "_GLOBAL__off_I_v1" 1 "gimple" } }
7 // { dg-final { scan-tree-dump-times "__omp_target_static_init_and_destruction" 2 "gimple" } }
8 // { dg-final { scan-tree-dump-times "__attribute__\\(\\(\[^\n\r]*omp declare target nohost" 2 "gimple" } }
10 // { dg-final { scan-tree-dump-not "omp_is_initial_device" "optimized" } }
11 // { dg-final { scan-tree-dump-not "__omp_target_static_init_and_destruction" "optimized" } }
13 // (A) No offloading configured: The symbols aren't present
14 // Caveat: They are present with -foffload=disable - or offloading
15 // configured but none of the optional offload packages/binaries installed.
16 // But the 'offload_target_any' check cannot distinguish those
17 // { dg-final { scan-tree-dump-not "void _GLOBAL__off_I_v1" "optimized" { target { ! offload_target_any } } } }
18 // { dg-final { scan-tree-dump-not "__attribute__\\(\\(\[^\n\r]*omp declare target nohost" "optimized" { target { ! offload_target_any } } } }
20 // (B) With offload configured (and compiling for an offload target)
21 // the symbols are present (missed optimization). Hence: FIXME.
22 // { dg-final { scan-tree-dump-times "void _GLOBAL__off_I_v1" 1 "optimized" { target offload_target_any } } }
23 // { dg-final { scan-tree-dump-times "__attribute__\\(\\(\[^\n\r]*omp declare target nohost" 1 "optimized" { target offload_target_any } } }
26 // { dg-final { only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump-not "omp_initial_device;" "optimized" { target offload_target_amdgcn } } }
27 // { dg-final { only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump "v1\\._x = 5;" "optimized" { target offload_target_amdgcn } } }
28 // { dg-final { only_for_offload_target nvptx-none scan-offload-tree-dump-not "omp_initial_device;" "optimized" { target offload_target_nvptx } } }
29 // { dg-final { only_for_offload_target nvptx-none scan-offload-tree-dump "v1\\._x = 5;" "optimized" { target offload_target_nvptx } } }
34 #pragma omp declare target
39 T add(str o) { return _x + o._x; }
45 #pragma omp end declare target
52 #pragma omp target map(from:res)