1 // RUN: %libomp-compile && env OMP_DYNAMIC=true KMP_DYNAMIC_MODE=random %libomp-run
3 // gcc/icc target offloading is incompatible with libomp
4 // UNSUPPORTED: icc, gcc
6 // This is a super simple unit test to see that teams behave properly when
7 // parallel regions inside the teams construct cannot allocate teams of
16 int main(int argc
, char **argv
) {
17 int num_procs
= omp_get_max_threads();
18 int num_teams
, thread_limit
, i
;
20 thread_limit
= num_procs
/ num_teams
;
21 for (i
= 0; i
< NUM_TIMES
; ++i
) {
22 #pragma omp target teams num_teams(num_teams) thread_limit(thread_limit)
24 #pragma omp parallel num_threads(thread_limit)
26 int my_num_threads
= omp_get_num_threads();
27 int my_num_teams
= omp_get_num_teams();
28 int my_team_id
= omp_get_team_num();
29 int my_thread_id
= omp_get_thread_num();
30 if (my_num_teams
< 0 || my_num_teams
> num_teams
) {
31 fprintf(stderr
, "error: my_num_teams (%d) invalid\n", my_num_teams
);
34 if (my_team_id
< 0 || my_team_id
>= my_num_teams
) {
35 fprintf(stderr
, "error: my_team_id (%d) invalid (nteams = %d)\n",
36 my_team_id
, my_num_teams
);
39 if (my_thread_id
< 0 || my_thread_id
>= my_num_threads
) {
41 "error: my_thread_id (%d) invalid (my_num_threads = %d)\n",
42 my_thread_id
, my_num_threads
);