From bba70ef51498f00b4a63e42f69bd0f4b81431f9e Mon Sep 17 00:00:00 2001 From: niusiyuan <siyuan.niu@telecom-paristech.fr> Date: Tue, 21 May 2019 10:55:48 +0200 Subject: [PATCH] task name ok --- simulators/c++2/src_simulator/arch/FPGA.cpp | 67 ++++++++----------- simulators/c++2/src_simulator/arch/FPGA.h | 18 +++-- .../src_simulator/arch/SchedulableDevice.cpp | 1 - 3 files changed, 39 insertions(+), 47 deletions(-) diff --git a/simulators/c++2/src_simulator/arch/FPGA.cpp b/simulators/c++2/src_simulator/arch/FPGA.cpp index 0f32a57c9a..31dc768e30 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.cpp +++ b/simulators/c++2/src_simulator/arch/FPGA.cpp @@ -61,7 +61,8 @@ FPGA::FPGA( ID iID, ,_cyclesBeforeIdle(iCyclesBeforeIdle) ,_cyclesPerExeci(iCyclesPerExeci) ,_cyclesPerExecc(iCyclesPerExecc) - ,_transNumber(0) + ,_taskNumber(0) + ,_currTaskNumber(0) {} @@ -471,8 +472,21 @@ void FPGA::showPieChart(std::ofstream& myfile) const{ myfile << SCHED_HTML_JS_DIV_ID << _ID << "_" << _htmlCurrTask->toShortString() << SCHED_HTML_JS_DIV_END << "<br>"; } - -void FPGA::schedule2HTML(std::ofstream& myfile) const { +std::string FPGA::determineHTMLCellClass(unsigned int &nextColor ) { + std::map<TMLTask*, std::string>::const_iterator it = taskCellClasses.find( _htmlCurrTask ); + + if ( it == taskCellClasses.end() ) { + unsigned int aColor = nextColor % NB_HTML_COLORS; + std::ostringstream cellClass; + cellClass << "t" << aColor; + taskCellClasses[ _htmlCurrTask ] = cellClass.str(); + nextColor++; + } + + return taskCellClasses[ _htmlCurrTask ]; +} + +void FPGA::schedule2HTML(std::ofstream& myfile) { if(_startFlagHTML == true){ myfile << "<h2><span>Scheduling for device: "<< _name << "</span></h2>" << std::endl; } @@ -483,14 +497,13 @@ void FPGA::schedule2HTML(std::ofstream& myfile) const { else { myfile << "<table>" << std::endl << "<tr>"; - std::map<TMLTask*, std::string> taskCellClasses; - unsigned int nextCellClassIndex = 0; TMLTime aCurrTime = 0; for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) { std::cout << (*i)-> getCommand()->getTask()->toString() <<std::endl; std::cout<< _htmlCurrTask->toString()<<std::endl; if( (*i)-> getCommand()->getTask() == _htmlCurrTask ){ + _currTaskNumber++; std::cout<<"in!!"<<_htmlCurrTask->toString()<<std::endl; TMLTransaction* aCurrTrans = *i; unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime; @@ -505,7 +518,7 @@ void FPGA::schedule2HTML(std::ofstream& myfile) const { // Issue #4 TMLTask* task = aCurrTrans->getCommand()->getTask(); std::cout<<"what is this task?"<<task->toString()<<std::endl; - const std::string cellClass = determineHTMLCellClass( taskCellClasses, task, nextCellClassIndex ); + const std::string cellClass = determineHTMLCellClass( nextCellClassIndex ); writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() ); @@ -529,45 +542,19 @@ void FPGA::schedule2HTML(std::ofstream& myfile) const { //myfile << "<td colspan=\"5\" class=\"sc\">" << aLength << "</td>"; } - myfile << "</tr>" << std::endl << "</table>" << std::endl << "<table>" << std::endl << "<tr>"; - - for( std::map<TMLTask*, std::string>::iterator taskColIt = taskCellClasses.begin(); taskColIt != taskCellClasses.end(); ++taskColIt ) { - TMLTask* task = (*taskColIt).first; - // Unset the default td max-width of 5px. For some reason setting the max-with on a specific t style does not work - myfile << "<td class=\"" << taskCellClasses[ task ] << "\"></td><td style=\"max-width: unset;\">" << task->toString() << "</td><td class=\"space\"></td>"; - } - - myfile << "</tr>" << std::endl; - -#ifdef ADD_COMMENTS - bool aMoreComments = true, aInit = true; - Comment* aComment; - - while ( aMoreComments ) { - aMoreComments = false; - myfile << "<tr>"; - + myfile << "</tr>" << std::endl << "</table>" << std::endl; + if(_currTaskNumber == _taskNumber){ + myfile << "<table>" << std::endl << "<tr>" << std::endl; for( std::map<TMLTask*, std::string>::iterator taskColIt = taskCellClasses.begin(); taskColIt != taskCellClasses.end(); ++taskColIt ) { - //for(TaskList::const_iterator j=_taskList.begin(); j != _taskList.end(); ++j){ TMLTask* task = (*taskColIt).first; - std::string aCommentString = task->getNextComment( aInit, aComment ); - - if ( aComment == 0 ) { - myfile << "<td></td><td></td><td class=\"space\"></td>"; - } - else { - replaceAll(aCommentString,"<","<"); - replaceAll(aCommentString,">",">"); - aMoreComments = true; - myfile << "<td style=\"max-width: unset;\">" << aComment->_time << "</td><td><pre>" << aCommentString << "</pre></td><td class=\"space\"></td>"; - } + // Unset the default td max-width of 5px. For some reason setting the max-with on a specific t style does not work + myfile << "<td class=\"" << taskCellClasses[ task ] << "\"></td><td style=\"max-width: unset;\">" << task->toString() << "</td><td class=\"space\"></td>"; } - - aInit = false; myfile << "</tr>" << std::endl; + myfile << "</table>" << std::endl; } -#endif - myfile << "</table>" << std::endl; + + } std::cout<<"end in!!!"<<std::endl; } diff --git a/simulators/c++2/src_simulator/arch/FPGA.h b/simulators/c++2/src_simulator/arch/FPGA.h index f8b226fb46..71cf7c29be 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.h +++ b/simulators/c++2/src_simulator/arch/FPGA.h @@ -125,11 +125,13 @@ public: */ virtual void registerTask(TMLTask* iTask){ _taskList.push_back(iTask); + _taskNumber++; if (_scheduler!=0) _scheduler->addWorkloadSource(iTask); } - inline void setTransNumber(unsigned int num) { _transNumber=num;} - inline unsigned int getTransNumber() { return _transNumber;} - void schedule2HTML(std::ofstream& myfile) const; + ///inline void setTransNumber(unsigned int num) { _transNumber=num;} + ///inline unsigned int getTransNumber() { return _transNumber;} + inline void setCurrTaskNumber(unsigned int num) { _currTaskNumber=num;} + void schedule2HTML(std::ofstream& myfile) ; inline const TaskList& getTaskList() const{return _taskList;} inline void setHtmlCurrTask(TMLTask *t) { _htmlCurrTask=t;} inline void setStartFlagHTML(bool s) {_startFlagHTML=s;} @@ -137,6 +139,7 @@ public: double averageLoad (TMLTask* currTask) const; void drawPieChart(std::ofstream& myfile) const; void showPieChart(std::ofstream& myfile) const; + std::string determineHTMLCellClass(unsigned int &nextColor ); protected: ///List of all tasks running on the FPGA TaskList _taskList; @@ -182,11 +185,14 @@ protected: TMLTime _timeBeforeIdle; ///Time needed to switch into idle mode TMLTime _changeIdleModeTime; - unsigned int _transNumber; bool _startFlagHTML; bool _endFlagHTML; - - + //number of tasks executed on FPGA + unsigned int _taskNumber; + //current number of tasks executed on FPGA + unsigned int _currTaskNumber; + unsigned int nextCellClassIndex; + std::map<TMLTask*, std::string> taskCellClasses; ///State variable for the VCD output vcdFPGAVisState _vcdOutputState; }; diff --git a/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp b/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp index ff092d7af8..4168bdb1db 100644 --- a/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp +++ b/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp @@ -309,7 +309,6 @@ void SchedulableDevice::schedule2HTML(std::ofstream& myfile) const { } myfile << "</tr>" << std::endl << "</table>" << std::endl << "<table>" << std::endl << "<tr>"; - for( std::map<TMLTask*, std::string>::iterator taskColIt = taskCellClasses.begin(); taskColIt != taskCellClasses.end(); ++taskColIt ) { TMLTask* task = (*taskColIt).first; // Unset the default td max-width of 5px. For some reason setting the max-with on a specific t style does not work -- GitLab