Skip to content

Commit

Permalink
added sort toggle for communication balance, updated parsed files
Browse files Browse the repository at this point in the history
  • Loading branch information
raptox committed Jan 25, 2020
1 parent 3f7d245 commit 7649bce
Show file tree
Hide file tree
Showing 11 changed files with 70,143 additions and 19,060 deletions.
66 changes: 54 additions & 12 deletions app/components/ViewParsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class ViewParsed extends Component {
this.state = {
parsedContent: '',
balanceZoom: false,
balanceSort: false,
balanceZoomIndex: 0,
balanceZoomPageSize: 30,
balanceZoomData: {},
Expand All @@ -42,6 +43,26 @@ export default class ViewParsed extends Component {
});
}

toggleBalanceSort() {
this.setState({ balanceSort: !this.state.balanceSort }, () => {
if (this.state.balanceSort) {
this.setState({
balanceZoomData: this.state.parsedContent.balanceDataSorted
});
} else {
this.setState({
balanceZoomData: this.state.parsedContent.balanceData
});
}
this.setState({
balanceZoom: false,
balanceZoomIndex: 1,
balanceZoomStart: true,
balanceZoomEnd: false
});
});
}

unZoomBalanceData() {
if (this.state.parsedContent.balanceData.labels) {
this.recalculateBalanceData(
Expand Down Expand Up @@ -94,17 +115,30 @@ export default class ViewParsed extends Component {

recalculateBalanceData(start, end) {
let newBalanceData = {
labels: this.state.parsedContent.balanceData.labels.slice(start, end),
datasets: this.state.parsedContent.balanceData.datasets.map(dataset => {
return {
label: dataset.label,
fill: dataset.fill,
backgroundColor: dataset.backgroundColor,
borderColor: dataset.borderColor,
pointHoverBackgroundColor: dataset.pointHoverBackgroundColor,
data: dataset.data.slice(start, end)
};
})
labels: this.state.balanceSort
? this.state.parsedContent.balanceDataSorted.labels.slice(start, end)
: this.state.parsedContent.balanceData.labels.slice(start, end),
datasets: this.state.balanceSort
? this.state.parsedContent.balanceDataSorted.datasets.map(dataset => {
return {
label: dataset.label,
fill: dataset.fill,
backgroundColor: dataset.backgroundColor,
borderColor: dataset.borderColor,
pointHoverBackgroundColor: dataset.pointHoverBackgroundColor,
data: dataset.data.slice(start, end)
};
})
: this.state.parsedContent.balanceData.datasets.map(dataset => {
return {
label: dataset.label,
fill: dataset.fill,
backgroundColor: dataset.backgroundColor,
borderColor: dataset.borderColor,
pointHoverBackgroundColor: dataset.pointHoverBackgroundColor,
data: dataset.data.slice(start, end)
};
})
};
this.setState({ balanceZoomData: newBalanceData });
}
Expand Down Expand Up @@ -143,6 +177,7 @@ export default class ViewParsed extends Component {
<h3>Metadata</h3>
<div>
<strong>user:</strong> {content.metadata.username} <br />
<strong>cmdline:</strong> {content.metadata.cmdline} <br />
<strong>start:</strong>{' '}
{moment
.unix(content.metadata.start)
Expand Down Expand Up @@ -194,13 +229,20 @@ export default class ViewParsed extends Component {

{this.state.balanceZoomData && (
<div>
<h3>Communication balance by task (sorted by MPI time)</h3>
<h3>Communication balance by task</h3>
<Button
variant="contained"
color="primary"
onClick={() => this.toggleBalanceZoom()}
>
Toggle Zoom
</Button>{' '}
<Button
variant="contained"
color="primary"
onClick={() => this.toggleBalanceSort()}
>
Toggle Sort
</Button>
{this.state.balanceZoom && (
<div>
Expand Down
40 changes: 27 additions & 13 deletions app/utils/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const parseData = (filename, callback) => {
data.mpiPies = getMpiPieCharts(data.mpiData, data.metadata.totalWallTime);
data.hpmData = getHpmData(taskdata);
data.balanceData = generateBalanceChartData(data.mpiData.mpiCallsByTask);
data.balanceDataSorted = generateBalanceChartData(
data.mpiData.mpiCallsByTaskSorted
);
// save raw parsed JSON to file
//
// fs.writeFile('log.json', JSON.stringify(result, null, 2), err => {
Expand All @@ -65,17 +68,23 @@ const generateBalanceChartData = mpiCallsByTask => {
};

for (let mpiCallKey in mpiCallsByTask[0].mpiCalls) {
let mpiCall = mpiCallsByTask[0].mpiCalls[mpiCallKey];
let dataset = mpiCallsByTask.map(task => task.mpiCalls[mpiCallKey].ttot);
//.sort((callA, callB) => callB - callA);
balanceData.datasets.push({
label: mpiCall.call,
fill: false,
backgroundColor: mpiCall.color,
borderColor: mpiCall.color,
pointHoverBackgroundColor: mpiCall.hoverColor,
data: dataset
});
try {
let mpiCall = mpiCallsByTask[0].mpiCalls[mpiCallKey];
let dataset = mpiCallsByTask.map(
task => task.mpiCalls[mpiCallKey].ttot
);
//.sort((callA, callB) => callB - callA);
balanceData.datasets.push({
label: mpiCall.call,
fill: false,
backgroundColor: mpiCall.color,
borderColor: mpiCall.color,
pointHoverBackgroundColor: mpiCall.hoverColor,
data: dataset
});
} catch (e) {
console.log(e);
}
}

return balanceData;
Expand Down Expand Up @@ -241,6 +250,7 @@ const getMpiData = taskdata => {
};
let mpiCallsSummarized = [];
let mpiCallsByTask = [];
let mpiCallsByTaskSorted = [];

try {
for (let taskKey in taskdata) {
Expand Down Expand Up @@ -327,7 +337,9 @@ const getMpiData = taskdata => {
// sort descending after total time
mpiCalls.sort((callA, callB) => callB.ttot - callA.ttot);
mpiCallsSummarized.sort((callA, callB) => callB.ttot - callA.ttot);
mpiCallsByTask.sort((taskA, taskB) => taskB.ttot - taskA.ttot);
mpiCallsByTaskSorted = JSON.parse(JSON.stringify(mpiCallsByTask)).sort(
(taskA, taskB) => taskB.ttot - taskA.ttot
);
} catch (e) {
console.log(e);
}
Expand All @@ -336,7 +348,8 @@ const getMpiData = taskdata => {
mpiCalls,
mpiCallsSummarized,
mpiAnalysis,
mpiCallsByTask
mpiCallsByTask,
mpiCallsByTaskSorted
};
};

Expand Down Expand Up @@ -371,6 +384,7 @@ const getMetadata = firstTask => {
metadata.ntasks = parseInt(firstTask.job[0].$.ntasks);
metadata.nhosts = parseInt(firstTask.job[0].$.nhosts);
metadata.totalWallTime = metadata.walltime * metadata.ntasks;
metadata.cmdline = firstTask.cmdline[0]._;
metadata.env = firstTask.env;
return metadata;
};
Expand Down
Loading

0 comments on commit 7649bce

Please sign in to comment.