loop-7.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* { dg-do run } */
  2. #include <omp.h>
  3. extern void abort (void);
  4. #define LLONG_MAX __LONG_LONG_MAX__
  5. #define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
  6. #define INT_MAX __INT_MAX__
  7. int v;
  8. int
  9. test1 (void)
  10. {
  11. int e = 0, cnt = 0;
  12. long long i;
  13. unsigned long long j;
  14. char buf[6], *p;
  15. #pragma omp for schedule(dynamic,1) collapse(2) nowait
  16. for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
  17. for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
  18. if ((i != LLONG_MAX - 30001
  19. && i != LLONG_MAX - 20001
  20. && i != LLONG_MAX - 10001)
  21. || j != 20)
  22. e = 1;
  23. else
  24. cnt++;
  25. if (e || cnt != 3)
  26. abort ();
  27. else
  28. cnt = 0;
  29. #pragma omp for schedule(guided,1) collapse(2) nowait
  30. for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
  31. for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
  32. if ((i != -LLONG_MAX + 30000
  33. && i != -LLONG_MAX + 20000
  34. && i != -LLONG_MAX + 10000)
  35. || j != ULLONG_MAX - 3)
  36. e = 1;
  37. else
  38. cnt++;
  39. if (e || cnt != 3)
  40. abort ();
  41. else
  42. cnt = 0;
  43. #pragma omp for schedule(static,1) collapse(2) nowait
  44. for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
  45. for (j = 20; j <= LLONG_MAX - 70 + v; j += LLONG_MAX + 50ULL)
  46. if ((i != LLONG_MAX - 30001
  47. && i != LLONG_MAX - 20001
  48. && i != LLONG_MAX - 10001)
  49. || j != 20)
  50. e = 1;
  51. else
  52. cnt++;
  53. if (e || cnt != 3)
  54. abort ();
  55. else
  56. cnt = 0;
  57. #pragma omp for schedule(static) collapse(2) nowait
  58. for (i = -LLONG_MAX + 30000 + v; i >= -LLONG_MAX + 10000; i -= 10000)
  59. for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
  60. if ((i != -LLONG_MAX + 30000
  61. && i != -LLONG_MAX + 20000
  62. && i != -LLONG_MAX + 10000)
  63. || j != ULLONG_MAX - 3)
  64. e = 1;
  65. else
  66. cnt++;
  67. if (e || cnt != 3)
  68. abort ();
  69. else
  70. cnt = 0;
  71. #pragma omp for schedule(runtime) collapse(2) nowait
  72. for (i = 10; i < 30; i++)
  73. for (p = buf; p <= buf + 4; p += 2)
  74. if (i < 10 || i >= 30 || (p != buf && p != buf + 2 && p != buf + 4))
  75. e = 1;
  76. else
  77. cnt++;
  78. if (e || cnt != 60)
  79. abort ();
  80. else
  81. cnt = 0;
  82. return 0;
  83. }
  84. int
  85. main (void)
  86. {
  87. if (2 * sizeof (int) != sizeof (long long))
  88. return 0;
  89. asm volatile ("" : "+r" (v));
  90. omp_set_schedule (omp_sched_dynamic, 1);
  91. test1 ();
  92. return 0;
  93. }