ProcessTimeline.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.data.timeline;
00002 
00003 import java.util.HashMap;
00004 
00005 import org.eclipse.core.runtime.Assert;
00006 
00007 import edu.rice.cs.hpc.data.experiment.extdata.AbstractBaseData;
00008 import edu.rice.cs.hpc.data.experiment.extdata.IBaseData;
00009 import edu.rice.cs.hpc.traceviewer.data.db.TraceDataByRank;
00010 import edu.rice.cs.hpc.traceviewer.data.db.DataRecord;
00011 import edu.rice.cs.hpc.traceviewer.data.graph.CallPath;
00012 
00014 public class ProcessTimeline {
00015 
00017     private HashMap<Integer, CallPath> scopeMap;
00018 
00020     private int lineNum;
00021 
00023     private long startingTime;
00024 
00026     private long timeRange;
00027 
00029     private double pixelLength;
00030 
00031     final TraceDataByRank data;
00032 
00033     /*************************************************************************
00034      * Reads in the call-stack trace data from the binary traceFile in the form:
00035      * double time-stamp int Call-Path ID double time-stamp int Call-Path ID ...
00036      ************************************************************************/
00037 
00042     public ProcessTimeline(int _lineNum, HashMap<Integer, CallPath> _scopeMap, IBaseData dataTrace, 
00043             int _processNumber, int _numPixelH, long _timeRange, long _startingTime)
00044     {
00045 
00046         lineNum = _lineNum;
00047         scopeMap = _scopeMap;
00048 
00049         timeRange = _timeRange;
00050         startingTime = _startingTime;
00051 
00052         pixelLength = timeRange / (double) _numPixelH;
00053         
00054         //TODO: Beautify
00055         if (dataTrace instanceof AbstractBaseData)
00056             data = new TraceDataByRank((AbstractBaseData) dataTrace, _processNumber, _numPixelH);
00057         else
00058             data = new TraceDataByRank(new DataRecord[0]);
00059     }
00060 
00061     //Remote version
00062     public ProcessTimeline(TraceDataByRank _data,
00063             HashMap<Integer, CallPath> _scopeMap, int _processNumber,
00064             int _numPixelH, long _timeRange, long _startingTime) {
00065         lineNum = _processNumber;
00066         scopeMap = _scopeMap;
00067 
00068         timeRange = _timeRange;
00069         startingTime = _startingTime;
00070 
00071         pixelLength = timeRange / (double) _numPixelH;
00072         if (_data == null)
00073             data = new TraceDataByRank(new DataRecord[0]);
00074         else
00075             data = _data;
00076     }
00077 
00082     public void readInData() {
00083 
00084         data.getData(startingTime, timeRange,
00085                 pixelLength);
00086     }
00087 
00089     public long getTime(int sample) {
00090         return data.getTime(sample);
00091     }
00092 
00094     private int getCpid(int sample) {
00095         return data.getCpid(sample);
00096     }
00097 
00098     public void shiftTimeBy(long lowestStartingTime) {
00099         data.shiftTimeBy(lowestStartingTime);
00100     }
00101 
00103     public CallPath getCallPath(int sample, int depth) {
00104         Assert.isTrue(sample>=0, "sample number is negative");
00105         int cpid = getCpid(sample);
00106 
00107         CallPath cp = scopeMap.get(cpid);
00108         if (cp == null) {
00109             System.err.println("ERROR: No sample found for cpid " + cpid
00110                     + " in trace sample: " + sample);
00111             System.err
00112                     .println("\tThere was most likely an error in the data collection; the display may be inaccurate.");
00113         }
00114         return cp;
00115     }
00120     public void copyDataFrom(ProcessTimeline another) {
00121         this.data.setListOfData(another.data.getListOfData());
00122     }
00123 
00125     public int size() {
00126         return data.size();
00127     }
00128 
00130     public int line() {
00131         return lineNum;
00132     }
00133 
00141     public int findMidpointBefore(long time, boolean usingMidpoint)
00142     {
00143         return data.findMidpointBefore(time, usingMidpoint);
00144     }
00145 
00146     /****
00147      * retrieve the trace data of this process time line
00148      * @return
00149      */
00150     public TraceDataByRank getData() 
00151     {
00152         return data;
00153     }
00154     // These are potentially useful for debugging, but otherwise serve no use.
00155 //  @Override
00156 //  public String toString() {
00157 //      return hashCode() + "#" + data.getRank();
00158 //  }
00159 //
00160 //  @Override
00161 //  public int hashCode() {
00162 //      double hash = 0.0;
00163 //      for (Record r : data.getListOfData()) {
00164 //          hash += r.cpId + Math.log(r.timestamp);
00165 //      }
00166 //      return (int) Math.round(hash);
00167 //  }
00168 
00169 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1