nestedfn-3.c 717 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* { dg-do run } */
  2. #include <omp.h>
  3. extern void abort (void);
  4. int
  5. main (void)
  6. {
  7. int i = 5, l = 0;
  8. int foo (void) { return i == 6; }
  9. int bar (void) { return i - 3; }
  10. omp_set_dynamic (0);
  11. #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l)
  12. if (omp_get_num_threads () != 1)
  13. l = 1;
  14. i++;
  15. #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l)
  16. if (omp_get_num_threads () != 3)
  17. l = 1;
  18. i++;
  19. #pragma omp master
  20. if (bar () != 4)
  21. abort ();
  22. #pragma omp single
  23. {
  24. if (foo ())
  25. abort ();
  26. i--;
  27. if (! foo ())
  28. abort ();
  29. }
  30. if (l)
  31. abort ();
  32. i = 8;
  33. #pragma omp atomic
  34. l += bar ();
  35. if (l != 5)
  36. abort ();
  37. return 0;
  38. }