[llvm] [Parallel] Ensure getThreadIndex()==0 for sequential tasks (PR #109084)
Andrew Ng via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 11:09:30 PDT 2024
================
@@ -217,13 +194,18 @@ TaskGroup::~TaskGroup() {
void TaskGroup::spawn(std::function<void()> F, bool Sequential) {
#if LLVM_ENABLE_THREADS
if (Parallel) {
+ if (Sequential) {
+ // Act as worker thread 0.
+ threadIndex = 0;
----------------
nga888 wrote:
IIUC, if a user was to mix sequential and parallel tasks within the same `TaskGroup` then this could potentially lead to unintentional concurrent access to thread index `0` resources.
https://github.com/llvm/llvm-project/pull/109084
More information about the llvm-commits
mailing list