simd-16.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* { dg-do run } */
  2. /* { dg-options "-O2 -std=c99" } */
  3. /* { dg-additional-options "-msse2" { target sse2_runtime } } */
  4. /* { dg-additional-options "-mavx" { target avx_runtime } } */
  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. }