force-parallel-6.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. void abort (void);
  2. #define N 500
  3. #define M 50
  4. int X[2*N], Y[2*N], B[2*N];
  5. int A[2*N][2*N], C[2*N][2*N];
  6. static void __attribute__((noinline,noclone))
  7. init (void)
  8. {
  9. volatile int i, j;
  10. for (i = 0; i < 2 * N; ++i)
  11. {
  12. B[i] = 1;
  13. X[i] = 1;
  14. Y[i] = 1;
  15. for (j = 0; j < 2 * N; ++j)
  16. {
  17. A[i][j] = 1;
  18. C[i][j] = 1;
  19. }
  20. }
  21. }
  22. static void __attribute__((noinline,noclone))
  23. foo (void)
  24. {
  25. int i, j, k;
  26. for (i = 0; i < M; i++)
  27. {
  28. X[i] = Y[i] + 10;
  29. for (j = 0; j < M; j++)
  30. {
  31. B[j] = A[j][N];
  32. for (k = 0; k < N; k++)
  33. {
  34. A[j+1][k] = B[j] + C[j][k];
  35. }
  36. Y[i+j] = A[j+1][N];
  37. }
  38. }
  39. }
  40. static void __attribute__((noinline,noclone))
  41. check (void)
  42. {
  43. volatile int i, j;
  44. for (i = 0; i < 2 * N; ++i)
  45. {
  46. int expect_x = i < M ? 11 : 1;
  47. if (B[i] != 1
  48. || X[i] != expect_x
  49. || Y[i] != 1)
  50. abort ();
  51. for (j = 0; j < 2 * N; ++j)
  52. {
  53. int expect_a = (0 < i && i <= M && j < N) ? 2 : 1;
  54. if (A[i][j] != expect_a
  55. || C[i][j] != 1)
  56. abort ();
  57. }
  58. }
  59. }
  60. int main(void)
  61. {
  62. init ();
  63. foo ();
  64. check ();
  65. return 0;
  66. }
  67. /* Check that parallel code generation part make the right answer. */
  68. /* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
  69. /* { dg-final { cleanup-tree-dump "graphite" } } */
  70. /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */
  71. /* { dg-final { cleanup-tree-dump "parloops" } } */
  72. /* { dg-final { cleanup-tree-dump "optimized" } } */