pause-2.c 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* { dg-do run } */
  2. /* { dg-require-effective-target tls_runtime } */
  3. #include <omp.h>
  4. #include <stdlib.h>
  5. int t = 128;
  6. #pragma omp threadprivate (t)
  7. int
  8. main ()
  9. {
  10. #pragma omp parallel
  11. t = omp_get_thread_num () + 256;
  12. #pragma omp parallel
  13. if (t != omp_get_thread_num () + 256)
  14. abort ();
  15. omp_pause_resource (omp_pause_soft, omp_get_initial_device ());
  16. /* This goes beyond what is required by the standard, we actually
  17. check if the threads other than the initial one have been destroyed. */
  18. #pragma omp parallel
  19. {
  20. if (omp_get_thread_num () != 0 && t != 128)
  21. abort ();
  22. t = omp_get_thread_num () + 384;
  23. }
  24. #pragma omp parallel
  25. if (t != omp_get_thread_num () + 384)
  26. abort ();
  27. omp_pause_resource_all (omp_pause_hard);
  28. #pragma omp parallel
  29. {
  30. if (omp_get_thread_num () != 0 && t != 128)
  31. abort ();
  32. t = omp_get_thread_num () + 512;
  33. }
  34. #pragma omp parallel
  35. if (t != omp_get_thread_num () + 512)
  36. abort ();
  37. return 0;
  38. }