pr26943-2.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* PR c++/26943 */
  2. /* { dg-do run } */
  3. extern int omp_set_dynamic (int);
  4. extern void abort (void);
  5. extern void GOMP_barrier (void);
  6. int a = 8, b = 12, c = 16, d = 20, j = 0;
  7. char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
  8. int
  9. main (void)
  10. {
  11. int i;
  12. omp_set_dynamic (0);
  13. #pragma omp parallel for shared (a, e) firstprivate (b, f) \
  14. lastprivate (c, g) private (d, h) \
  15. schedule (static, 1) num_threads (4) \
  16. reduction (+:j)
  17. for (i = 0; i < 4; i++)
  18. {
  19. if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
  20. j++;
  21. GOMP_barrier ();
  22. #pragma omp atomic
  23. a += i;
  24. b += i;
  25. c = i;
  26. d = i;
  27. #pragma omp atomic
  28. e[0] += i;
  29. f[0] += i;
  30. g[0] = 'g' + i;
  31. h[0] = 'h' + i;
  32. GOMP_barrier ();
  33. if (a != 8 + 6 || b != 12 + i || c != i || d != i)
  34. j += 8;
  35. if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
  36. j += 64;
  37. if (h[0] != 'h' + i)
  38. j += 512;
  39. }
  40. if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
  41. abort ();
  42. if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
  43. abort ();
  44. return 0;
  45. }