<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Support/Parallel.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>Reland [Support][Jobserver][Tests] Simplify default executor init (#168165)</title>
<updated>2025-11-18T16:50:19+00:00</updated>
<author>
<name>Yaxun (Sam) Liu</name>
<email>yaxun.liu@amd.com</email>
</author>
<published>2025-11-18T16:50:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c7d2ed43648ebd9076ee290928d7bc805906882d'/>
<id>c7d2ed43648ebd9076ee290928d7bc805906882d</id>
<content type='text'>
and make (#165264)

Truely recover Executor::getDefaultExecutor. The previous change missed
std::unique_ptr, which is needed in a normal program exit, since only
with that ThreadPoolExecutor destructor will be called in a normal
program exit, where it ensures the executor has been stopped and waits
for worker threads to finish. The wait is important as it prevents
intermittent crashes on Windows when the process is doing a full exit.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
and make (#165264)

Truely recover Executor::getDefaultExecutor. The previous change missed
std::unique_ptr, which is needed in a normal program exit, since only
with that ThreadPoolExecutor destructor will be called in a normal
program exit, where it ensures the executor has been stopped and waits
for worker threads to finish. The wait is important as it prevents
intermittent crashes on Windows when the process is doing a full exit.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[Support][Jobserver][Tests] Simplify default executor init and make (#165264)"</title>
<updated>2025-11-14T05:46:40+00:00</updated>
<author>
<name>Aiden Grossman</name>
<email>aidengrossman@google.com</email>
</author>
<published>2025-11-14T05:46:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6b44cea0d589fdf2840746cec7a7917751dd8618'/>
<id>6b44cea0d589fdf2840746cec7a7917751dd8618</id>
<content type='text'>
This reverts commit b196c52301f4a581f994237c675cb4deffec6e8d.

This broke premerge both within the PR and afterwards:
1. https://github.com/llvm/llvm-project/actions/runs/19351188603
2. https://lab.llvm.org/staging/#/builders/21/builds/8845

Other buildbots were failing as well:
1. https://lab.llvm.org/buildbot/#/builders/46/builds/26346
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit b196c52301f4a581f994237c675cb4deffec6e8d.

This broke premerge both within the PR and afterwards:
1. https://github.com/llvm/llvm-project/actions/runs/19351188603
2. https://lab.llvm.org/staging/#/builders/21/builds/8845

Other buildbots were failing as well:
1. https://lab.llvm.org/buildbot/#/builders/46/builds/26346
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support][Jobserver][Tests] Simplify default executor init and make (#165264)</title>
<updated>2025-11-14T03:43:31+00:00</updated>
<author>
<name>Yaxun (Sam) Liu</name>
<email>yaxun.liu@amd.com</email>
</author>
<published>2025-11-14T03:43:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b196c52301f4a581f994237c675cb4deffec6e8d'/>
<id>b196c52301f4a581f994237c675cb4deffec6e8d</id>
<content type='text'>
jobserver tests deterministic

- Replace call-once wrapper in Parallel.cpp with a function-local static
default executor.

- Rework Jobserver tests for parallelFor/parallelSort to run in a fresh
subprocess. The parent test spawns the current test binary with a gtest
filter selecting a child test, ensuring the child process initializes
the default executor after setting parallel::strategy =
jobserver_concurrency() and after setting up a FIFO-backed jobserver
proxy. This makes the tests reliable and independent from prior executor
initialization in the combined SupportTests binary.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
jobserver tests deterministic

- Replace call-once wrapper in Parallel.cpp with a function-local static
default executor.

- Rework Jobserver tests for parallelFor/parallelSort to run in a fresh
subprocess. The parent test spawns the current test binary with a gtest
filter selecting a child test, ensuring the child process initializes
the default executor after setting parallel::strategy =
jobserver_concurrency() and after setting up a FIFO-backed jobserver
proxy. This makes the tests reliable and independent from prior executor
initialization in the combined SupportTests binary.</pre>
</div>
</content>
</entry>
<entry>
<title>Reland "[LLVM] Add GNU make jobserver support (#145131)"</title>
<updated>2025-10-03T21:38:37+00:00</updated>
<author>
<name>Yaxun (Sam) Liu</name>
<email>yaxun.liu@amd.com</email>
</author>
<published>2025-10-03T18:42:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fb458aa91f8fa614086e855ab29749e81e834194'/>
<id>fb458aa91f8fa614086e855ab29749e81e834194</id>
<content type='text'>
With fix for JobServerTest where default parallel scheduling
strategy is saved/restored.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With fix for JobServerTest where default parallel scheduling
strategy is saved/restored.
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[LLVM] Add GNU make jobserver support (#145131)"</title>
<updated>2025-10-03T14:35:03+00:00</updated>
<author>
<name>Yaxun (Sam) Liu</name>
<email>yaxun.liu@amd.com</email>
</author>
<published>2025-10-03T14:35:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f8f6c0b6ecb9d87ead48246d4fadf6048207375d'/>
<id>f8f6c0b6ecb9d87ead48246d4fadf6048207375d</id>
<content type='text'>
revert this patch due to failure in unittests/Support, e.g.

https://lab.llvm.org/buildbot/#/builders/33/builds/24178/steps/6/logs/FAIL__LLVM-Unit__SupportTests_61

This reverts commit ffc503edd0a2d07121232fe204e480fc29631a90.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
revert this patch due to failure in unittests/Support, e.g.

https://lab.llvm.org/buildbot/#/builders/33/builds/24178/steps/6/logs/FAIL__LLVM-Unit__SupportTests_61

This reverts commit ffc503edd0a2d07121232fe204e480fc29631a90.
</pre>
</div>
</content>
</entry>
<entry>
<title>[LLVM] Add GNU make jobserver support (#145131)</title>
<updated>2025-10-03T13:25:49+00:00</updated>
<author>
<name>Yaxun (Sam) Liu</name>
<email>yaxun.liu@amd.com</email>
</author>
<published>2025-10-03T13:25:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ffc503edd0a2d07121232fe204e480fc29631a90'/>
<id>ffc503edd0a2d07121232fe204e480fc29631a90</id>
<content type='text'>
This patch introduces support for the jobserver protocol to control
parallelism for device offloading tasks.

When running a parallel build with a modern build system like `make -jN`
or `ninja -jN`, each Clang process might also be configured to use
multiple threads for its own tasks (e.g., via `--offload-jobs=4`). This
can lead to an explosion of threads (N * 4), causing heavy system load,
CPU contention, and ultimately slowing down the entire build.

This patch allows Clang to act as a cooperative client of the build
system's jobserver. It extends the `--offload-jobs` option to accept the
value 'jobserver'. With the recent addition of jobserver support to the
Ninja build system, this functionality now benefits users of both Make
and Ninja.

When `--offload-jobs=jobserver` is specified, Clang's thread pool will:
1. Parse the MAKEFLAGS environment variable to find the jobserver
details.
2. Before dispatching a task, acquire a job slot from the jobserver. If
none are available, the worker thread will block.
3. Release the job slot once the task is complete.

This ensures that the total number of active offload tasks across all
Clang processes does not exceed the limit defined by the parent build
system, leading to more efficient and controlled parallel builds.

Implementation:
- A new library, `llvm/Support/Jobserver`, is added to provide a
platform-agnostic client for the jobserver protocol, with backends for
Unix (FIFO) and Windows (semaphores).
- `llvm/Support/ThreadPool` and `llvm/Support/Parallel` are updated with
a `jobserver_concurrency` strategy to integrate this logic.
- The Clang driver and linker-wrapper are modified to recognize the
'jobserver' argument and enable the new thread pool strategy.
- New unit and integration tests are added to validate the feature.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduces support for the jobserver protocol to control
parallelism for device offloading tasks.

When running a parallel build with a modern build system like `make -jN`
or `ninja -jN`, each Clang process might also be configured to use
multiple threads for its own tasks (e.g., via `--offload-jobs=4`). This
can lead to an explosion of threads (N * 4), causing heavy system load,
CPU contention, and ultimately slowing down the entire build.

This patch allows Clang to act as a cooperative client of the build
system's jobserver. It extends the `--offload-jobs` option to accept the
value 'jobserver'. With the recent addition of jobserver support to the
Ninja build system, this functionality now benefits users of both Make
and Ninja.

When `--offload-jobs=jobserver` is specified, Clang's thread pool will:
1. Parse the MAKEFLAGS environment variable to find the jobserver
details.
2. Before dispatching a task, acquire a job slot from the jobserver. If
none are available, the worker thread will block.
3. Release the job slot once the task is complete.

This ensures that the total number of active offload tasks across all
Clang processes does not exceed the limit defined by the parent build
system, leading to more efficient and controlled parallel builds.

Implementation:
- A new library, `llvm/Support/Jobserver`, is added to provide a
platform-agnostic client for the jobserver protocol, with backends for
Unix (FIFO) and Windows (semaphores).
- `llvm/Support/ThreadPool` and `llvm/Support/Parallel` are updated with
a `jobserver_concurrency` strategy to integrate this logic.
- The Clang driver and linker-wrapper are modified to recognize the
'jobserver' argument and enable the new thread pool strategy.
- New unit and integration tests are added to validate the feature.</pre>
</div>
</content>
</entry>
<entry>
<title>NFC: remove some instances of deprecated capture (#154884)</title>
<updated>2025-08-26T20:29:26+00:00</updated>
<author>
<name>Jeremy Kun</name>
<email>jkun@google.com</email>
</author>
<published>2025-08-26T20:29:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=be2f0205b697ce299f08aff024a09ce24498ed8c'/>
<id>be2f0205b697ce299f08aff024a09ce24498ed8c</id>
<content type='text'>
```
 warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
```

Co-authored-by: Jeremy Kun &lt;j2kun@users.noreply.github.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
```
 warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
```

Co-authored-by: Jeremy Kun &lt;j2kun@users.noreply.github.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[Parallel] Revert sequential task changes</title>
<updated>2024-09-21T04:15:42+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-09-21T04:15:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b84d773fd004ce719da69fbae5ec1dbc2b951230'/>
<id>b84d773fd004ce719da69fbae5ec1dbc2b951230</id>
<content type='text'>
https://reviews.llvm.org/D148728 introduced `bool Sequential` to unify
`execute` and the old `spawn` without argument. However, sequential
tasks might be executed by any worker thread (non-deterministic),
leading to non-determinism output for ld.lld -z nocombreloc (see
https://reviews.llvm.org/D133003).

In addition, the extra member variables have overhead.
This sequential task has only been used for lld parallel relocation
scanning.

This patch restores the behavior before https://reviews.llvm.org/D148728 .

Fix #105958

Pull Request: https://github.com/llvm/llvm-project/pull/109084
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://reviews.llvm.org/D148728 introduced `bool Sequential` to unify
`execute` and the old `spawn` without argument. However, sequential
tasks might be executed by any worker thread (non-deterministic),
leading to non-determinism output for ld.lld -z nocombreloc (see
https://reviews.llvm.org/D133003).

In addition, the extra member variables have overhead.
This sequential task has only been used for lld parallel relocation
scanning.

This patch restores the behavior before https://reviews.llvm.org/D148728 .

Fix #105958

Pull Request: https://github.com/llvm/llvm-project/pull/109084
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] ThreadPoolExecutor: remove unused default argument</title>
<updated>2024-08-14T00:49:57+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-08-14T00:49:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a3cba6b5db1b0918923240f46dcd6279a7b4421d'/>
<id>a3cba6b5db1b0918923240f46dcd6279a7b4421d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Restrict ManagedStatic ThreadPoolExecutor to Windows</title>
<updated>2024-08-14T00:02:03+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-08-14T00:02:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9487cf97e31bb9fac14394913b64c60ae60f5e41'/>
<id>9487cf97e31bb9fac14394913b64c60ae60f5e41</id>
<content type='text'>
https://reviews.llvm.org/D70447 switched to `ManagedStatic` to work
around race conditions in MSVC runtimes and the MinGW runtime.
However, `ManagedStatic` is not suitable for other platforms.

However, this workaround is not suitable for other platforms (#66974).
lld::fatal calls exitLld(1), which calls `llvm_shutdown` to destroy
`ManagedStatic` objects. The worker threads will finish and invoke TLS
destructors (glibc `__call_tls_dtors`). This can lead to race conditions
if other threads attempt to access TLS objects that have already been
destroyed.

While lld's early exit mechanism needs more work, I believe Parallel.cpp
should avoid this pitfall as well.

Pull Request: https://github.com/llvm/llvm-project/pull/102989
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://reviews.llvm.org/D70447 switched to `ManagedStatic` to work
around race conditions in MSVC runtimes and the MinGW runtime.
However, `ManagedStatic` is not suitable for other platforms.

However, this workaround is not suitable for other platforms (#66974).
lld::fatal calls exitLld(1), which calls `llvm_shutdown` to destroy
`ManagedStatic` objects. The worker threads will finish and invoke TLS
destructors (glibc `__call_tls_dtors`). This can lead to race conditions
if other threads attempt to access TLS objects that have already been
destroyed.

While lld's early exit mechanism needs more work, I believe Parallel.cpp
should avoid this pitfall as well.

Pull Request: https://github.com/llvm/llvm-project/pull/102989
</pre>
</div>
</content>
</entry>
</feed>
