teams-2.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include <omp.h>
  2. #include <stdlib.h>
  3. int
  4. foo ()
  5. {
  6. return 934;
  7. }
  8. int
  9. main ()
  10. {
  11. int a[934] = {};
  12. int k, e;
  13. #pragma omp target map(a)
  14. #pragma omp teams num_teams (foo ())
  15. {
  16. int i = omp_get_team_num ();
  17. if (omp_get_num_teams () != 934
  18. || (unsigned) i >= 934U
  19. || a[i] != 0)
  20. abort ();
  21. ++a[i];
  22. }
  23. #pragma omp target map(a)
  24. #pragma omp teams num_teams (foo () - 50 : foo ())
  25. {
  26. int i = omp_get_team_num ();
  27. int j = omp_get_num_teams ();
  28. if (j < 884
  29. || j > 934
  30. || (unsigned) i >= (unsigned) j
  31. || a[i] != 1)
  32. abort ();
  33. ++a[i];
  34. }
  35. #pragma omp target teams map(a) num_teams (foo () / 2)
  36. {
  37. int i = omp_get_team_num ();
  38. if (omp_get_num_teams () != 467
  39. || (unsigned) i >= 467U
  40. || a[i] != 2)
  41. abort ();
  42. ++a[i];
  43. }
  44. #pragma omp target teams map(a) num_teams (foo () / 2 - 50 : foo () / 2)
  45. {
  46. int i = omp_get_team_num ();
  47. int j = omp_get_num_teams ();
  48. if (j < 417
  49. || j > 467
  50. || (unsigned) i >= (unsigned) j
  51. || a[i] != 3)
  52. abort ();
  53. ++a[i];
  54. }
  55. e = 4;
  56. for (k = 0; k < 934; k++)
  57. {
  58. if (k >= 417 && k < 467 && a[k] == 3)
  59. e = 3;
  60. else if (k == 467)
  61. e = 2;
  62. else if (k >= 884 && a[k] == 1)
  63. e = 1;
  64. if (a[k] != e)
  65. abort ();
  66. }
  67. return 0;
  68. }