MaskRay added a comment.

In D75153#1942336 <https://reviews.llvm.org/D75153#1942336>, @aganea wrote:

> In D75153#1906580 <https://reviews.llvm.org/D75153#1906580>, @MaskRay wrote:
>
> > Does `taskset -c 0-3 lld -flavor ...` restrict the number of cores?
> >
> >   cpu_set_t cpu;
> >   sched_getaffinity(0, sizeof(cpu), &cpu);
> >   CPU_COUNT(&cpu)
>
>
> Thanks for raising this! This does not seem to work (I currently only have 
> WSL at hand, no real Linux machine). I don't think it worked before my patch. 
> The current code in LLVM is written such as: (//note the "if" statement//)
>
>   #if defined(HAVE_SCHED_GETAFFINITY) && defined(HAVE_CPU_COUNT)
>     cpu_set_t Set;
>     if (sched_getaffinity(0, sizeof(Set), &Set))
>       return CPU_COUNT(&Set);
>   #endif
>
>
>
>
>   [[ https://linux.die.net/man/2/sched_getaffinity | The doc ]] for 
> `sched_getaffinity` says:
>   
>
> > On success, sched_setaffinity() and sched_getaffinity() return 0. On error, 
> > -1 is returned, and errno is set appropriately.
>
> So it would always fall back to `std::thread::hardware_concurrency`, which 
> apparently does not always take affinity into account, according to 
> @respindola (please see rG8c0ff9508da5f02e8ce6580a126a2018c9bf702a 
> <https://reviews.llvm.org/rG8c0ff9508da5f02e8ce6580a126a2018c9bf702a>).
>
> I'll write a follow-up patch to test affinity on Linux and Windows.


Created D78324 <https://reviews.llvm.org/D78324> to fix this pre-existing 
issue. I remember I saw a related bugs.llvm.org report yesterday but I can't 
find it now...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75153/new/

https://reviews.llvm.org/D75153



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to