/******************************************************************* * * DESCRIPTION: class FlatCoordinatorModel * * AUTHOR: Ezequiel Glinsky * Revised By: Qi (Jacky) Liu (v1) * * EMAIL: mailto://eglinsky@sce.carleton.ca * mailto://liuqi@sce.carleton.ca * * DATE: March, 2004 * Revision Date: Oct, 2005 *******************************************************************/ #ifndef _PFCOORDSTATE_H #define _PFCOORDSTATE_H #include #include #include "port.h" #include "pProcessorState.h" #include "pprocadm.h" #include "model.h" #include "JackyDebugStream.h" //for jacky-debug-mode class ParallelFlatCoordinatorState :public ParallelProcessorState { public: ParallelFlatCoordinatorState(); virtual ~ParallelFlatCoordinatorState(); // All local dependants, their procId and absoluteNext() typedef map < ProcId, VTime, less > DependantList; //the DependantList map holds // KEY -> the Local child model's Master Processor id // VALUE -> the absoluteNext() of the dependant ParallelSimulator // this time is used to test whether the dependant is an // imminent simulator DependantList* dependants; int donecount; // Oct. 19, 2005 //this is the local InfluenceList holding ports on Local atomic models //(the corresponding simulators are dependants of this FC). This will //be filled by function findLocalInfluenceList(const Port&), and Must //be cleared in function sortExternalMessage() InfluenceList localInfluList; //list // Oct. 19, 2005 typedef set ProcSet; // Oct. 19, 2005 ProcSet synchronizeList; // Oct. 19, 2005 #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-15] //Jacky Note: //We need to define bagref in FC's state so that the FC's MessageBag can be //recovered just before the coast forward operations! //This is only for coast forward since in normal rollback operations, TimeSlices are automic //calculation units in normal rollback operations. That is, we will not be rolled back into //a particular Time Slice. And at the end of any Time Slice, the FC's MessageBag should be EMPTY! //However, if infrequent state saving strategy is used, we are forced to rollback INTO a Time Slice //and then coast forward through one/more TimeSlices depending on the state saving frequency. //Since we may start coast forward within a TimeSlice, we need to recover the status of the FC's //MessageBag to its status just before the restored state was saved. The FCBagReference is for this //purpose. typedef multimap< const VTime, BasicEvent* > FCBagReference; //pair FCBagReference fcbagref; #endif //end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-15] ParallelFlatCoordinatorState& operator=(ParallelFlatCoordinatorState& thisState); void copyState(BasicState *); int getSize() const; #ifdef JACKY_DEBUG //Jacky: this function will be defined in all state classes for ParallelProcesses & Models // to show (print) the content of the state for debugging purpose virtual void showStateContent( ostream& ) const; void showDependants( ostream& ) const; void showSyncList( ostream& ) const; void showLocalInfluList( ostream& ) const; #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-15] void showFCBagRef( ostream& ) const; #endif //end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-15] #endif }; #ifdef JACKY_DEBUG //------------------------------------------------------------------------------------------------- inline void ParallelFlatCoordinatorState::showStateContent( ostream& out ) const{ //1> first call the counterpart function in the base class ParallelProcessorState::showStateContent(out); //2> show content defined in this class out << "\tParallelFlatCoordinatorState -> dependants are: " << endl << flush; showDependants(out); out << "\tdonecount = " << donecount << endl << flush; showSyncList(out); showLocalInfluList(out); #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-15] out << endl << "\t[FC_BagRef] = " << flush; showFCBagRef(out); #endif //end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-15] } inline void ParallelFlatCoordinatorState::showDependants( ostream& out ) const{ ParallelFlatCoordinatorState::DependantList::const_iterator it; for(it = dependants->begin(); it != dependants->end(); it++){ out << "\t\t<" << it->first << " <-> " << (it->second).asString() << "> " << flush; } out << endl << flush; } inline void ParallelFlatCoordinatorState::showSyncList( ostream& out ) const{ ParallelFlatCoordinatorState::ProcSet::const_iterator it = synchronizeList.begin(); out << "\tSynchronizeList: < " << flush; if( synchronizeList.size() == 0 ){ out << "EMPTY >" << endl << flush; } else { for( ; it != synchronizeList.end(); it++){ out << (*it) << ", " << flush; } out << " >" << endl << flush; } } inline void ParallelFlatCoordinatorState::showLocalInfluList( ostream& out ) const { InfluenceList::const_iterator it = localInfluList.begin(); out << "\tLocalInfluList: < " << flush; if( localInfluList.size() == 0 ){ out << "EMPTY >" << endl << flush; } else { for( ; it != localInfluList.end(); it++){ out << (*it)->name() << "@" << ((*it)->model()).asString() << ", " << flush; } out << " >" << endl << flush; } } #if defined(JACKY_INFREQ_STATEMANAGER) && defined(INFREQSTATEMANAGER) //[2006-03-15] inline void ParallelFlatCoordinatorState::showFCBagRef( ostream& out ) const { if( fcbagref.size() > 0 ){ ParallelFlatCoordinatorState::FCBagReference::const_iterator pos = fcbagref.begin(); for( ; pos != fcbagref.end(); pos++ ){ //print out the recvTime of the BasicEvent, and its address out << "<" << (pos->first).asString() << ", " << pos->second << "> " << flush; } out << endl << flush; } else { out << "-> EMPTY!" << endl << flush; } } #endif //end JACKY_INFREQ_STATEMANAGER && INFREQSTATEMANAGER //[2006-03-15] #endif //end JACKY_DEBUG ------------------------------------------------------------------------------------------- #endif //_PNCOORDSTATE_H