[Mlir-commits] [mlir] 7effcbd - Rename parallelForEachN to just parallelFor

Nico Weber llvmlistbot at llvm.org
Sun Jun 19 14:49:08 PDT 2022


Author: Nico Weber
Date: 2022-06-19T17:49:00-04:00
New Revision: 7effcbda49ba32991b8955821b8fdbd4f8f303e2

URL: https://github.com/llvm/llvm-project/commit/7effcbda49ba32991b8955821b8fdbd4f8f303e2
DIFF: https://github.com/llvm/llvm-project/commit/7effcbda49ba32991b8955821b8fdbd4f8f303e2.diff

LOG: Rename parallelForEachN to just parallelFor

Patch created by running:

  rg -l parallelForEachN | xargs sed -i '' -c 's/parallelForEachN/parallelFor/'

No behavior change.

Differential Revision: https://reviews.llvm.org/D128140

Added: 
    

Modified: 
    lld/COFF/DebugTypes.cpp
    lld/COFF/ICF.cpp
    lld/COFF/LLDMapFile.cpp
    lld/COFF/MapFile.cpp
    lld/ELF/ICF.cpp
    lld/ELF/MapFile.cpp
    lld/ELF/OutputSections.cpp
    lld/ELF/SyntheticSections.cpp
    lld/ELF/Writer.cpp
    lld/MachO/ICF.cpp
    lld/MachO/MapFile.cpp
    lld/MachO/UnwindInfoSection.cpp
    lld/wasm/MapFile.cpp
    llvm/include/llvm/Support/Parallel.h
    llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
    llvm/lib/Support/Parallel.cpp
    llvm/unittests/Support/ParallelTest.cpp
    mlir/docs/Diagnostics.md
    mlir/include/mlir/IR/Threading.h

Removed: 
    


