0005-cilkrts.diff 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c
  2. index cb582dd..e43d7d5 100644
  3. --- a/libcilkrts/runtime/os-unix.c
  4. +++ b/libcilkrts/runtime/os-unix.c
  5. @@ -51,6 +51,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. // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output
  13. @@ -400,28 +401,19 @@ COMMON_SYSDEP void __cilkrts_sleep(void)
  14. COMMON_SYSDEP void __cilkrts_yield(void)
  15. {
  16. -#if __APPLE__ || __FreeBSD__ || __VXWORKS__
  17. - // On MacOS, call sched_yield to yield quantum. I'm not sure why we
  18. - // don't do this on Linux also.
  19. - sched_yield();
  20. -#elif defined(__DragonFly__)
  21. - // On DragonFly BSD, call sched_yield to yield quantum.
  22. - sched_yield();
  23. -#elif defined(__MIC__)
  24. +#if defined(__MIC__)
  25. // On MIC, pthread_yield() really trashes things. Arch's measurements
  26. // showed that calling _mm_delay_32() (or doing nothing) was a better
  27. // option. Delaying 1024 clock cycles is a reasonable compromise between
  28. // giving up the processor and latency starting up when work becomes
  29. // available
  30. _mm_delay_32(1024);
  31. -#elif defined(__ANDROID__) || (defined(__sun__) && defined(__svr4__))
  32. - // On Android and Solaris, call sched_yield to yield quantum. I'm not
  33. - // sure why we don't do this on Linux also.
  34. - sched_yield();
  35. -#else
  36. - // On Linux, call pthread_yield (which in turn will call sched_yield)
  37. - // to yield quantum.
  38. +#elif defined(__sun__) && !defined(__svr4__)
  39. + // On old SunOS call pthread_yield to yield a quantum.
  40. pthread_yield();
  41. +#else
  42. + // On other platforms call sched_yield to yield a quantum.
  43. + sched_yield();
  44. #endif
  45. }