[flang][cuda] Add c_devloc as intrinsic and inline it during lowering (#120648)
[llvm-project.git] / openmp / runtime / test / teams / teams_resize.c
blob70e9afe1f704d7f8d3acdcc562dc5b6a510b62c1
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
8 // thread_limit size.
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <omp.h>
14 #define NUM_TIMES 10
16 int main(int argc, char **argv) {
17 int num_procs = omp_get_max_threads();
18 int num_teams, thread_limit, i;
19 num_teams = 2;
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);
32 exit(1);
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);
37 exit(1);
39 if (my_thread_id < 0 || my_thread_id >= my_num_threads) {
40 fprintf(stderr,
41 "error: my_thread_id (%d) invalid (my_num_threads = %d)\n",
42 my_thread_id, my_num_threads);
43 exit(1);
48 return 0;