/******************************************************************* * * DESCRIPTION: class ParallelMainSimulator * * AUTHOR: Ezequiel Glinsky * *******************************************************************/ #ifndef __PARALLELSIMULATOR_H #define __PARALLELSIMULATOR_H /** include files **/ #include #include "eventlist.h" #include "proot.h" // EventList #include "ini.h" // class Ini #include "pini.h" // class PIni #include "loader.h" // class SimLoader #include "ltranadm.h" // class LocalTransAdmin #include "log.h" #include "LogicalProcess.hh" // Warped logical process //define JACKY_DEBUG macro and the jacky debug fstream #include "JackyDebugStream.h" #ifdef JACKY_UNIQUE_LOG //[2006-04-26] class ParallelNodeCoordinator; #endif //end JACKY_UNIQUE_LOG [2006-04-26] /** declarations **/ class ParallelMainSimulator { public: typedef hash_map< MachineId, ProcId> NodeCoordinatorsList; typedef hash_map< MachineId, ProcId> FlatCoordinatorsList; NodeCoordinatorsList nodeCoordinatorsList; FlatCoordinatorsList flatCoordinatorsList; static ParallelMainSimulator &Instance() ; ParallelMainSimulator &loader( SimLoader *l ) {sloader = l; return *this;} void registerNewAtomics() ; string outputName() {return loader()->outputName();} string logName() {return Log::Default.filename();} ostream &debugStream(); #ifdef JACKY_UNIQUE_LOG //[2006-04-26] ================================= //if we use "One Log File per Node" strategy, all log data will be //written to the outFileQ[logIndex] of the local NC. //This pointer is defined to point to the local NC, so that all other //processors can easily find it and get the outFileQ[logIndex] in it. ParallelNodeCoordinator *localNC; //this pointer to the local NC is initialized to NULL, and will be //set to the address of the local NC by function //ParallelProcessorAdmin::generateNodeCoordinator() at the time when //the local NC is created. #endif //end JACKY_UNIQUE_LOG //[2006-04-26] =========================== #ifdef JACKY_DEBUG //print out the simArray in each LP void printSimArray(ostream& out); void printModels(ostream& out); void printProcessors(ostream& out); void printNCList(ostream& out); void printFCList(ostream& out); void printDependantList(ostream& out); void printSlaves(ostream& out); const EventList& getEventsInNC(); //const EventList& getEventsInFC(); //no event lists in FC anymore LogicalProcess* getLP(){ return lp; } #endif #ifdef JACKY_RB_ZERO //Nov. 7, 2005 //Jacky Note: this function is made public! ParallelMainSimulator &afterInitialize(); #endif ostream &evalDebugStream() {return EvalDebug().Stream();} bool evalDebug() {return EvalDebug().Active();} bool existsParameter( const string &modelName, const string ¶meterName ) const {return iniFile().exists( modelName, parameterName );} const string getParameter( const string &modelName, const string ¶meterName ) const ; SimLoader *loader() {return sloader;} ParallelMainSimulator &run(); int getMachineID(); virtual ~ParallelMainSimulator(); // We store all the input & output ports virtual const PortList &allInputPorts() const {return allinputports;} virtual const PortList &allOutputPorts() const {return alloutputports;} virtual const PortList &allPorts() const {return allports;} virtual PortList &allInputPorts() {return allinputports;} virtual PortList &allOutputPorts() {return alloutputports;} virtual PortList &allPorts() {return allports;} // We store all the links virtual const PortLinksList &allPortLinks() const {return allportlinks;} virtual PortLinksList &allPortLinks() {return allportlinks;} virtual ParallelMainSimulator &debugFlattenedLinks(); virtual ParallelMainSimulator &flattenLinks(); virtual ParallelMainSimulator &debugInputPorts(); virtual ParallelMainSimulator &debugOutputPorts(); #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-20] ----------------------------- #if defined(JACKY_FOSSIL_COLLECTION_STRATEGY_A) //[2006-03-26] //add a public function to get the value of flag "topHasOutputPorts" bool isTopHasOutputPorts(){ return topHasOutputPorts; } #endif //end JACKY_FOSSIL_COLLECTION_STRATEGY_A [2006-03-26] #endif // end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-20] ------------------------------------- protected: friend class ParallelRoot; friend class CoupledCell; friend class Coupled ; friend class Atomic ; friend class Model; // ** class variables ** // static ParallelMainSimulator *instance ; // ** instance constants ** // const char separator ; const char *componentLabel ; const char *inPortsLabel ; const char *outPortsLabel ; const char *linksLabel ; #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-20] ----------------------------- #if defined(JACKY_FOSSIL_COLLECTION_STRATEGY_A) //[2006-03-26] //If InfreqStateManager is used, we need to decide whether ParallelRoot needs to participate in calculating //the lVT value of the LAST state before gVT in GVTManager::gcollect() or not. The criterion is: //if the TOP model has output ports, then ParallelRoot will participate in the calculation since there may //be (Y) messages received by the Root, and the Root may be rolled back (thus do coast-forward operations). //if the TOP model has no output ports, then ParallelRoot will not participate in the calculation. //this flag is added to identify whether the TOP model has output ports //the default is false (i.e. TOP has no output ports). //In function loadPorts(), parsimu will test if the TOP has output ports. If it has, then we set the flag to true. //The ParalleProcessorAdmin will test this flag to set the "skipCalculateLVT" flag for the Root! bool topHasOutputPorts; #endif //end JACKY_FOSSIL_COLLECTION_STRATEGY_A [2006-03-26] #endif // end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-20] ------------------------------------- // ** Methods ** // ParallelMainSimulator() ; // ** Methods ** // ParallelMainSimulator &loadModels( istream&, istream&, bool printParserInfo ) ; ParallelMainSimulator &setUpLogicalProcess(); ParallelMainSimulator &loadExternalEvents( istream& ) ; ParallelMainSimulator &log( ostream & ) ; ParallelMainSimulator &output( ostream & ) ; ParallelMainSimulator &loadModel( Coupled &, bool ) ; ParallelMainSimulator &loadPorts( Coupled & ) ; ParallelMainSimulator &loadComponents( Coupled &, bool ) ; ParallelMainSimulator &loadLinks( Coupled & ) ; ParallelMainSimulator &loadCells( CoupledCell &, bool ) ; ParallelMainSimulator &loadStateVariables( CoupledCell &, bool ) ; ParallelMainSimulator &loadMachines( Atomic & ); ParallelMainSimulator &loadMachines (Coupled & ); ParallelMainSimulator &loadMachines( CoupledCell &coupledcell ); ParallelMainSimulator &loadInitialCellValues( CoupledCell & ) ; ParallelMainSimulator &loadInitialCellValuesFromFile( CoupledCell &parent, const string &fileName ); ParallelMainSimulator &loadInitialCellValuesFromMapFile( CoupledCell &parent, const string &fileName ); ParallelMainSimulator &loadStateVariables( CoupledCell & ) ; ParallelMainSimulator &loadInitialVariablesValues( CoupledCell & ) ; ParallelMainSimulator &loadInitialVariablesValuesFromFile( CoupledCell &parent, const string &fileName ); ParallelMainSimulator &loadDefaultTransitions( CoupledCell &, bool ) ; ParallelMainSimulator &loadPortInTransitions( CoupledCell &, bool ) ; ParallelMainSimulator &loadLocalZones( CoupledCell &, bool ) ; ParallelMainSimulator ®isterTransition(const LocalTransAdmin::Function &, bool ); ParallelMainSimulator ®isterTransitionPortIn(const LocalTransAdmin::Function &, bool, const string & ); #ifndef JACKY_RB_ZERO //Nov. 7, 2005 //Jacky Note: this function is made public! ParallelMainSimulator &afterInitialize(); #endif #ifndef KERNEL_NOTIME ParallelMainSimulator &calculateGVT() { lp->calculateGVT(); return *this; } #endif void showEvents( const EventList &events, ostream &out = cout ) ; void showModelPartition( ostream &out = cout ); void showLogInfo( ostream &out = cout ); bool splitString( const string &full, string &first, string &second, char separator ); const Ini &iniFile() const {return ini;} const PIni &pIniFile() const { return pini; } private: // ** instance variables ** // SimLoader *sloader ; ostream *vDebugStream; Ini ini; PIni pini; LogicalProcess *lp; PortList allinputports ; PortList alloutputports ; PortList allports ; PortLinksList allportlinks ; }; // class ParallelMainSimulator /*inline*/ inline int ParallelMainSimulator::getMachineID() { return loader()->machineID; } #endif //__ParallelMainSimulator_H