MergeMetric.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.data.experiment.merge;
00002
00003 import java.util.ArrayList;
00004
00005 import edu.rice.cs.hpc.data.experiment.metric.BaseMetric;
00006 import edu.rice.cs.hpc.data.experiment.metric.MetricValue;
00007 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 public class MergeMetric {
00020 int pointerMetric1[];
00021 int pointerMetric2[];
00022 int pointerCommon[];
00023
00024 ArrayList<BaseMetric> metrics;
00025
00026
00027
00028
00029
00030
00031
00032
00033 static public void mergeMetrics(Scope target, Scope source, int offset[]) {
00034
00035 for(int i=0; i<offset.length; i++) {
00036 MetricValue sourceValue = source.getMetricValue(i);
00037 MetricValue newValue = MetricValue.NONE;
00038
00039 if (sourceValue != null && MetricValue.isAvailable(sourceValue)) {
00040 newValue = new MetricValue();
00041 MetricValue targetValue = target.getMetricValue(offset[i]);
00042 float myValue = 0;
00043
00044 if (targetValue != null && MetricValue.isAvailable(targetValue)) {
00045 myValue = target.getMetricValue(offset[i]).getValue();
00046 }
00047 MetricValue.setValue(newValue, myValue - sourceValue.getValue());
00048 target.setMetricValue(offset[i], newValue);
00049 }
00050
00051 MetricValue.setAnnotationAvailable(newValue, false);
00052 }
00053 }
00054
00055 static public void setMetrics(Scope target, Scope source, int offset[], int factor) {
00056
00057 for(int i=0; i<offset.length; i++) {
00058 MetricValue mv = source.getMetricValue(i);
00059 MetricValue mine = MetricValue.NONE;
00060
00061 if (mv != null && MetricValue.isAvailable(mv)) {
00062 mine = new MetricValue();
00063 MetricValue myMV = target.getMetricValue(i);
00064 float myValue = 0;
00065
00066 if (myMV != null && MetricValue.isAvailable(myMV)) {
00067 myValue = target.getMetricValue(i).getValue();
00068 MetricValue.setValue(mine, myValue - mv.getValue());
00069 } else {
00070 MetricValue.setValue(mine, factor * mv.getValue());
00071 float annValue = MetricValue.getAnnotationValue(mv);
00072 MetricValue.setAnnotationValue(mine, annValue);
00073 }
00074
00075 MetricValue.setAnnotationAvailable(mine, false);
00076 target.setMetricValue(i, mine);
00077 }
00078 }
00079 }
00080
00081 }