Debian Codegraph @

libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c

raw
1 /* Test 'nohost' clause via 'weak'.
2
3 { dg-require-effective-target weak_undefined }
4
5 When the OpenACC 'routine' with 'nohost' clauses gets discarded, the weak symbol then resolves to 'NULL'.
6 */
7
8 /* { dg-additional-sources routine-nohost-2_2.c } */
9
10 /* { dg-additional-options "-fno-inline" } for stable results regarding OpenACC 'routine'. */
11 /* { dg-add-options weak_undefined } */
12
13 #include <assert.h>
14 #include <openacc.h>
15
16 #pragma acc routine //nohost
17 __attribute__((weak))
18 extern int f1(int);
19
20 int main()
21 {
22 int x = -10;
23
24 #pragma acc serial copy(x)
25 /* { dg-warning {using .vector_length \(32\)., ignoring 1} "" { target openacc_nvidia_accel_selected } .-1 } */
26 {
27 if (f1)
28 x = f1(x);
29 else
30 x = 0;
31
32 }
33
34 if (acc_get_device_type() == acc_device_host)
35 assert(x == 0);
36 else
37 assert(x == -20);
38
39 return 0;
40 }