diff --git a/simulators/c++2/src_simulator/TMLTransaction.cpp b/simulators/c++2/src_simulator/TMLTransaction.cpp index 66f2d39c8a408ad82ef9cac1d420691acced1296..51c2b2eaf138a307f7a41b49c6910f3a618f9829 100755 --- a/simulators/c++2/src_simulator/TMLTransaction.cpp +++ b/simulators/c++2/src_simulator/TMLTransaction.cpp @@ -56,7 +56,7 @@ TMLTransaction::TMLTransaction():_runnableTime(0), _startTime(0), _length(0), _v } -TMLTransaction::TMLTransaction(TMLCommand* iCommand, TMLLength iVirtualLength, TMLTime iRunnableTime, TMLChannel* iChannel):_runnableTime(iRunnableTime), _startTime(0), _length(0), _virtualLength(iVirtualLength), _command(iCommand), +TMLTransaction::TMLTransaction(TMLCommand* iCommand, TMLLength iVirtualLength, TMLTime iRunnableTime, TMLChannel* iChannel):_runnableTime(iRunnableTime), _startTime(0), _length(0), _virtualLength(iVirtualLength), _command(iCommand),_endState(false), #ifdef PENALTIES_ENABLED _idlePenalty(0), _taskSwitchingPenalty(0), //, _branchingPenalty(0), #endif diff --git a/simulators/c++2/src_simulator/TMLTransaction.h b/simulators/c++2/src_simulator/TMLTransaction.h index f316cc112e6e842c396a3f66b738371e693c00a0..7fcebbdd81553ef9144a9b3420e46ae36ac99024 100644 --- a/simulators/c++2/src_simulator/TMLTransaction.h +++ b/simulators/c++2/src_simulator/TMLTransaction.h @@ -166,6 +166,7 @@ class TMLTransaction { return _startTime + _length; #endif } + ///Returns the idle panalty of the transaction /** \return Idle penalty diff --git a/simulators/c++2/src_simulator/app/TMLTask.cpp b/simulators/c++2/src_simulator/app/TMLTask.cpp index ad659e5e1e2885fd852347d509bf0bee73b1a4f4..b1d077de335682c7e8c5c0a24241257bf6eb691a 100755 --- a/simulators/c++2/src_simulator/app/TMLTask.cpp +++ b/simulators/c++2/src_simulator/app/TMLTask.cpp @@ -48,7 +48,7 @@ Ludovic Apvrille, Renaud Pacalet unsigned int TMLTask::_instanceCount=1; -TMLTask::TMLTask(ID iID, Priority iPriority, std::string iName, CPU** iCPU, unsigned int iNoOfCPUs): WorkloadSource(iPriority), _ID(iID), _name(iName), _endLastTransaction(0), _currCommand(0), _firstCommand(0), _currentCPU(0), _cpus(iCPU), _noOfCPUs(iNoOfCPUs), _nextCellIndex(0), _comment(0), _busyCycles(0), _CPUContentionDelay(0), _noCPUTransactions(0), _justStarted(true), _myInstance(_instanceCount), /*_isScheduled(false),*/ _stateHash(0, 30) , _liveVarList(0), _hashInvalidated(true){ +TMLTask::TMLTask(ID iID, Priority iPriority, std::string iName, CPU** iCPU, unsigned int iNoOfCPUs, bool isDaemon): WorkloadSource(iPriority), _ID(iID), _name(iName), _endLastTransaction(0), _currCommand(0), _firstCommand(0), _currentCPU(0), _cpus(iCPU), _noOfCPUs(iNoOfCPUs), _isDaemon(isDaemon), _nextCellIndex(0), _comment(0), _busyCycles(0), _CPUContentionDelay(0), _noCPUTransactions(0), _justStarted(true), _myInstance(_instanceCount), /*_isScheduled(false),*/ _stateHash(0, 30) , _liveVarList(0), _hashInvalidated(true){ for (unsigned int i=0; i< _noOfCPUs; i++) _cpus[i]->registerTask(this); #ifdef ADD_COMMENTS @@ -59,7 +59,7 @@ TMLTask::TMLTask(ID iID, Priority iPriority, std::string iName, CPU** iCPU, unsi if (_noOfCPUs==1) _currentCPU = _cpus[0]; } -TMLTask::TMLTask(ID iID, Priority iPriority, std::string iName, FPGA** iFPGA, unsigned int iNoOfFPGAs): WorkloadSource(iPriority), _ID(iID), _name(iName), _endLastTransaction(0), _currCommand(0), _firstCommand(0), _currentFPGA(0), _fpgas(iFPGA), _noOfFPGAs(iNoOfFPGAs), _nextCellIndex(0),_comment(0), _busyCycles(0), _FPGAContentionDelay(0), _noFPGATransactions(0), _justStarted(true), _myInstance(_instanceCount), +TMLTask::TMLTask(ID iID, Priority iPriority, std::string iName, FPGA** iFPGA, unsigned int iNoOfFPGAs, bool isDaemon): WorkloadSource(iPriority), _ID(iID), _name(iName), _endLastTransaction(0), _currCommand(0), _firstCommand(0), _currentFPGA(0), _fpgas(iFPGA), _noOfFPGAs(iNoOfFPGAs), _isDaemon(isDaemon), _nextCellIndex(0),_comment(0), _busyCycles(0), _FPGAContentionDelay(0), _noFPGATransactions(0), _justStarted(true), _myInstance(_instanceCount), _stateHash(0, 30) , _liveVarList(0), _hashInvalidated(true){ for (unsigned int i=0; i< _noOfFPGAs; i++) _fpgas[i]->registerTask(this); diff --git a/simulators/c++2/src_simulator/app/TMLTask.h b/simulators/c++2/src_simulator/app/TMLTask.h index 7dcc017b363c2f75983857ce94c331fcdc459238..6516c55bb1691741881d7cc9856bf8fbd834cb94 100755 --- a/simulators/c++2/src_simulator/app/TMLTask.h +++ b/simulators/c++2/src_simulator/app/TMLTask.h @@ -74,8 +74,8 @@ public: \param iCPU Pointer to the CPUs the task is mapped onto \param iNoOfCPUs Number of CPUs */ - TMLTask(ID iID, Priority iPriority, std::string iName, CPU** iCPU, unsigned int iNoOfCPUs); - TMLTask(ID iID, Priority iPriority, std::string iName, FPGA** iFPGA, unsigned int iNoOfFPGAs); + TMLTask(ID iID, Priority iPriority, std::string iName, CPU** iCPU, unsigned int iNoOfCPUs, bool isDaemon); + TMLTask(ID iID, Priority iPriority, std::string iName, FPGA** iFPGA, unsigned int iNoOfFPGAs, bool isDaemon); ///Destructor virtual ~TMLTask(); ///Returns the priority of the task @@ -235,6 +235,7 @@ public: void setNextCellIndex(unsigned int n) {_nextCellIndex=n;} unsigned int getNextCellIndex() const {return _nextCellIndex;} void schedule2HTML(std::ofstream& myfile) const; + bool getIsDaemon() {return _isDaemon;}; protected: ///ID of the task ID _ID; @@ -258,7 +259,9 @@ protected: FPGA** _fpgas; ///Number of cores assigned to the task unsigned int _noOfFPGAs; + bool _isDaemon; unsigned int _nextCellIndex; + #ifdef ADD_COMMENTS ///Comment list CommentList _commentList; diff --git a/simulators/c++2/src_simulator/arch/CPU.cpp b/simulators/c++2/src_simulator/arch/CPU.cpp index 200ea8532e95a18586a92fb50dea281710cb3d31..f852c4bff60b89b2a4c70d9b3f257db59eec58d4 100644 --- a/simulators/c++2/src_simulator/arch/CPU.cpp +++ b/simulators/c++2/src_simulator/arch/CPU.cpp @@ -209,8 +209,10 @@ void CPU::HW2HTML(std::ofstream& myfile) const { unsigned int indexTrans=aCurrTransName.find_first_of(":"); std::string aCurrContent=aCurrTransName.substr(indexTrans+1,2); writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); - - aCurrTime = aCurrTrans->getEndTime(); + if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime) + aCurrTime = _simulatedTime; + else + aCurrTime = aCurrTrans->getEndTime(); } } @@ -276,7 +278,10 @@ void CPU::schedule2HTML(std::ofstream& myfile) const { writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() ); - aCurrTime = aCurrTrans->getEndTime(); + if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime) + aCurrTime = _simulatedTime; + else + aCurrTime = aCurrTrans->getEndTime(); } } diff --git a/simulators/c++2/src_simulator/arch/FPGA.cpp b/simulators/c++2/src_simulator/arch/FPGA.cpp index b57ba1154a55a35983efc814ccae62dc84b9bbdd..56588d0fe7d49548606a28d14a5924edf3e0dd94 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.cpp +++ b/simulators/c++2/src_simulator/arch/FPGA.cpp @@ -236,8 +236,11 @@ std::cout<<"fpga addTransaction"<<std::endl; #ifdef DEBUG_FPGA std::cout<<"I am in finish!!!"<<std::endl; #endif - - if(_endSchedule == 0) _maxEndTime=max(_maxEndTime,_nextTransaction->getEndTime()); + //_endSchedule=0; + // _maxEndTime=max(_maxEndTime,_nextTransaction->getEndTime()) + //std::cout<<"end schedule is ~~~~~~~"<<_endSchedule<<std::endl; + if(_endSchedule == 0 && (!(_nextTransaction->getCommand()->getTask()->getIsDaemon()==true && _nextTransaction->getCommand()->getTask()->getNextTransaction(0)==0))) + _maxEndTime=max(_maxEndTime,_nextTransaction->getEndTime()); if(_reconfigNumber>0) _endSchedule=_maxEndTime+_reconfigNumber*_reconfigTime; else{ @@ -592,7 +595,10 @@ void FPGA::HW2HTML(std::ofstream& myfile) { std::string aCurrContent=aCurrTransName.substr(indexTrans+1,2); writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); - aCurrTime = aCurrTrans->getEndTime(); + if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime) + aCurrTime = _simulatedTime; + else + aCurrTime = aCurrTrans->getEndTime(); } } @@ -656,7 +662,10 @@ void FPGA::schedule2HTML(std::ofstream& myfile) { writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() ); - aCurrTime = aCurrTrans->getEndTime(); + if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime) + aCurrTime = _simulatedTime; + else + aCurrTime = aCurrTrans->getEndTime(); } } diff --git a/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp b/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp index 85b05e636cbd36ccd43ee09aeda6cf7c29dc107d..eb448b5e1d46da4a657a7c35c8cf7c06424bd895 100644 --- a/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp +++ b/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp @@ -357,8 +357,8 @@ std::cout << "CPU:calcSTL: addtransaction of CPU " << _name << ": " << _nextTran } time++; - - _simulatedTime=max(_simulatedTime,_nextTransaction->getEndTime()); + if(!(_nextTransaction->getCommand()->getTask()->getIsDaemon()==true && _nextTransaction->getCommand()->getTask()->getNextTransaction(0)==0)) + _simulatedTime=max(_simulatedTime,_nextTransaction->getEndTime()); _overallTransNo++; //NEW!!!!!!!! _overallTransSize+=_nextTransaction->getOperationLength(); //NEW!!!!!!!! //std::cout << "lets crash execute\n"; diff --git a/simulators/c++2/src_simulator/arch/OrderScheduler.cpp b/simulators/c++2/src_simulator/arch/OrderScheduler.cpp index b0e11cfce88207f82d6ce3cb01a65b93348ab385..64d948f4e2bffa079df1005a1679ad24cd52a5bb 100644 --- a/simulators/c++2/src_simulator/arch/OrderScheduler.cpp +++ b/simulators/c++2/src_simulator/arch/OrderScheduler.cpp @@ -54,7 +54,7 @@ TMLTime OrderScheduler::schedule(TMLTime iEndSchedule){ WorkloadSource *aSourcePast=0, *aSourceFuture=0; //NEW for(WorkloadList::iterator i=_workloadList.begin(); i != _workloadList.end(); ++i){ aTempTrans=(*i)->getNextTransaction(iEndSchedule); - if(aTempTrans) std::cout<<"show temp trans"<<aTempTrans->toShortString()<<std::endl; + // if(aTempTrans) std::cout<<"show temp trans"<<aTempTrans->toShortString()<<std::endl; if (aTempTrans!=0 && aTempTrans->getVirtualLength()!=0 && aTempTrans->getCommand()->getTask()->getFPGA()){ aRunnableTime=aTempTrans->getRunnableTime(); if (aRunnableTime<=iEndSchedule){ @@ -82,9 +82,11 @@ TMLTime OrderScheduler::schedule(TMLTime iEndSchedule){ _nextTransaction=aMarkerPast; _lastSource=aSourcePast; //NEW } +#ifdef DEBUG_FPGA if(_nextTransaction) std::cout<<"order next trans is "<<_nextTransaction->toShortString()<<std::endl; else std::cout<<"order next trans is 0"<<std::endl; std::cout<<"end order scheduler"<<std::endl; +#endif return 0; } diff --git a/simulators/c++2/src_simulator/arch/SchedulableDevice.h b/simulators/c++2/src_simulator/arch/SchedulableDevice.h index 7cb94897c84cdf9a265fa4b3340e593e03bdf7df..475408c0a8fab7aeb4f02c790679ae933a137376 100644 --- a/simulators/c++2/src_simulator/arch/SchedulableDevice.h +++ b/simulators/c++2/src_simulator/arch/SchedulableDevice.h @@ -106,7 +106,7 @@ public: \return Number of simulated clock cycles */ static TMLTime getSimulatedTime() { return _simulatedTime; } - + static TMLTime getNonDaemonSimulatedTime() { return _nonDaemonSimulatedTime;} ///Sets the number of simulated clock cycles /** \param iSimulatedTime Number of simulated clock cycles @@ -163,6 +163,7 @@ protected: std::string _name; ///Class variable holding the simulation time static TMLTime _simulatedTime; + static TMLTime _nonDaemonSimulatedTime; ///End time of the last scheduled transaction TMLTime _endSchedule; diff --git a/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp b/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp index 3b93a80d89b4577ee0120d0e8b481f001f01843e..3d9fc7ca63f27bf211df1ba47b57bdca291f3c1f 100644 --- a/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp +++ b/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp @@ -295,9 +295,17 @@ std::cout<<"addTransaction"<<std::endl; //#endif //_nextTransaction->getCommand()->execute(); //NEW!!!! //std::cout << "CPU:addt: to be started" << std::endl; - _endSchedule=_nextTransaction->getEndTime(); + _endSchedule=_nextTransaction->getEndTime(); + std::cout<<"end schedule is"<<_endSchedule<<std::endl; + + std::cout<<"simulated time is ---------"<<_simulatedTime<<std::endl; + //std::cout << "set end schedule CPU: " << _endSchedule << " startTime of trans:" << _nextTransaction->getStartTime() << " length of trans=" << _nextTransaction->getLength() <<"\n"; - _simulatedTime=max(_simulatedTime,_endSchedule); + + if(!(_nextTransaction->getCommand()->getTask()->getIsDaemon()==true && _nextTransaction->getCommand()->getTask()->getNextTransaction(0)==0)) + _simulatedTime=max(_simulatedTime,_endSchedule); + // else + // _nextTransaction->setEndTime(_simulatedTime); _overallTransNo++; //NEW!!!!!!!! _overallTransSize+=_nextTransaction->getOperationLength(); //NEW!!!!!!!! //std::cout << "lets crash execute\n"; diff --git a/simulators/c++2/src_simulator/definitions.cpp b/simulators/c++2/src_simulator/definitions.cpp index c968bc4b38cf46fe8774d5120fae1472b619dfde..a022035aeb9594f0846e0e34d6581ed6c318d891 100644 --- a/simulators/c++2/src_simulator/definitions.cpp +++ b/simulators/c++2/src_simulator/definitions.cpp @@ -53,6 +53,7 @@ Ludovic Apvrille, Renaud Pacalet #include <unistd.h> TMLTime SchedulableDevice::_simulatedTime=0; +TMLTime SchedulableDevice::_nonDaemonSimulatedTime=0; TMLTime SchedulableDevice::_overallTransNo=0; TMLTime SchedulableDevice::_overallTransSize=0; ID TMLTransaction::_ID=1; diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp index 8168118f94ee19fd62a2ae21c9d3e51c3ee55a68..f6d0d8c09501dc107188068d01b931754ce45058 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.cpp +++ b/simulators/c++2/src_simulator/sim/Simulator.cpp @@ -808,7 +808,7 @@ bool Simulator::channelImpactsCommand(TMLChannel* iCh, TMLCommand* iCmd){ bool Simulator::simulate(TMLTransaction*& oLastTrans){ TMLTransaction* depTransaction,*depNextTrans,*transLET; TMLCommand* commandLET,*depCommand,*depNextCommand; - TMLTask* depTask; + TMLTask* depTask,*lastNonDaemonTask=0; SchedulableDevice* deviceLET; CPU* depCPU; FPGA* depFPGA; @@ -844,8 +844,23 @@ bool Simulator::simulate(TMLTransaction*& oLastTrans){ #ifdef DEBUG_KERNEL std::cout << "kernel:simulate: scheduling decision: " << transLET->toString() << std::endl; #endif - commandLET=transLET->getCommand(); + + if(commandLET->getTask()->getIsDaemon()==false){ + lastNonDaemonTask=commandLET->getTask(); + } + + std::cout<<"transLET is********"<<transLET->toString()<<std::endl; + if(transLET!=0 && transLET->getCommand()->getTask()->getIsDaemon()==true){ + if(transLET->getStartTime() >= deviceLET->getSimulatedTime()){ + if(lastNonDaemonTask!=0 && lastNonDaemonTask->getNextTransaction(0)!=0) + std::cout<<"next trans no 0********** "<< lastNonDaemonTask->getNextTransaction(0)->toString()<<std::endl; + if(lastNonDaemonTask!=0 && lastNonDaemonTask->getNextTransaction(0)==0){ + break; + } + } + } + #ifdef DEBUG_SIMULATE std::cout<<"device is "<<deviceLET->getName()<<std::endl; #endif @@ -856,6 +871,7 @@ bool Simulator::simulate(TMLTransaction*& oLastTrans){ #ifdef DEBUG_KERNEL std::cout << "kernel:simulate: AFTER add trans: " << x << std::endl; #endif + if (x){ #ifdef DEBUG_KERNEL std::cout << "kernel:simulate: add transaction 0" << commandLET->toString() << std::endl; @@ -975,11 +991,9 @@ bool Simulator::simulate(TMLTransaction*& oLastTrans){ #ifdef DEBUG_SIMULATE std::cout<<"task is !!!!!"<<oLastTrans->toString()<<std::endl; #endif - transLET=getTransLowestEndTime(deviceLET); - // if(transLET==0) std::cout<<"translet is 0~~~"<<std::endl; - // if(_simComp->getStopFlag()==true) std::cout<<"stop flag is true"<<std::endl; - // else std::cout<<"stop flag is false"<<std::endl; - } + + transLET=getTransLowestEndTime(deviceLET); + } bool aSimCompleted = ( transLET==0 && !_simComp->getStoppedOnAction());