diff --git a/GaudiHive/src/AvalancheSchedulerSvc.cpp b/GaudiHive/src/AvalancheSchedulerSvc.cpp index 8ca5fba3af90aa793d02ed1a756729db162d3d07..fb646b0c7c5eb1e323ef3265c7d093ed6cf96a70 100644 --- a/GaudiHive/src/AvalancheSchedulerSvc.cpp +++ b/GaudiHive/src/AvalancheSchedulerSvc.cpp @@ -302,8 +302,8 @@ StatusCode AvalancheSchedulerSvc::initialize() SmartIF<IMessageSvc> messageSvc( serviceLocator() ); if ( !messageSvc.isValid() ) error() << "Error retrieving MessageSvc interface IMessageSvc." << endmsg; - m_eventSlots.assign( m_maxEventsInFlight, EventSlot( m_algosDependencies, algsNumber, - precSvc->getRules()->getControlFlowNodeCounter(), messageSvc ) ); + m_eventSlots.assign( m_maxEventsInFlight, + EventSlot( algsNumber, precSvc->getRules()->getControlFlowNodeCounter(), messageSvc ) ); std::for_each( m_eventSlots.begin(), m_eventSlots.end(), []( EventSlot& slot ) { slot.complete = true; } ); if ( m_threadPoolSize > 1 ) { @@ -832,34 +832,9 @@ void AvalancheSchedulerSvc::dumpSchedulerState( int iSlot ) << " event: " << thisSlot.eventContext->evt() << " -----------" << std::endl; if ( 0 > iSlot or iSlot == slotCount ) { - outputMessageStream << "Algorithms states:" << std::endl; - - const DataObjIDColl& wbSlotContent( thisSlot.dataFlowMgr.content() ); - for ( unsigned int algoIdx = 0; algoIdx < thisSlot.algsStates.size(); ++algoIdx ) { - outputMessageStream << " o " << index2algname( algoIdx ) << " [" - << AlgsExecutionStates::stateNames[thisSlot.algsStates[algoIdx]] << "] Data deps: "; - DataObjIDColl deps( thisSlot.dataFlowMgr.dataDependencies( algoIdx ) ); - const int depsSize = deps.size(); - if ( depsSize == 0 ) outputMessageStream << " none"; - - DataObjIDColl missing; - for ( auto d : deps ) { - outputMessageStream << d << " "; - if ( wbSlotContent.find( d ) == wbSlotContent.end() ) { - // outputMessageStream << "[missing] "; - missing.insert( d ); - } - } - - outputMessageStream << std::endl; - } - - // Snapshot of the WhiteBoard - outputMessageStream << "\nWhiteboard contents: " << std::endl; - for ( auto& product : wbSlotContent ) outputMessageStream << " o " << product << std::endl; - // Snapshot of the ControlFlow - outputMessageStream << "\nControl Flow:" << std::endl; + // Snapshot of the Control Flow and FSM states + outputMessageStream << "\nControl Flow and FSM states:" << std::endl; outputMessageStream << m_precSvc->printState( thisSlot ) << std::endl; } } diff --git a/GaudiHive/src/DataFlowManager.cpp b/GaudiHive/src/DataFlowManager.cpp deleted file mode 100644 index bfb0f10d873cb31f7decde3d014f09175e382ad0..0000000000000000000000000000000000000000 --- a/GaudiHive/src/DataFlowManager.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "DataFlowManager.h" - -//--------------------------------------------------------------------------- -// Static members -std::vector<DataFlowManager::dependency_bitset> DataFlowManager::m_algosRequirements; -std::unordered_map<DataObjID, long int, DataObjID_Hasher> DataFlowManager::m_productName_index_map; -std::vector<DataObjID> DataFlowManager::m_productName_vec; -//--------------------------------------------------------------------------- -/** - * If this is the first instance, the constructor fills the requirements of - * all algorithms and indexes the data products. - */ -DataFlowManager::DataFlowManager( algosDependenciesCollection algosDependencies ) -{ - - // Count how many products are actually requested - unsigned int nProducts( 0 ); - for ( auto& thisAlgoDependencies : algosDependencies ) { - nProducts += thisAlgoDependencies.size(); - } - m_dataObjectsCatalog.resize( nProducts ); - - // If it's not the first instance, nothing to do here - if ( m_algosRequirements.size() == 0 ) { - // This is the first instance, compile the requirements - m_algosRequirements.resize( algosDependencies.size(), dependency_bitset( nProducts ) ); - - // Fill the requirements - unsigned int algoIndex = 0; - long int productIndex = 0; - for ( auto& thisAlgoDependencies : algosDependencies ) { - // Make a local alias for better readability - auto& dependency_bits = m_algosRequirements[algoIndex]; - for ( auto& product : thisAlgoDependencies ) { - auto ret_val = m_productName_index_map.insert( std::pair<DataObjID, long int>( product, productIndex ) ); - // insert successful means product wasn't known before. So increment counter - if ( ret_val.second == true ) ++productIndex; - // in any case the return value holds the proper product index - dependency_bits[ret_val.first->second] = true; - } // end loop on products on which the algo depends - algoIndex++; - } // end loop on algorithms - - // Now the vector of products - m_productName_vec.resize( m_productName_index_map.size() ); - for ( auto& name_idx : m_productName_index_map ) m_productName_vec[name_idx.second] = name_idx.first; - } -} - -//--------------------------------------------------------------------------- - -/** - * This method is called to know if the algorithm can run according to what - * data objects are in the event. - */ -bool DataFlowManager::canAlgorithmRun( unsigned int iAlgo ) -{ - const dependency_bitset& thisAlgoRequirements = m_algosRequirements[iAlgo]; - return thisAlgoRequirements.is_subset_of( m_dataObjectsCatalog ); -} - -//--------------------------------------------------------------------------- - -/// Update the catalog of available products in the slot -void DataFlowManager::updateDataObjectsCatalog( const DataObjIDColl& newProducts ) -{ - for ( const auto& new_product : newProducts ) { - m_fc.insert( new_product ); - const int index = productName2index( new_product ); - if ( index >= 0 ) m_dataObjectsCatalog[index] = true; - } -} - -//--------------------------------------------------------------------------- - -/// Reset the slot for a new event -void DataFlowManager::reset() -{ - m_dataObjectsCatalog.reset(); - m_fc.clear(); -} - -//--------------------------------------------------------------------------- - -/// Get the content (inefficient, only for debug in case of crashes) -DataObjIDColl DataFlowManager::content() const -{ - DataObjIDColl products; - for ( const auto& p : m_fc ) { - products.insert( p ); - } - return products; -} - -//--------------------------------------------------------------------------- -/// Get the data dependencies (inefficient, only for debug in case of crashes) -DataObjIDColl DataFlowManager::dataDependencies( unsigned int iAlgo ) const -{ - // with move semantics this is ~fine - DataObjIDColl deps; - for ( unsigned int i = 0; i < m_productName_vec.size(); ++i ) { - if ( m_algosRequirements[iAlgo][i] ) deps.insert( m_productName_vec[i] ); - } - return deps; -} - -//--------------------------------------------------------------------------- diff --git a/GaudiHive/src/DataFlowManager.h b/GaudiHive/src/DataFlowManager.h deleted file mode 100644 index 6314bccc18ddecbb837461f7472097c2ae81fbb7..0000000000000000000000000000000000000000 --- a/GaudiHive/src/DataFlowManager.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef GAUDIHIVE_DATAFLOWMANAGER_H -#define GAUDIHIVE_DATAFLOWMANAGER_H - -// FW includes -#include "GaudiKernel/DataObjID.h" -#include "GaudiKernel/IAlgorithm.h" -#include "GaudiKernel/SmartIF.h" - -// boost -#include "boost/dynamic_bitset.hpp" - -// std includes -#include <list> -#include <set> -#include <unordered_map> -#include <unordered_set> -#include <vector> - -/**@class DataFlowManager DataFlowManager.h GaudiHive/src/DataFlowManager.h - * - * The DataFlowManager takes care of keeping track of the dependencies of - * the algorithms in terms of dataObjects. - * One instance of the DataFlowManager is responsible for one event. - * - * @author Danilo Piparo, Benedikt Hegner - * @version 1.0 - */ -class DataFlowManager -{ - -public: - /// Type holding the dependencies for one single algorithm - typedef boost::dynamic_bitset<> dependency_bitset; - - typedef std::vector<DataObjIDColl> algosDependenciesCollection; - /// Constructor - DataFlowManager( const std::list<IAlgorithm*>& /*algos*/ ) : m_dataObjectsCatalog( 0 ){}; - - /// Constructor (transitional, will be deprecated once handles are in place) - DataFlowManager( algosDependenciesCollection algoDependencies ); - - /// Needed data products are available - bool canAlgorithmRun( unsigned int iAlgo ); - - /// Update the catalog of available products in the slot - void updateDataObjectsCatalog( const DataObjIDColl& newProducts ); - - /// Reset to default values - void reset(); - - /// Get the content of the catalog - DataObjIDColl content() const; - - /// Get the dependencies of a single algo; - DataObjIDColl dataDependencies( unsigned int iAlgo ) const; - -private: - DataObjIDColl m_fc; - - /// Catalog of the products in the whiteboard - dependency_bitset m_dataObjectsCatalog; - /// Requirements of algos. Static since the same for all events. - static std::vector<dependency_bitset> m_algosRequirements; - /// Track the products, assigning an index to them. Static since the same for all events. - static std::vector<DataObjID> m_productName_vec; - /// Track the products, assigning an index to them. Static since the same for all events. - typedef DataObjID productName_t; - - static std::unordered_map<productName_t, long int, DataObjID_Hasher> m_productName_index_map; - /// Simple helper method to convert the product name into an index - inline long int productName2index( const productName_t& productName ) - { - return m_productName_index_map.count( productName ) > 0 ? m_productName_index_map[productName] : -1; - }; - /// Simple helper method to convert an index to a product name - inline DataObjID& index2productName( const unsigned int i ) { return m_productName_vec[i]; }; -}; - -#endif diff --git a/GaudiHive/src/EventSlot.h b/GaudiHive/src/EventSlot.h index 232cef43b23f6071fc535f40008945a2853e8b40..9f620e6a9ef83e5b086e3baa2b88daf0af3b4fd2 100644 --- a/GaudiHive/src/EventSlot.h +++ b/GaudiHive/src/EventSlot.h @@ -3,7 +3,6 @@ // Framework includes #include "AlgsExecutionStates.h" -#include "DataFlowManager.h" #include "GaudiKernel/EventContext.h" // Event slots management ------------------------------------------------- @@ -11,12 +10,10 @@ class EventSlot { public: - EventSlot( const std::vector<DataObjIDColl>& algoDependencies, unsigned int numberOfAlgorithms, - unsigned int numberOfControlFlowNodes, SmartIF<IMessageSvc> MS ) + EventSlot( unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF<IMessageSvc> MS ) : eventContext( nullptr ) , algsStates( numberOfAlgorithms, MS ) , complete( false ) - , dataFlowMgr( algoDependencies ) , controlFlowState( numberOfControlFlowNodes, -1 ){}; ~EventSlot(){}; @@ -26,7 +23,6 @@ public: { eventContext = theeventContext; algsStates.reset(); - dataFlowMgr.reset(); complete = false; controlFlowState.assign( controlFlowState.size(), -1 ); }; @@ -37,8 +33,6 @@ public: AlgsExecutionStates algsStates; /// Flags completion of the event bool complete; - /// DataFlowManager of this slot - DataFlowManager dataFlowMgr; /// State of the control flow std::vector<int> controlFlowState; };