summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Parallel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Support] ThreadPoolExecutor fixes for Windows/MinGWAndrew Ng2020-01-101-18/+64
| | | | | | | | | | | | | | | | | | | | | Changed ThreadPoolExecutor to no longer use detached threads and instead to join threads on destruction. This is to prevent intermittent crashing on Windows when doing a normal full exit, e.g. via exit(). Changed ThreadPoolExecutor to be a ManagedStatic so that it can be stopped on llvm_shutdown(). Without this, it would only be stopped in the destructor when doing a full exit. This is required to avoid intermittent crashing on Windows due to a race condition between the ThreadPoolExecutor starting up threads and the process doing a fast exit, e.g. via _exit(). The Windows crashes appear to only occur with the MSVC static runtimes and are more frequent with the debug static runtime. These changes also prevent intermittent deadlocks on exit with the MinGW runtime. Differential Revision: https://reviews.llvm.org/D70447
* win: Move Parallel.h off concrt to cross-platform codeNico Weber2019-10-101-30/+1
| | | | | | | | | | | | | | | | | | | | | r179397 added Parallel.h and implemented it terms of concrt in 2013. In 2015, a cross-platform implementation of the functions has appeared and is in use everywhere but on Windows (r232419). r246219 hints that <thread> had issues in MSVC2013, but r296906 suggests they've been fixed now that we require 2015+. So remove the concrt code. It's less code, and it sounds like concrt has conceptual and performance issues, see PR41198. I built blink_core.dll in a debug component build with full symbols and in a release component build without any symbols. I couldn't measure a performance difference for linking blink_core.dll before and after this patch. Differential Revision: https://reviews.llvm.org/D68820 llvm-svn: 374421
* Parallel: only allow the first TaskGroup to run tasks parallellyFangrui Song2019-04-251-6/+25
| | | | | | | | | | | | | | | | | | | Summary: Concurrent (e.g. nested) llvm::parallel::for_each() may lead to dead locks. See PR35788 (fixed by rLLD322041) and PR41508 (fixed by D60757). When parallel_for_each() is about to return, in ~Latch() called by ~TaskGroup(), a thread (in the default executor) may block in Latch::sync() waiting for Count to become zero. If all threads in the default executor are blocked, it is a dead lock. To fix this, force serial execution if the current TaskGroup is not the first one. For a nested llvm::parallel::for_each(), this parallelizes the outermost loop and serializes inner loops. Differential Revision: https://reviews.llvm.org/D61115 llvm-svn: 359182
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove unused SyncExecutor and make it clearer that the whole file is only ↵Nico Weber2018-05-111-14/+5
| | | | | | used if LLVM_ENABLE_THREADS llvm-svn: 332098
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-3/+3
| | | | | | | | | | | | | | | | We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
* Bring r314809 back.Rafael Espindola2017-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | But now include a check for CPU_COUNT so we still build on 10 year old versions of glibc. Original message: Use sched_getaffinity instead of std::thread::hardware_concurrency. The issue with std::thread::hardware_concurrency is that it forwards to libc and some implementations (like glibc) don't take thread affinity into consideration. With this change a llvm program that can execute in only 2 cores will use 2 threads, even if the machine has 32 cores. This makes benchmarking a lot easier, but should also help if someone doesn't want to use all cores for compilation for example. llvm-svn: 314931
* Revert D38481 due to missing cmake check for CPU_COUNTDaniel Neilson2017-10-041-2/+2
| | | | | | | | | | | | | Summary: This reverts D38481. The change breaks systems with older versions of glibc. It injects a use of CPU_COUNT() from sched.h without checking to ensure that the function exists first. Reviewers: Subscribers: llvm-svn: 314922
* Use sched_getaffinity instead of std::thread::hardware_concurrency.Rafael Espindola2017-10-031-2/+2
| | | | | | | | | | | | | | The issue with std::thread::hardware_concurrency is that it forwards to libc and some implementations (like glibc) don't take thread affinity into consideration. With this change a llvm program that can execute in only 2 cores will use 2 threads, even if the machine has 32 cores. This makes benchmarking a lot easier, but should also help if someone doesn't want to use all cores for compilation for example. llvm-svn: 314809
* Fix -DLLVM_ENABLE_THREADS=OFF build after r302748Hans Wennborg2017-05-111-0/+2
| | | | llvm-svn: 302806
* Final (hopefully) fix for the build bots.Zachary Turner2017-05-111-1/+1
| | | | | | | | This time it actually occurred to me to change the #defines to actually test the pre-processed out codepath. Hopefully this time it works. llvm-svn: 302752
* Try again to fix the buildbots.Zachary Turner2017-05-111-1/+1
| | | | | | | TaskGroup and Latch need to be in llvm::parallel::detail, not in llvm::detail. llvm-svn: 302751
* Fix build errors with Parallel.Zachary Turner2017-05-111-1/+1
| | | | llvm-svn: 302749
* [Support] Move Parallel algorithms from LLD to LLVM.Zachary Turner2017-05-111-0/+136
Differential Revision: https://reviews.llvm.org/D33024 llvm-svn: 302748
OpenPOWER on IntegriCloud