simd-16.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* { dg-do run } */
  2. /* { dg-additional-options "-msse2" { target sse2_runtime } } */
  3. /* { dg-additional-options "-mavx" { target avx_runtime } } */
  4. /* { dg-additional-options "-std=c99" {target c } } */
  5. int
  6. main ()
  7. {
  8. int b, c = 0;
  9. b = 7;
  10. #pragma omp simd linear(b:2) reduction(+:c)
  11. for (int i = 0; i < 64; i++)
  12. {
  13. c = c + (b != 7 + 2 * i);
  14. b = b + 2;
  15. }
  16. if (c || b != 7 + 64 * 2)
  17. __builtin_abort ();
  18. b = 7;
  19. #pragma omp simd linear(b:3) reduction(+:c)
  20. for (int i = 0; i < 64; i += 4)
  21. {
  22. c = c + (b != 7 + i / 4 * 3);
  23. b = b + 3;
  24. }
  25. if (c || b != 7 + 16 * 3)
  26. __builtin_abort ();
  27. b = 7;
  28. #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
  29. for (int i = 0; i < 8; i++)
  30. for (int j = 0; j < 8; j++)
  31. {
  32. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  33. b = b + 2;
  34. }
  35. if (c || b != 7 + 64 * 2)
  36. __builtin_abort ();
  37. b = 7;
  38. #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
  39. for (int i = 0; i < 64; i++)
  40. {
  41. c = c + (b != 7 + 2 * i);
  42. b = b + 2;
  43. }
  44. if (c || b != 7 + 64 * 2)
  45. __builtin_abort ();
  46. b = 7;
  47. #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
  48. for (int i = 0; i < 64; i += 4)
  49. {
  50. c = c + (b != 7 + i / 4 * 3);
  51. b = b + 3;
  52. }
  53. if (c || b != 7 + 16 * 3)
  54. __builtin_abort ();
  55. b = 7;
  56. #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
  57. for (int i = 0; i < 8; i++)
  58. for (int j = 0; j < 8; j++)
  59. {
  60. c = c + (b != 7 + 2 * j + 2 * 8 * i);
  61. b = b + 2;
  62. }
  63. if (c || b != 7 + 64 * 2)
  64. __builtin_abort ();
  65. return 0;
  66. }