forked from OSchip/llvm-project
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
This commit is contained in:
parent
a5cb6edb47
commit
7effcbda49
|
@ -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++) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue