Skip to content

Commit

Permalink
- Transpose the profiling data for faster reading
Browse files Browse the repository at this point in the history
  - Split into 2 files: uint32 and double in split files to transpose them easier
  - OMEdit can read the data, but the transformation widget has nowhere to display the graphs yet
- Some minor fixes for equations that were not profiled
- Handle profiling of noretcall


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20318 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 30, 2014
1 parent c6e18be commit 582a988
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 45 deletions.
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/GUI/MainWindow.cpp
Expand Up @@ -1058,7 +1058,7 @@ void MainWindow::showOpenResultFileDialog()
void MainWindow::showOpenTransformationFileDialog()
{
QString fileName = StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
NULL, Helper::xmlFileTypes, NULL);
NULL, Helper::infoXmlFileTypes, NULL);
if (fileName.isEmpty())
return;

Expand Down
48 changes: 44 additions & 4 deletions OMEdit/OMEditGUI/GUI/Widgets/TransformationsWidget.cpp
Expand Up @@ -440,8 +440,10 @@ TransformationsWidget::TransformationsWidget(QString infoXMLFullFileName, MainWi
{
if (!mInfoXMLFullFileName.endsWith("_info.xml")) {
mProfJSONFullFileName = "";
mProfilingDataRealFileName = "";
} else {
mProfJSONFullFileName = infoXMLFullFileName.left(infoXMLFullFileName.size() - 8) + "prof.json";
mProfilingDataRealFileName = infoXMLFullFileName.left(infoXMLFullFileName.size() - 8) + "prof.realdata";
}
setWindowIcon(QIcon(":/Resources/icons/debugger.svg"));
setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::transformationalDebugger));
Expand Down Expand Up @@ -861,11 +863,13 @@ QTreeWidgetItem* TransformationsWidget::makeEquationTreeWidgetItem(int equationI
QStringList values;
values << QString::number(equation->index)
<< OMEquationTypeToString(equation->kind)
<< equation->toString()
<< QString::number(equation->ncall)
<< equation->toString();
if (equation->profileBlock >= 0) {
values << QString::number(equation->ncall)
<< QString::number(equation->maxTime, 'g', 3)
<< QString::number(equation->time, 'g', 3)
<< QString::number(100 * equation->fraction, 'g', 3) + "%";
}

QTreeWidgetItem *pEquationTreeItem = new IntegerTreeWidgetItem(values, mpEquationsTreeWidget);
pEquationTreeItem->setToolTip(0, values[0]);
Expand Down Expand Up @@ -915,6 +919,8 @@ QTreeWidgetItem* TransformationsWidget::findEquationTreeItem(int equationIndex)
return 0;
}

// #include <qwt_plot.h>

void TransformationsWidget::fetchEquationData(int equationIndex)
{
OMEquation *equation = mpInfoXMLFileHandler->getOMEquation(equationIndex);
Expand All @@ -939,6 +945,37 @@ void TransformationsWidget::fetchEquationData(int equationIndex)
file.close();
mpTSourceEditor->goToLineNumber(equation->info.lineStart);
}
/* TODO: This data is correct. Add this to some widget thingy somewhere.
* Maybe a small one that you can click to enlarge.
* Also add the count one (Model_prof.intdata)
*/
#if 0
if (equation->profileBlock >= 0) {
QFile file(mProfilingDataRealFileName);
if (file.open(QIODevice::ReadOnly)) {

QwtPlot *w;
long c1;
w = new QwtPlot();

size_t rowSize = sizeof(double) * profilingNumSteps;
qDebug() << file.size() / rowSize;
file.seek(0);
QByteArray datax = file.read(rowSize);
file.seek((equation->profileBlock+2) * rowSize);
QByteArray datay = file.read(rowSize);
double *x = (double*)datax.data();
double *y = (double*)datay.data();

QwtPlotCurve *curve = new QwtPlotCurve("Curve 1");

curve->setData(x, y, profilingNumSteps);
curve->attach(w);
w->replot();
w->show();
}
}
#endif
}

