Skip to content

Commit 1840985

Browse files
authored
Merge pull request #48807 from Dr15Jones/staticNoProcess
Determine non-process name lookups at begin job
2 parents 5c77e25 + 8572541 commit 1840985

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+862
-1090
lines changed

DataFormats/Provenance/interface/ProductRegistry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ namespace edm {
182182
iter->second.merge(prod.second);
183183
}
184184
}
185+
mergeProcessOrderFromAddInput(iReg.processOrder());
185186
}
186187

187188
private:
@@ -206,6 +207,7 @@ namespace edm {
206207

207208
void checkForDuplicateProcessName(ProductDescription const& desc, std::string const* processName) const;
208209
void updateProcessOrder(std::vector<std::string> const& processOrder);
210+
void mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder);
209211

210212
void throwIfNotFrozen() const;
211213
void throwIfFrozen() const;

DataFormats/Provenance/interface/ProductResolverIndexHelper.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ namespace edm {
156156
char const* moduleLabel,
157157
char const* instance) const;
158158

159-
// Return indexes for all groups that match the type.
160-
Matches relatedIndexes(KindOfType kindOfType, TypeID const& typeID) const;
161-
162159
// This will throw if called after the object is frozen.
163160
// The typeID must be for a type with a dictionary
164161
// (the calling function is expected to check that)
@@ -196,15 +193,13 @@ namespace edm {
196193
// Before the object is frozen the accessors above will
197194
// fail to find a match. Once frozen, no more new entries
198195
// can be added with insert.
199-
void setFrozen(std::string_view processName);
196+
void setFrozen(std::vector<std::string> const& orderedProcessNames);
200197

201198
/**The list of process names for data products associated to the ProductResolvers.
202199
* If no products are associated with a process for this transition, the process name will not be in this list.
203200
*/
204201
std::vector<std::string> const& lookupProcessNames() const;
205202

206-
bool producesInCurrentProcess() const { return producesInCurrentProcess_; }
207-
208203
class Range {
209204
public:
210205
Range(unsigned int begin, unsigned int end) : begin_(begin), end_(end) {}
@@ -263,6 +258,10 @@ namespace edm {
263258
// For debugging only
264259
void print(std::ostream& os) const;
265260

261+
//ProcessName label used to denote the current process should be skipped
262+
//used by all methods of this class that accept the process name
263+
static constexpr char const* const skipCurrentProcessLabel() { return "#"; }
264+
266265
private:
267266
// Next available value for a ProductResolverIndex. This just
268267
// increments by one each time a new value is assigned.
@@ -335,6 +334,7 @@ namespace edm {
335334
ProductResolverIndex index() const { return index_; }
336335

337336
void clearProcess() { process_.clear(); }
337+
void setSkipCurrentProcess() { process_ = ProductResolverIndexHelper::skipCurrentProcessLabel(); }
338338
void setIndex(ProductResolverIndex v) { index_ = v; }
339339

340340
bool operator<(Item const& right) const;
@@ -351,8 +351,6 @@ namespace edm {
351351
edm::propagate_const<std::unique_ptr<std::set<Item>>> items_;
352352

353353
edm::propagate_const<std::unique_ptr<std::set<std::string>>> processItems_;
354-
355-
bool producesInCurrentProcess_{false};
356354
};
357355
} // namespace edm
358356
#endif

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ namespace edm {
218218
processingOrderMerge(processOrder, transient_.processOrder_);
219219
}
220220

221+
void ProductRegistry::mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder) {
222+
if (processOrder.empty())
223+
return;
224+
//see if the input already has the current process
225+
if (not transient_.processOrder_.empty() and (transient_.processOrder_[0] != processOrder[0])) {
226+
transient_.processOrder_.insert(transient_.processOrder_.end(), processOrder.begin(), processOrder.end());
227+
} else {
228+
updateProcessOrder(processOrder);
229+
}
230+
}
231+
221232
void ProductRegistry::setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
222233
throwIfFrozen();
223234

@@ -250,9 +261,20 @@ namespace edm {
250261
std::string ProductRegistry::merge(ProductRegistry const& other,
251262
std::string const& fileName,
252263
ProductDescription::MatchMode branchesMustMatch) {
253-
if (branchesMustMatch == ProductDescription::FromInputToCurrent and transient_.processOrder_.size() == 1) {
254-
transient_.processOrder_.insert(
255-
transient_.processOrder_.end(), other.transient_.processOrder_.begin(), other.transient_.processOrder_.end());
264+
if (branchesMustMatch == ProductDescription::FromInputToCurrent) {
265+
if (processOrder().size() == 1 and not other.processOrder().empty() and
266+
processOrder()[0] != other.processOrder()[0]) {
267+
assert(transient_.processOrder_.size() == 1);
268+
transient_.processOrder_.insert(transient_.processOrder_.end(),
269+
other.transient_.processOrder_.begin(),
270+
other.transient_.processOrder_.end());
271+
} else {
272+
//the current process must not change
273+
assert(not processOrder().empty());
274+
auto current = processOrder()[0];
275+
processingOrderMerge(other.processOrder(), transient_.processOrder_);
276+
assert(current == processOrder()[0]);
277+
}
256278
} else {
257279
processingOrderMerge(other.processOrder(), transient_.processOrder_);
258280
}
@@ -310,6 +332,7 @@ namespace edm {
310332
std::vector<std::string> producedTypes;
311333

312334
transient_.branchIDToIndex_.clear();
335+
assert(productList_.empty() or !processOrder().empty());
313336

314337
std::array<std::shared_ptr<ProductResolverIndexHelper>, NumBranchTypes> new_productLookups{
315338
{std::make_shared<ProductResolverIndexHelper>(),
@@ -450,9 +473,8 @@ namespace edm {
450473
throwMissingDictionariesException(missingDictionaries, context, producedTypes, branchNamesForMissing);
451474
}
452475

453-
std::string_view processNameSV(processName ? std::string_view(*processName) : std::string_view());
454476
for (auto& iterProductLookup : new_productLookups) {
455-
iterProductLookup->setFrozen(processNameSV);
477+
iterProductLookup->setFrozen(processOrder());
456478
}
457479
for (size_t i = 0; i < new_productLookups.size(); ++i) {
458480
transient_.productLookups_[i] = std::move(new_productLookups[i]);

0 commit comments

Comments
 (0)