copyin-2.c 581 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* { dg-do run } */
  2. /* { dg-options "-O2" } */
  3. /* { dg-require-effective-target tls_runtime } */
  4. #include <omp.h>
  5. #include <stdlib.h>
  6. struct { int t; char buf[64]; } thr = { 32, "" };
  7. #pragma omp threadprivate (thr)
  8. int
  9. main (void)
  10. {
  11. int l = 0;
  12. omp_set_dynamic (0);
  13. omp_set_num_threads (6);
  14. #pragma omp parallel copyin (thr) reduction (||:l)
  15. {
  16. l = thr.t != 32;
  17. thr.t = omp_get_thread_num () + 11;
  18. }
  19. if (l || thr.t != 11)
  20. abort ();
  21. #pragma omp parallel reduction (||:l)
  22. l = thr.t != omp_get_thread_num () + 11;
  23. if (l)
  24. abort ();
  25. return 0;
  26. }