void TransformationsWidget::fetchDefines(OMEquation *equation)
Expand Down Expand Up @@ -1135,14 +1172,17 @@ void TransformationsWidget::parseProfiling(QString fileName)
bool ok;
QVariantMap result = parser.parse(file, &ok).toMap();
double totalStepsTime = result["totalTimeProfileBlocks"].toDouble();
foreach (QVariant v, result["profileBlocks"].toList()) {
QVariantMap eq = v.toMap();
QVariantList list = result["profileBlocks"].toList();
profilingNumSteps = result["numStep"].toInt() + 1; // Initialization is not a step, but part of the file
for (int i=0; i<list.size(); i++) {
QVariantMap eq = list[i].toMap();
long id = eq["id"].toInt();
double time = eq["time"].toDouble();
mpInfoXMLFileHandler->equations[id]->ncall = eq["ncall"].toInt();
mpInfoXMLFileHandler->equations[id]->maxTime = eq["maxTime"].toDouble();
mpInfoXMLFileHandler->equations[id]->time = time;
mpInfoXMLFileHandler->equations[id]->fraction = time / totalStepsTime;
mpInfoXMLFileHandler->equations[id]->profileBlock = i;
}
delete file;
}
3 changes: 2 additions & 1 deletion OMEdit/OMEditGUI/GUI/Widgets/TransformationsWidget.h
Expand Up @@ -185,7 +185,8 @@ class TransformationsWidget : public QWidget
void clearTreeWidgetItems(QTreeWidget *pTreeWidget);
private:
MainWindow *mpMainWindow;
QString mInfoXMLFullFileName, mProfJSONFullFileName;
QString mInfoXMLFullFileName, mProfJSONFullFileName, mProfilingDataRealFileName;
int profilingNumSteps;
MyHandler *mpInfoXMLFileHandler;
QLineEdit *mpFindVariablesTextBox;
QComboBox *mpFindSyntaxComboBox;
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Util/Helper.cpp
Expand Up @@ -54,6 +54,7 @@ QString Helper::imageFileTypes = "SVG (*.svg);;PNG image (*.png);;Windows BMP im
QString Helper::bitmapFileTypes = "PNG image (*.png);;Windows BMP image (*.bmp);;JPEG (*.jpg *.jpeg)";
QString Helper::fmuFileTypes = "FMU Files (*.fmu)";
QString Helper::xmlFileTypes = "XML Files (*.xml)";
QString Helper::infoXmlFileTypes = "OM Info XML Files (*_info.xml)";
QString Helper::matFileTypes = "MAT Files (*.mat)";
QString Helper::omResultFileTypes = "OpenModelica Result Files (*.mat *.plt *.csv)";
int Helper::treeIndentation = 13;
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Util/Helper.h
Expand Up @@ -64,6 +64,7 @@ class Helper : public QObject
static QString bitmapFileTypes;
static QString fmuFileTypes;
static QString xmlFileTypes;
static QString infoXmlFileTypes;
static QString matFileTypes;
static QString omResultFileTypes;
static int treeIndentation;
Expand Down
39 changes: 2 additions & 37 deletions OMEdit/OMEditGUI/Util/OMDumpXML.cpp
Expand Up @@ -242,43 +242,6 @@ OMEquation::OMEquation()

}

OMEquation::OMEquation(const OMEquation &eq)
{
kind = eq.kind;
index = eq.index;
text = eq.text;
info = eq.info;
defines = eq.defines;
depends = eq.depends;
foreach (OMOperation *op, eq.ops) {
if (dynamic_cast<OMOperationSimplify*>(op))
ops.append(new OMOperationSimplify(*dynamic_cast<OMOperationSimplify*>(op)));
else if (dynamic_cast<OMOperationScalarize*>(op))
ops.append(new OMOperationScalarize(*dynamic_cast<OMOperationScalarize*>(op)));
else if (dynamic_cast<OMOperationInline*>(op))
ops.append(new OMOperationInline(*dynamic_cast<OMOperationInline*>(op)));
else if (dynamic_cast<OMOperationSubstitution*>(op))
ops.append(new OMOperationSubstitution(*dynamic_cast<OMOperationSubstitution*>(op)));
else if (dynamic_cast<OMOperationSolved*>(op))
ops.append(new OMOperationSolved(*dynamic_cast<OMOperationSolved*>(op)));
else if (dynamic_cast<OMOperationLinearSolved*>(op))
ops.append(new OMOperationLinearSolved(*dynamic_cast<OMOperationLinearSolved*>(op)));
else if (dynamic_cast<OMOperationSolve*>(op))
ops.append(new OMOperationSolve(*dynamic_cast<OMOperationSolve*>(op)));
else if (dynamic_cast<OMOperationDifferentiate*>(op))
ops.append(new OMOperationDifferentiate(*dynamic_cast<OMOperationDifferentiate*>(op)));
else if (dynamic_cast<OMOperationResidual*>(op))
ops.append(new OMOperationResidual(*dynamic_cast<OMOperationResidual*>(op)));
else if (dynamic_cast<OMOperationDummyDerivative*>(op))
ops.append(new OMOperationDummyDerivative(*dynamic_cast<OMOperationDummyDerivative*>(op)));
else if (dynamic_cast<OMOperationFlattening*>(op))
ops.append(new OMOperationFlattening(*dynamic_cast<OMOperationFlattening*>(op)));
else
ops.append(new OMOperation(*op));
}
eqs = eq.eqs;
}

OMEquation::~OMEquation() {
foreach (OMOperation *op, ops) {
delete op;
Expand All @@ -293,6 +256,8 @@ QString OMEquation::toString()
return QString("(assignment) %1 = %2").arg(defines[0]).arg(text[1]);
} else if (text[0] == "statement") {
return "(statement) " + text[1];
} else if (text[0] == "nonlinear") {
return QString("nonlinear, size %1").arg(eqs.size());
} else {
return "(" + text.join(",") + ")";
}
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/Util/OMDumpXML.h
Expand Up @@ -174,7 +174,7 @@ struct OMVariable {

struct OMEquation {
OMEquationType kind;
int index,parent,ncall;
int index,profileBlock=-1,parent,ncall;
double time,maxTime,fraction;
QStringList text;
OMInfo info;
Expand All @@ -183,7 +183,6 @@ struct OMEquation {
QList<OMOperation*> ops;
QList<int> eqs;
OMEquation();
OMEquation(const OMEquation& eq);
~OMEquation();
QString toString();
};
Expand Down

0 comments on commit 582a988

Please sign in to comment.