0003-cilkrts.diff 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c
  2. index c419fb68abf..155d8669e91 100644
  3. --- a/libcilkrts/runtime/os-unix.c
  4. +++ b/libcilkrts/runtime/os-unix.c
  5. @@ -55,6 +55,7 @@
  6. #if defined __linux__
  7. # include <sys/sysinfo.h>
  8. # include <sys/syscall.h>
  9. +# include <sched.h>
  10. #elif defined __APPLE__
  11. # include <sys/sysctl.h>
  12. @@ -452,28 +453,19 @@ COMMON_SYSDEP void __cilkrts_sleep(void)
  13. COMMON_SYSDEP void __cilkrts_yield(void)
  14. {
  15. -#if defined(__ANDROID__) || \
  16. - defined(__APPLE__) || \
  17. - defined(__CYGWIN__) || \
  18. - defined(__FreeBSD__) || \
  19. - defined(__VXWORKS__) || \
  20. - (defined(__sun__) && defined(__svr4__))
  21. - // Call sched_yield to yield quantum. I'm not sure why we
  22. - // don't do this on Linux also.
  23. - sched_yield();
  24. -#elif defined(__MIC__)
  25. +#if defined(__MIC__)
  26. // On MIC, pthread_yield() really trashes things. Arch's measurements
  27. // showed that calling _mm_delay_32() (or doing nothing) was a better
  28. // option. Delaying 1024 clock cycles is a reasonable compromise between
  29. // giving up the processor and latency starting up when work becomes
  30. // available
  31. _mm_delay_32(1024);
  32. -#elif defined(__linux__)
  33. - // On Linux, call pthread_yield (which in turn will call sched_yield)
  34. - // to yield quantum.
  35. +#elif defined(__sun__) && !defined(__svr4__)
  36. + // On old SunOS call pthread_yield to yield a quantum.
  37. pthread_yield();
  38. #else
  39. -# error "Unsupported architecture"
  40. + // On other platforms call sched_yield to yield a quantum.
  41. + sched_yield();
  42. #endif
  43. }