simd-14.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* { dg-do run } */
  2. /* { dg-options "-O2" } */
  3. /* { dg-additional-options "-msse2" { target sse2_runtime } } */
  4. /* { dg-additional-options "-mavx" { target avx_runtime } } */
  5. int
  6. main ()
  7. {
  8. int i, j, b, c = 0;
  9. i = 4; j = 4; b = 7;
  10. #pragma omp simd linear(b:2) reduction(+:c)
  11. for (i = 0; i < 64; i++)
  12. {
  13. c = c + (b != 7 + 2 * i);
  14. b = b + 2;
  15. }
  16. if (c || i != 64 || b != 7 + 64 * 2)
  17. __builtin_abort ();
  18. i = 4; j = 4; b = 7;
  19. #pragma omp simd linear(b:3) reduction(+:c)
  20. for (i = 0; i < 64; i += 4)
  21. {
  22. c = c + (b != 7 + i / 4 * 3);
  23. b = b + 3;
  24. }
  25. if (c || i != 64 || b != 7 + 16 * 3)
  26. __builtin_abort ();
  27. i = 4; j = 4; b = 7;
  28. #pragma omp simd linear(i) linear(b:2) reduction(+:c)
  29. for (i = 0; i < 64; i++)
  30. {
  31. c = c + (b != 7 + 2 * i);
  32. b = b + 2;
  33. }
  34. if (c || i != 64 || b != 7 + 64 * 2)
  35. __builtin_abort ();
  36. i = 4; j = 4; b = 7;
  37. #pragma omp simd linear(i:4) linear(b:3) reduction(+:c)
  38. for (i = 0; i < 64; i += 4)
  39. {
  40. c = c + (b != 7 + i / 4 * 3);
  41. b = b + 3;
  42. }
  43. if (c || i != 64 || b != 7 + 16 * 3)
  44. __builtin_abort ();
  45. i = 4; j = 4; b = 7;
  46. #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
  47. for (i = 0; i < 8; i++)
  48. for (j = 0; j < 8; j++)
  49. {
  50. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  51. b = b + 2;
  52. }
  53. if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
  54. __builtin_abort ();
  55. i = 4; j = 4; b = 7;
  56. #pragma omp simd collapse (2) lastprivate (i, j) linear(b:2) reduction(+:c)
  57. for (i = 0; i < 8; i++)
  58. for (j = 0; j < 8; j++)
  59. {
  60. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  61. b = b + 2;
  62. }
  63. if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
  64. __builtin_abort ();
  65. i = 4; j = 4; b = 7;
  66. #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
  67. for (i = 0; i < 64; i++)
  68. {
  69. c = c + (b != 7 + 2 * i);
  70. b = b + 2;
  71. }
  72. if (c || i != 64 || b != 7 + 64 * 2)
  73. __builtin_abort ();
  74. i = 4; j = 4; b = 7;
  75. #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
  76. for (i = 0; i < 64; i += 4)
  77. {
  78. c = c + (b != 7 + i / 4 * 3);
  79. b = b + 3;
  80. }
  81. if (c || i != 64 || b != 7 + 16 * 3)
  82. __builtin_abort ();
  83. i = 4; j = 4; b = 7;
  84. #pragma omp parallel for simd schedule (static, 4) linear(i) linear(b:2) reduction(+:c)
  85. for (i = 0; i < 64; i++)
  86. {
  87. c = c + (b != 7 + 2 * i);
  88. b = b + 2;
  89. }
  90. if (c || i != 64 || b != 7 + 64 * 2)
  91. __builtin_abort ();
  92. i = 4; j = 4; b = 7;
  93. #pragma omp parallel for simd schedule (static, 4) linear(i:4) linear(b:3) reduction(+:c)
  94. for (i = 0; i < 64; i += 4)
  95. {
  96. c = c + (b != 7 + i / 4 * 3);
  97. b = b + 3;
  98. }
  99. if (c || i != 64 || b != 7 + 16 * 3)
  100. __builtin_abort ();
  101. i = 4; j = 4; b = 7;
  102. #pragma omp parallel for simd lastprivate (i, j) collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
  103. for (i = 0; i < 8; i++)
  104. for (j = 0; j < 8; j++)
  105. {
  106. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  107. b = b + 2;
  108. }
  109. if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
  110. __builtin_abort ();
  111. i = 4; j = 4; b = 7;
  112. #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
  113. for (i = 0; i < 8; i++)
  114. for (j = 0; j < 8; j++)
  115. {
  116. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  117. b = b + 2;
  118. }
  119. if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
  120. __builtin_abort ();
  121. return 0;
  122. }