teams-4.c 791 B

123456789101112131415161718192021222324252627282930
  1. #include <omp.h>
  2. #include <stdlib.h>
  3. int
  4. main ()
  5. {
  6. if (omp_get_num_teams () != 1 || omp_get_team_num () != 0)
  7. abort ();
  8. #pragma omp parallel num_threads (2)
  9. if (omp_get_num_teams () != 1 || omp_get_team_num () != 0)
  10. abort ();
  11. #pragma omp teams num_teams (4)
  12. {
  13. int team = omp_get_team_num ();
  14. if (omp_get_num_teams () != 4 || (unsigned) team >= 4U)
  15. abort ();
  16. #pragma omp parallel num_threads (3)
  17. if (omp_get_num_teams () != 4 || omp_get_team_num () != team)
  18. abort ();
  19. #pragma omp parallel if (0)
  20. #pragma omp target
  21. #pragma omp teams num_teams (2)
  22. if (omp_get_num_teams () != 2
  23. || (unsigned) omp_get_team_num () >= 2U)
  24. abort ();
  25. if (omp_get_num_teams () != 4 || (unsigned) team >= 4U)
  26. abort ();
  27. }
  28. return 0;
  29. }