################################################################################
diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 0d25de464f9f..5878386aeb93 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -1056,7 +1056,7 @@ void TypeMerger::mergeTypesWithGHash() {
   // position. Because the table does not rehash, the position will not change
   // under insertion. After insertion is done, the value of the cell can be read
   // to retrieve the final PDB type index.
-  parallelForEachN(0, ctx.tpiSourceList.size(), [&](size_t tpiSrcIdx) {
+  parallelFor(0, ctx.tpiSourceList.size(), [&](size_t tpiSrcIdx) {
     TpiSource *source = ctx.tpiSourceList[tpiSrcIdx];
     source->indexMapStorage.resize(source->ghashes.size());
     for (uint32_t i = 0, e = source->ghashes.size(); i < e; i++) {

diff  --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp
index 832362662394..49546ea8bdc2 100644
--- a/lld/COFF/ICF.cpp
+++ b/lld/COFF/ICF.cpp
@@ -233,10 +233,10 @@ void ICF::forEachClass(std::function<void(size_t, size_t)> fn) {
   size_t boundaries[numShards + 1];
   boundaries[0] = 0;
   boundaries[numShards] = chunks.size();
-  parallelForEachN(1, numShards, [&](size_t i) {
+  parallelFor(1, numShards, [&](size_t i) {
     boundaries[i] = findBoundary((i - 1) * step, chunks.size());
   });
-  parallelForEachN(1, numShards + 1, [&](size_t i) {
+  parallelFor(1, numShards + 1, [&](size_t i) {
     if (boundaries[i - 1] < boundaries[i]) {
       forEachClassRange(boundaries[i - 1], boundaries[i], fn);
     }

diff  --git a/lld/COFF/LLDMapFile.cpp b/lld/COFF/LLDMapFile.cpp
index 639b186dbb6f..af15af5accf1 100644
--- a/lld/COFF/LLDMapFile.cpp
+++ b/lld/COFF/LLDMapFile.cpp
@@ -75,7 +75,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> syms) {
 static DenseMap<DefinedRegular *, std::string>
 getSymbolStrings(ArrayRef<DefinedRegular *> syms) {
   std::vector<std::string> str(syms.size());
-  parallelForEachN((size_t)0, syms.size(), [&](size_t i) {
+  parallelFor((size_t)0, syms.size(), [&](size_t i) {
     raw_string_ostream os(str[i]);
     writeHeader(os, syms[i]->getRVA(), 0, 0);
     os << indent16 << toString(*syms[i]);

diff  --git a/lld/COFF/MapFile.cpp b/lld/COFF/MapFile.cpp
index ace614da866b..2da50af30387 100644
--- a/lld/COFF/MapFile.cpp
+++ b/lld/COFF/MapFile.cpp
@@ -141,7 +141,7 @@ static void getSymbols(const COFFLinkerContext &ctx,
 static DenseMap<Defined *, std::string>
 getSymbolStrings(const COFFLinkerContext &ctx, ArrayRef<Defined *> syms) {
   std::vector<std::string> str(syms.size());
-  parallelForEachN((size_t)0, syms.size(), [&](size_t i) {
+  parallelFor((size_t)0, syms.size(), [&](size_t i) {
     raw_string_ostream os(str[i]);
     Defined *sym = syms[i];
 

diff  --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index f4e4389b41fc..77d32db6718a 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -422,11 +422,11 @@ void ICF<ELFT>::forEachClass(llvm::function_ref<void(size_t, size_t)> fn) {
   boundaries[0] = 0;
   boundaries[numShards] = sections.size();
 
-  parallelForEachN(1, numShards, [&](size_t i) {
+  parallelFor(1, numShards, [&](size_t i) {
     boundaries[i] = findBoundary((i - 1) * step, sections.size());
   });
 
-  parallelForEachN(1, numShards + 1, [&](size_t i) {
+  parallelFor(1, numShards + 1, [&](size_t i) {
     if (boundaries[i - 1] < boundaries[i])
       forEachClassRange(boundaries[i - 1], boundaries[i], fn);
   });

diff  --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp
index 048d41b8d0ee..bcd897a83a82 100644
--- a/lld/ELF/MapFile.cpp
+++ b/lld/ELF/MapFile.cpp
@@ -92,7 +92,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<Defined *> syms) {
 static DenseMap<Symbol *, std::string>
 getSymbolStrings(ArrayRef<Defined *> syms) {
   auto strs = std::make_unique<std::string[]>(syms.size());
-  parallelForEachN(0, syms.size(), [&](size_t i) {
+  parallelFor(0, syms.size(), [&](size_t i) {
     raw_string_ostream os(strs[i]);
     OutputSection *osec = syms[i]->getOutputSection();
     uint64_t vma = syms[i]->getVA();

diff  --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 44d3d3c7ca28..bc940c7e6546 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -350,7 +350,7 @@ template <class ELFT> void OutputSection::maybeCompress() {
   // concatenated with the next shard.
   auto shardsOut = std::make_unique<SmallVector<uint8_t, 0>[]>(numShards);
   auto shardsAdler = std::make_unique<uint32_t[]>(numShards);
-  parallelForEachN(0, numShards, [&](size_t i) {
+  parallelFor(0, numShards, [&](size_t i) {
     shardsOut[i] = deflateShard(shardsIn[i], level,
                                 i != numShards - 1 ? Z_SYNC_FLUSH : Z_FINISH);
     shardsAdler[i] = adler32(1, shardsIn[i].data(), shardsIn[i].size());
@@ -409,7 +409,7 @@ template <class ELFT> void OutputSection::writeTo(uint8_t *buf) {
 
     buf[0] = 0x78; // CMF
     buf[1] = 0x01; // FLG: best speed
-    parallelForEachN(0, compressed.numShards, [&](size_t i) {
+    parallelFor(0, compressed.numShards, [&](size_t i) {
       memcpy(buf + offsets[i], compressed.shards[i].data(),
              compressed.shards[i].size());
     });
@@ -425,7 +425,7 @@ template <class ELFT> void OutputSection::writeTo(uint8_t *buf) {
   if (nonZeroFiller)
     fill(buf, sections.empty() ? size : sections[0]->outSecOff, filler);
 
-  parallelForEachN(0, sections.size(), [&](size_t i) {
+  parallelFor(0, sections.size(), [&](size_t i) {
     InputSection *isec = sections[i];
     if (auto *s = dyn_cast<SyntheticSection>(isec))
       s->writeTo(buf + isec->outSecOff);
@@ -623,7 +623,7 @@ void OutputSection::checkDynRelAddends(const uint8_t *bufStart) {
   assert(config->writeAddends && config->checkDynamicRelocs);
   assert(type == SHT_REL || type == SHT_RELA);
   SmallVector<InputSection *, 0> sections = getInputSections(*this);
-  parallelForEachN(0, sections.size(), [&](size_t i) {
+  parallelFor(0, sections.size(), [&](size_t i) {
     // When linking with -r or --emit-relocs we might also call this function
     // for input .rel[a].<sec> sections which we simply pass through to the
     // output. We skip over those and only look at the synthetic relocation

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 2f16ddcd5b97..091e03836527 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2841,7 +2841,7 @@ static SmallVector<GdbIndexSection::GdbSymbol, 0> createSymbols(
   // Instantiate GdbSymbols while uniqufying them by name.
   auto symbols = std::make_unique<SmallVector<GdbSymbol, 0>[]>(numShards);
 
-  parallelForEachN(0, concurrency, [&](size_t threadId) {
+  parallelFor(0, concurrency, [&](size_t threadId) {
     uint32_t i = 0;
     for (ArrayRef<NameAttrEntry> entries : nameAttrs) {
       for (const NameAttrEntry &ent : entries) {
@@ -2921,7 +2921,7 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
   SmallVector<GdbChunk, 0> chunks(files.size());
   SmallVector<SmallVector<NameAttrEntry, 0>, 0> nameAttrs(files.size());
 
-  parallelForEachN(0, files.size(), [&](size_t i) {
+  parallelFor(0, files.size(), [&](size_t i) {
     // To keep memory usage low, we don't want to keep cached DWARFContext, so
     // avoid getDwarf() here.
     ObjFile<ELFT> *file = cast<ObjFile<ELFT>>(files[i]);
@@ -3287,8 +3287,8 @@ void MergeTailSection::finalizeContents() {
 }
 
 void MergeNoTailSection::writeTo(uint8_t *buf) {
-  parallelForEachN(0, numShards,
-                   [&](size_t i) { shards[i].write(buf + shardOffsets[i]); });
+  parallelFor(0, numShards,
+              [&](size_t i) { shards[i].write(buf + shardOffsets[i]); });
 }
 
 // This function is very hot (i.e. it can take several seconds to finish)
@@ -3312,7 +3312,7 @@ void MergeNoTailSection::finalizeContents() {
                        numShards));
 
   // Add section pieces to the builders.
-  parallelForEachN(0, concurrency, [&](size_t threadId) {
+  parallelFor(0, concurrency, [&](size_t threadId) {
     for (MergeInputSection *sec : sections) {
       for (size_t i = 0, e = sec->pieces.size(); i != e; ++i) {
         if (!sec->pieces[i].live)

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 649958b74798..5e2cf0713c40 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2915,7 +2915,7 @@ computeHash(llvm::MutableArrayRef<uint8_t> hashBuf,
   std::unique_ptr<uint8_t[]> hashes(new uint8_t[hashesSize]);
 
   // Compute hash values.
-  parallelForEachN(0, chunks.size(), [&](size_t i) {
+  parallelFor(0, chunks.size(), [&](size_t i) {
     hashFn(hashes.get() + i * hashBuf.size(), chunks[i]);
   });
 

diff  --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 6d10262826e5..515fa7fbbf54 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -270,10 +270,10 @@ void ICF::forEachClass(llvm::function_ref<void(size_t, size_t)> func) {
   size_t boundaries[shards + 1];
   boundaries[0] = 0;
   boundaries[shards] = icfInputs.size();
-  parallelForEachN(1, shards, [&](size_t i) {
+  parallelFor(1, shards, [&](size_t i) {
     boundaries[i] = findBoundary((i - 1) * step, icfInputs.size());
   });
-  parallelForEachN(1, shards + 1, [&](size_t i) {
+  parallelFor(1, shards + 1, [&](size_t i) {
     if (boundaries[i - 1] < boundaries[i]) {
       forEachClassRange(boundaries[i - 1], boundaries[i], func);
     }

diff  --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp
index a4a0065c2816..974d823a4fab 100644
--- a/lld/MachO/MapFile.cpp
+++ b/lld/MachO/MapFile.cpp
@@ -75,7 +75,7 @@ static std::pair<Symbols, Symbols> getSymbols() {
 static DenseMap<Symbol *, std::string>
 getSymbolStrings(ArrayRef<Defined *> syms) {
   std::vector<std::string> str(syms.size());
-  parallelForEachN(0, syms.size(), [&](size_t i) {
+  parallelFor(0, syms.size(), [&](size_t i) {
     raw_string_ostream os(str[i]);
     Defined *sym = syms[i];
 

diff  --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index 5822d668b4c0..2c4a469578de 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -326,7 +326,7 @@ void UnwindInfoSectionImpl::prepareRelocations(ConcatInputSection *isec) {
 // is no source address to make a relative location meaningful.
 void UnwindInfoSectionImpl::relocateCompactUnwind(
     std::vector<CompactUnwindEntry> &cuEntries) {
-  parallelForEachN(0, symbolsVec.size(), [&](size_t i) {
+  parallelFor(0, symbolsVec.size(), [&](size_t i) {
     CompactUnwindEntry &cu = cuEntries[i];
     const Defined *d = symbolsVec[i].second;
     cu.functionAddress = d->getVA();

diff  --git a/lld/wasm/MapFile.cpp b/lld/wasm/MapFile.cpp
index 9dbab5046e23..0e63fda6acd6 100644
--- a/lld/wasm/MapFile.cpp
+++ b/lld/wasm/MapFile.cpp
@@ -75,7 +75,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<Symbol *> syms) {
 static DenseMap<Symbol *, std::string>
 getSymbolStrings(ArrayRef<Symbol *> syms) {
   std::vector<std::string> str(syms.size());
-  parallelForEachN(0, syms.size(), [&](size_t i) {
+  parallelFor(0, syms.size(), [&](size_t i) {
     raw_string_ostream os(str[i]);
     auto *chunk = syms[i]->getChunk();
     if (chunk == nullptr)

diff  --git a/llvm/include/llvm/Support/Parallel.h b/llvm/include/llvm/Support/Parallel.h
index 04caf5eac961..ff113f9b44c4 100644
--- a/llvm/include/llvm/Support/Parallel.h
+++ b/llvm/include/llvm/Support/Parallel.h
@@ -193,11 +193,11 @@ void parallelSort(RandomAccessIterator Start, RandomAccessIterator End,
   llvm::sort(Start, End, Comp);
 }
 
-void parallelForEachN(size_t Begin, size_t End, function_ref<void(size_t)> Fn);
+void parallelFor(size_t Begin, size_t End, function_ref<void(size_t)> Fn);
 
 template <class IterTy, class FuncTy>
 void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn) {
-  parallelForEachN(0, End - Begin, [&](size_t I) { Fn(Begin[I]); });
+  parallelFor(0, End - Begin, [&](size_t I) { Fn(Begin[I]); });
 }
 
 template <class IterTy, class ResultTy, class ReduceFuncTy,

diff  --git a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
index cf6790d72f8b..262873c6e6ab 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
@@ -197,7 +197,7 @@ void GSIStreamBuilder::finalizeGlobalBuckets(uint32_t RecordZeroOffset) {
 void GSIHashStreamBuilder::finalizeBuckets(
     uint32_t RecordZeroOffset, MutableArrayRef<BulkPublic> Records) {
   // Hash every name in parallel.
-  parallelForEachN(0, Records.size(), [&](size_t I) {
+  parallelFor(0, Records.size(), [&](size_t I) {
     Records[I].setBucketIdx(hashStringV1(Records[I].Name) % IPHR_HASH);
   });
 
@@ -232,7 +232,7 @@ void GSIHashStreamBuilder::finalizeBuckets(
   // bucket can properly early-out when it detects the record won't be found.
   // The algorithm used here corresponds to the function
   // caseInsensitiveComparePchPchCchCch in the reference implementation.
-  parallelForEachN(0, IPHR_HASH, [&](size_t I) {
+  parallelFor(0, IPHR_HASH, [&](size_t I) {
     auto B = HashRecords.begin() + BucketStarts[I];
     auto E = HashRecords.begin() + BucketCursors[I];
     if (B == E)

diff  --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp
index 85426847c28c..798d7124e7e9 100644
--- a/llvm/lib/Support/Parallel.cpp
+++ b/llvm/lib/Support/Parallel.cpp
@@ -175,8 +175,8 @@ void TaskGroup::spawn(std::function<void()> F) {
 } // namespace llvm
 #endif // LLVM_ENABLE_THREADS
 
-void llvm::parallelForEachN(size_t Begin, size_t End,
-                            llvm::function_ref<void(size_t)> Fn) {
+void llvm::parallelFor(size_t Begin, size_t End,
+                       llvm::function_ref<void(size_t)> Fn) {
   // If we have zero or one items, then do not incur the overhead of spinning up
   // a task group.  They are surprisingly expensive, and because they do not
   // support nested parallelism, a single entry task group can block parallel

diff  --git a/llvm/unittests/Support/ParallelTest.cpp b/llvm/unittests/Support/ParallelTest.cpp
index f4bd10b57f89..bbf27dfab437 100644
--- a/llvm/unittests/Support/ParallelTest.cpp
+++ b/llvm/unittests/Support/ParallelTest.cpp
@@ -40,7 +40,7 @@ TEST(Parallel, parallel_for) {
   // writing.
   uint32_t range[2050];
   std::fill(range, range + 2050, 1);
-  parallelForEachN(0, 2049, [&range](size_t I) { ++range[I]; });
+  parallelFor(0, 2049, [&range](size_t I) { ++range[I]; });
 
   uint32_t expected[2049];
   std::fill(expected, expected + 2049, 2);

diff  --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md
index 5bb6ed572c39..dbb503e018d6 100644
--- a/mlir/docs/Diagnostics.md
+++ b/mlir/docs/Diagnostics.md
@@ -381,7 +381,7 @@ ParallelDiagnosticHandler handler(context);
 
 // Process a list of operations in parallel.
 std::vector<Operation *> opsToProcess = ...;
-llvm::parallelForEachN(0, opsToProcess.size(), [&](size_t i) {
+llvm::parallelFor(0, opsToProcess.size(), [&](size_t i) {
   // Notify the handler that we are processing the i'th operation.
   handler.setOrderIDForThread(i);
   auto *op = opsToProcess[i];

diff  --git a/mlir/include/mlir/IR/Threading.h b/mlir/include/mlir/IR/Threading.h
index dd99039e298a..4dc067667ea4 100644
--- a/mlir/include/mlir/IR/Threading.h
+++ b/mlir/include/mlir/IR/Threading.h
@@ -138,8 +138,7 @@ void parallelForEach(MLIRContext *context, RangeT &&range, FuncT &&func) {
 /// not have multi-threading enabled, this function always processes elements
 /// sequentially.
 template <typename FuncT>
-void parallelForEachN(MLIRContext *context, size_t begin, size_t end,
-                      FuncT &&func) {
+void parallelFor(MLIRContext *context, size_t begin, size_t end, FuncT &&func) {
   parallelForEach(context, llvm::seq(begin, end), std::forward<FuncT>(func));
 }
 


        


More information about the Mlir-commits mailing list