Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit a6670c1

Browse files
committed
Fix issue #209 (the root has no exclusive costs in the thread view)
This happens because hpcprof doesn't generate exclusive costs for the root. The solution is the viewer has to copy the costs from the inclusive one. However, this causes another problem: the original hpcprof doesn't provide information of metric partner. At the moment the viewer only assumes that if two metrics have the same name, they must be partnered.
1 parent fbca5ab commit a6670c1

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

edu.rice.cs.hpcdata/src/edu/rice/cs/hpcdata/experiment/metric/MetricRaw.java

-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ public MetricValue getValue(IMetricScope s) {
161161
if (s instanceof RootScope) {
162162
if (value != MetricValue.NONE)
163163
rootValue = value;
164-
else if (metricType != MetricType.EXCLUSIVE)
165-
rootValue = getValue((RootScope)s, threads);
166164
else if (partner != null)
167165
rootValue = partner.getValue((RootScope)s, threads);
168166
} else {

edu.rice.cs.hpcviewer.ui/src/edu/rice/cs/hpcviewer/ui/internal/AbstractTableView.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public abstract class AbstractTableView extends AbstractView
9292
private ProfilePart profilePart;
9393
private IEventBroker eventBroker;
9494
private IUndoableActionManager actionManager;
95-
95+
private IScopeTreeData treeData;
9696

9797
/*****
9898
* Constructor to create a view
@@ -294,7 +294,7 @@ protected void createTable(IMetricManager input) {
294294
// -------------------------------------------
295295

296296
root = getRoot();
297-
IScopeTreeData treeData = getTreeData(root, metricManager);
297+
treeData = getTreeData(root, metricManager);
298298

299299
table = new ScopeTreeTable(parent, SWT.NONE, treeData);
300300
table.addSelectionListener(scope -> updateButtonStatus());
@@ -337,7 +337,6 @@ public Object getInput() {
337337
*/
338338
@Override
339339
public List<FilterDataItem<BaseMetric>> getFilterDataItems() {
340-
IScopeTreeData treeData = getTreeData(root, metricManager);
341340
final List<BaseMetric> listAllMetrics = getMetricManager().getVisibleMetrics();
342341

343342
// List of indexes of the hidden columns based on the info from the table.

edu.rice.cs.hpcviewer.ui/src/edu/rice/cs/hpcviewer/ui/parts/thread/ThreadMetricManager.java

+20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package edu.rice.cs.hpcviewer.ui.parts.thread;
22

33
import java.util.ArrayList;
4+
import java.util.HashMap;
45
import java.util.List;
6+
import java.util.Map;
57

68
import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
79
import org.eclipse.collections.impl.list.mutable.FastList;
@@ -17,6 +19,7 @@
1719
import edu.rice.cs.hpcdata.experiment.scope.Scope;
1820

1921

22+
2023
public class ThreadMetricManager implements IMetricManager
2124
{
2225
private final EventList<BaseMetric> rawMetrics;
@@ -25,12 +28,29 @@ public class ThreadMetricManager implements IMetricManager
2528
public ThreadMetricManager(List<BaseMetric> metrics, List<Integer> listThreads) {
2629
List<BaseMetric> listMetrics = FastList.newList(metrics.size());
2730
mapIntToMetric = new IntObjectHashMap<BaseMetric>();
31+
Map<String, MetricRaw> mapNameToMetric = new HashMap<>(listMetrics.size());
2832

2933
for(BaseMetric m: metrics) {
3034
MetricRaw mr = MetricRaw.create(m);
3135
mr.setThread(listThreads);
36+
3237
listMetrics.add(mr);
3338
mapIntToMetric.put(m.getIndex(), mr);
39+
40+
// reconstruct the metric partner
41+
var length = mr.getDisplayName().length();
42+
var baseName = mr.getDisplayName().substring(0, length-4);
43+
var partner = mapNameToMetric.get(baseName);
44+
45+
if (partner == null) {
46+
mapNameToMetric.put(baseName, mr);
47+
} else {
48+
partner.setPartner(mr.getIndex());
49+
mr.setPartner(partner.getIndex());
50+
51+
partner.setMetricPartner(mr);
52+
mr.setMetricPartner(partner);
53+
}
3454
}
3555
rawMetrics = GlazedLists.eventList(listMetrics);
3656
}

0 commit comments

Comments
 (0)