Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / icv-9.c
blob21b874f8ae9296084ab5e93e1d980192ffd0b51f
1 /* { dg-do run } */
3 /* This tests usage of ICVs on the host and on devices if no corresponding
4 environment variables are configured. */
6 #include <omp.h>
7 #include <stdlib.h>
9 int
10 main ()
12 if (omp_get_max_teams () != 0
13 || omp_get_teams_thread_limit () != 0)
14 abort ();
16 omp_set_num_teams (9);
17 omp_set_teams_thread_limit (2);
18 if (omp_get_max_teams () != 9
19 || omp_get_teams_thread_limit () != 2)
20 abort ();
22 #pragma omp teams
23 if (omp_get_num_teams () > 9
24 || omp_get_team_num () >= 9)
25 abort ();
27 #pragma omp teams num_teams(5)
28 if (omp_get_num_teams () > 5
29 || omp_get_team_num () >= 5)
30 abort ();
32 int num_devices = omp_get_num_devices () > 3 ? 3 : omp_get_num_devices ();
33 for (int i = 0; i < num_devices; i++)
35 #pragma omp target device (i)
36 if (omp_get_max_teams () != 0
37 || omp_get_teams_thread_limit () != 0)
38 abort ();
40 #pragma omp target device (i)
42 omp_set_num_teams (8 + i);
43 omp_set_teams_thread_limit (3 + i);
44 if (omp_get_max_teams () != 8 + i
45 || omp_get_teams_thread_limit () != 3 + i)
46 abort ();
49 /* omp_set_num_teams above set the value of nteams-var ICV on device 'i',
50 which has scope 'device' and should be avaible in subsequent target
51 regions. */
52 #pragma omp target device (i)
53 if (omp_get_max_teams () != 8 + i
54 || omp_get_teams_thread_limit () != 3 + i)
55 abort ();
57 #pragma omp target device (i)
58 #pragma omp teams
59 if (omp_get_num_teams () > 8 + i
60 || omp_get_team_num () >= 8 + i)
61 abort ();
63 /* NUM_TEAMS clause has priority over previously set NUM_TEAMS value. */
64 #pragma omp target device (i)
65 #pragma omp teams num_teams(5 + i)
66 if (omp_get_num_teams () > 5 + i
67 || omp_get_team_num () >= 5 + i)
68 abort ();
71 return 0;