Skip to content
Snippets Groups Projects
Commit 34c34b8b authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Merge branch 'make_unique_alglist_unique' into 'master'

Make sure that entries in m_flatUniqueAlgList are actually unique

See merge request !255

Conflicts:
	GaudiHive/src/AlgResourcePool.cpp
parents b0466c4d b461d0a5
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -189,32 +189,31 @@ StatusCode AlgResourcePool::flattenSequencer(Algorithm* algo, ListAlg& alglist, ...@@ -189,32 +189,31 @@ StatusCode AlgResourcePool::flattenSequencer(Algorithm* algo, ListAlg& alglist,
if (algo->hasProperty("Members")) { if (algo->hasProperty("Members")) {
if (algo->hasProperty("ShortCircuit")) { if (algo->hasProperty("ShortCircuit")) {
isGaudiSequencer = true; isGaudiSequencer = true;
isAtomicSeq = ( algo->hasProperty("Atomic") && isAtomicSeq = ( algo->hasProperty("Atomic") &&
(algo->getProperty("Atomic").toString() == "True") ); (algo->getProperty("Atomic").toString() == "True") );
} else if (algo->hasProperty("StopOverride")) { } else if (algo->hasProperty("StopOverride")) {
isAthSequencer = true; isAthSequencer = true;
isAtomicSeq = ( algo->hasProperty("Atomic") && isAtomicSeq = ( algo->hasProperty("Atomic") &&
(algo->getProperty("Atomic").toString() == "True") ); (algo->getProperty("Atomic").toString() == "True") );
} }
} }
std::vector<Algorithm*>* subAlgorithms = algo->subAlgorithms(); std::vector<Algorithm*>* subAlgorithms = algo->subAlgorithms();
if ( //we only want to add basic algorithms -> have no subAlgs if ( //we only want to add basic algorithms -> have no subAlgs
// and exclude the case of empty GaudiSequencers // and exclude the case of empty sequencers
(subAlgorithms->empty() and not (isGaudiSequencer (subAlgorithms->empty() && !(isGaudiSequencer || isAthSequencer))
|| isAthSequencer) ) // we want to add non-empty atomic sequencers
// we want to add non-empty AtomicSequencers or (isAtomicSeq && !subAlgorithms->empty()) ) {
or (isAtomicSeq and not subAlgorithms->empty())
){ ON_DEBUG {
debug() << std::string(recursionDepth, ' ') << algo->name() << " is ";
debug() << std::string(recursionDepth, ' ') << algo->name() << " is "; if (isAtomicSeq) {
if (isAtomicSeq) { debug() << "an atomic sequencer";
debug() << "an atomic sequencer"; } else {
} else { debug() << "not a sequencer";
debug() << "not a sequencer"; }
debug() << ". Appending it" << endmsg;
} }
debug() << ". Appending it" << endmsg;
alglist.emplace_back(algo); alglist.emplace_back(algo);
m_PRGraph->addAlgorithmNode(algo, parentName, false, false).ignore(); m_PRGraph->addAlgorithmNode(algo, parentName, false, false).ignore();
...@@ -305,11 +304,19 @@ StatusCode AlgResourcePool::decodeTopAlgs() { ...@@ -305,11 +304,19 @@ StatusCode AlgResourcePool::decodeTopAlgs() {
m_PRGraph->addHeadNode("EVENT LOOP",true,true,false); m_PRGraph->addHeadNode("EVENT LOOP",true,true,false);
// Now we unroll it ---- // Now we unroll it ----
for (auto& algoSmartIF : m_topAlgList){ for (auto& algoSmartIF : m_topAlgList) {
Algorithm* algorithm = dynamic_cast<Algorithm*> (algoSmartIF.get()); Algorithm* algorithm = dynamic_cast<Algorithm*> (algoSmartIF.get());
if (!algorithm) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg; if (!algorithm) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
sc = flattenSequencer(algorithm, m_flatUniqueAlgList, "EVENT LOOP"); sc = flattenSequencer(algorithm, m_flatUniqueAlgList, "EVENT LOOP");
} }
// stupid O(N^2) unique-ification..
for ( auto i = begin(m_flatUniqueAlgList); i!=end(m_flatUniqueAlgList); ++i ) {
auto n = next(i);
while ( n!=end(m_flatUniqueAlgList) ) {
if (*n==*i) n = m_flatUniqueAlgList.erase(n);
else ++n;
}
}
if (msgLevel(MSG::DEBUG)){ if (msgLevel(MSG::DEBUG)){
debug() << "List of algorithms is: " << endmsg; debug() << "List of algorithms is: " << endmsg;
for (auto& algo : m_flatUniqueAlgList) for (auto& algo : m_flatUniqueAlgList)
...@@ -346,11 +353,9 @@ StatusCode AlgResourcePool::decodeTopAlgs() { ...@@ -346,11 +353,9 @@ StatusCode AlgResourcePool::decodeTopAlgs() {
state_type requirements(0); state_type requirements(0);
for (auto& resource_name : ialgo->neededResources()){ for (auto& resource_name : ialgo->neededResources()){
auto ret = m_resource_indices.insert(std::pair<std::string, unsigned int>(resource_name,resource_counter)); auto ret = m_resource_indices.emplace(resource_name,resource_counter);
// insert successful means == wasn't known before. So increment counter // insert successful means == wasn't known before. So increment counter
if (ret.second==true) { if (ret.second) ++resource_counter;
++resource_counter;
}
// Resize for every algo according to the found resources // Resize for every algo according to the found resources
requirements.resize(resource_counter); requirements.resize(resource_counter);
// in any case the return value holds the proper product index // in any case the return value holds the proper product index
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment