simd-8.c 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* { dg-do run } */
  2. /* { dg-additional-options "-msse2" { target sse2_runtime } } */
  3. /* { dg-additional-options "-mavx" { target avx_runtime } } */
  4. extern void abort ();
  5. int a[32][32] __attribute__((aligned (32))) = { { 1 } };
  6. struct S { int s; };
  7. #pragma omp declare reduction (+:struct S:omp_out.s += omp_in.s)
  8. #pragma omp declare reduction (foo:struct S:omp_out.s += omp_in.s)
  9. #pragma omp declare reduction (foo:int:omp_out += omp_in)
  10. __attribute__((noinline, noclone)) int
  11. foo (void)
  12. {
  13. int i, j, u = 0;
  14. struct S s, t;
  15. s.s = 0; t.s = 0;
  16. #pragma omp simd aligned(a : 32) reduction(+:s) reduction(foo:t, u) collapse(2)
  17. for (i = 0; i < 32; i++)
  18. for (j = 0; j < 32; j++)
  19. {
  20. int x = a[i][j];
  21. s.s += x;
  22. t.s += x;
  23. u += x;
  24. }
  25. if (t.s != s.s || u != s.s)
  26. abort ();
  27. return s.s;
  28. }
  29. int
  30. main ()
  31. {
  32. int i, j;
  33. for (i = 0; i < 32; i++)
  34. for (j = 0; j < 32; j++)
  35. a[i][j] = j + (i / 4);
  36. int s = foo ();
  37. if (s != 19456)
  38. abort ();
  39. return 0;
  40. }