Commit b5862f5c authored by Siyuan Niu's avatar Siyuan Niu

html for fpga is ok

parent fdb49eec
......@@ -408,5 +408,168 @@ void FPGA::latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned in
return;
}
double FPGA::averageLoad (TMLTask* currTask) const{
double _averageLoad=0;
TMLTime _maxEndTime=0;
for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) {
if( (*i)-> getCommand()->getTask() == currTask ){
TMLTime _endTime= (*i)->getEndTime();
_maxEndTime=max(_maxEndTime,_endTime);
}
}
for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) {
if( (*i)-> getCommand()->getTask() == currTask ){
_averageLoad += (*i)->getEndTime() - (*i)->getStartTime();
}
}
if(_maxEndTime == 0)
return 0;
else {
_averageLoad = (double)_averageLoad/_maxEndTime;
return _averageLoad;
}
/*if( _maxEndTime == 0 )
myfile << "average load is 0" << "<br>";
else
myfile<<" average load is "<<(double)_averageLoad/_maxEndTime<<"<br>";*/
}
void FPGA::drawPieChart(std::ofstream& myfile) const {
std::cout<<"fpga drawpie chart"<<std::endl;
TMLTime _maxEndTime=0;
for(TaskList::const_iterator j =_taskList.begin(); j != _taskList.end(); ++j){
for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) {
if( (*i)-> getCommand()->getTask() == (*j) ){
TMLTime _endTime= (*i)->getEndTime();
_maxEndTime=max(_maxEndTime,_endTime);
}
}
std::cout<<"max end time is "<<_maxEndTime<<std::endl;
std::map <TMLTask*, double > transPercentage;
for( TransactionList::const_iterator i = _transactList.begin(); i!= _transactList.end(); ++i){
if( (*i)-> getCommand()->getTask() == (*j) ){
transPercentage[(*i)-> getCommand()->getTask()]+=(double)((*i)->getEndTime()-(*i)->getStartTime())/_maxEndTime;
}
}
std::map <TMLTask*, double>::iterator iter = transPercentage.begin();
myfile << " var chart" << _ID << "_" << (*j)->toShortString() << "= new CanvasJS.Chart(\"chartContainer" << _ID << "_" << (*j)->toShortString() <<"\"," << std::endl;
myfile << SCHED_HTML_JS_CONTENT2 << "Average load is " << averageLoad(*j) << SCHED_HTML_JS_CONTENT3 << std::endl;
double idle=1;
while( iter != transPercentage.end()){
myfile << " { y:" << (iter->second)*100 << ", indexLabel: \"" << iter->first->toString() << "\" }," << std::endl;
idle-=iter->second;
++iter;
}
myfile << " { y:" << idle*100 << ", indexLabel: \"idle time\"" << " }" << std::endl;
myfile << std::endl;
myfile << SCHED_HTML_PIE_END;
myfile << "chart" << _ID << "_" << (*j)->toShortString() << ".render();" << std::endl;
}
}
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 {
myfile << "<h2><span>Scheduling for device: "<< _name << "</span></h2>" << std::endl;
if ( _transactList.size() == 0 ) {
myfile << "<h4>Device never activated</h4>" << std::endl;
}
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 ){
std::cout<<"in!!"<<_htmlCurrTask->toString()<<std::endl;
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
std::cout<<"blank is "<<aBlanks<<std::endl;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
unsigned int aLength = aCurrTrans->getOperationLength();
// 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 );
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
aCurrTime = aCurrTrans->getEndTime();
}
}
myfile << "</tr>" << std::endl << "<tr>";
for ( unsigned int aLength = 0; aLength < aCurrTime; aLength++ ) {
myfile << "<th></th>";
}
myfile << "</tr>" << std::endl << "<tr>";
for ( unsigned int aLength = 0; aLength <= aCurrTime; aLength += 5 ) {
std::ostringstream spanVal;
spanVal << aLength;
writeHTMLColumn( myfile, 5, "sc", "", spanVal.str(), false );
//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>";
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,"<","&lt;");
replaceAll(aCommentString,">","&gt;");
aMoreComments = true;
myfile << "<td style=\"max-width: unset;\">" << aComment->_time << "</td><td><pre>" << aCommentString << "</pre></td><td class=\"space\"></td>";
}
}
aInit = false;
myfile << "</tr>" << std::endl;
}
#endif
myfile << "</table>" << std::endl;
}
std::cout<<"end in!!!"<<std::endl;
}
......@@ -127,10 +127,16 @@ public:
}
inline void setTransNumber(unsigned int num) { _transNumber=num;}
inline unsigned int getTransNumber() { return _transNumber;}
double averageLoad (TMLTask* currTask) const;
void drawPieChart(std::ofstream& myfile) const;
void showPieChart(std::ofstream& myfile) const;
void schedule2HTML(std::ofstream& myfile) const;
inline const TaskList& getTaskList() const{return _taskList;}
inline void setHtmlCurrTask(TMLTask *t) { _htmlCurrTask=t;}
protected:
///List of all tasks running on the FPGA
TaskList _taskList;
TMLTask* _htmlCurrTask;
/**
\param iTime Indicates at what time the transaction should be truncated
*/
......
......@@ -191,13 +191,14 @@ std::string SchedulableDevice::determineHTMLCellClass( std::map<TMLTask*, std::
double SchedulableDevice::averageLoad() const{
std::cout<<"average load"<<std::endl;
double _averageLoad=0;
TMLTime _maxEndTime=0;
for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) {
TMLTime _endTime= (*i)->getEndTime();
_maxEndTime=max(_maxEndTime,_endTime);
}
std::cout<<"max end time is "<<_maxEndTime<<std::endl;
// std::cout<<"max end time is "<<_maxEndTime<<std::endl;
for( TransactionList::const_iterator i = _transactList.begin(); i != _transactList.end(); ++i ) {
_averageLoad += (*i)->getEndTime() - (*i)->getStartTime();
......
......@@ -368,6 +368,9 @@ std::cout<<"schedule2HTML--------------------------------------*****************
for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i){
(*i)->drawPieChart(myfile);
}
for(FPGAList::const_iterator i=_simComp->getFPGAList().begin(); i != _simComp->getFPGAList().end(); ++i){
(*i)->drawPieChart(myfile);
}
for(BusList::const_iterator j=_simComp->getBusList().begin(); j != _simComp->getBusList().end(); ++j){
(*j)->drawPieChart(myfile);
}
......@@ -393,6 +396,16 @@ std::cout<<"schedule2HTML--------------------------------------*****************
}
jsfile.close();
for(FPGAList::const_iterator j=_simComp->getFPGAList().begin(); j != _simComp->getFPGAList().end(); ++j){
for(TaskList::const_iterator i = (*j)->getTaskList().begin(); i != (*j)->getTaskList().end(); ++i){
(*j)->setHtmlCurrTask(*i);
std::cout<<"begin fpga html "<<(*j)->toShortString()<<std::endl;
(*j)->schedule2HTML(myfile);
std::cout<<"end fpga html "<<(*j)->toShortString()<<std::endl;
(*j)->showPieChart(myfile);
}
}
for(BusList::const_iterator j=_simComp->getBusList().begin(); j != _simComp->getBusList().end(); ++j){
(*j)->schedule2HTML(myfile);
(*j)->showPieChart(myfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment