HPCToolkit
SpaceTimeDataController.cpp
Go to the documentation of this file.
1 // -*-Mode: C++;-*-
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL: https://hpctoolkit.googlecode.com/svn/branches/hpctoolkit-hpcserver/src/tool/hpcserver/SpaceTimeDataController.cpp $
6 // $Id: SpaceTimeDataController.cpp 4317 2013-07-25 16:32:22Z felipet1326@gmail.com $
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //***************************************************************************
48 //
49 // File:
50 // $HeadURL: https://hpctoolkit.googlecode.com/svn/branches/hpctoolkit-hpcserver/src/tool/hpcserver/SpaceTimeDataController.cpp $
51 //
52 // Purpose:
53 // Manages much of the flow of data through the program
54 //
55 // Description:
56 // [The set of functions, macros, etc. defined in the file]
57 //
58 //***************************************************************************
60 #include "FileData.hpp"
61 #include <iostream>
62 using namespace std;
63 namespace TraceviewerServer
64 {
65 
66 //ImageTraceAttributes* Attributes;
67 //ProcessTimeline** Traces;
68 //int TracesLength;
69 
70  SpaceTimeDataController::SpaceTimeDataController(FileData* locations)
71  {
72  attributes = new ImageTraceAttributes();
73 
74  //This could potentially be a problem if the header size is not the
75  //default because we might not be able to read the number of ranks correctly.
76  //For now, it's not an issue, and the data dependencies make changing this
77  //complicated.
78  dataTrace = new FilteredBaseData(locations->fileTrace, DEFAULT_HEADER_SIZE);
79  height = dataTrace->getNumberOfRanks();
80  experimentXML = locations->fileXML;
81  fileTrace = locations->fileTrace;
82  tracesInitialized = false;
83 
84  }
85 
86 //called once the INFO packet has been received to add the information to the controller
87  void SpaceTimeDataController::setInfo(Time _minBegTime, Time _maxEndTime,
88  int _headerSize)
89  {
90  minBegTime = _minBegTime;
91  maxEndTime = _maxEndTime;
92  headerSize = _headerSize;
93  delete dataTrace;
94  dataTrace = new FilteredBaseData(fileTrace, headerSize);
95  }
96 
97  int SpaceTimeDataController::getNumRanks()
98  {
99  return height;
100  }
101 
102  string SpaceTimeDataController::getExperimentXML()
103  {
104  return experimentXML;
105  }
106 
107  ProcessTimeline* SpaceTimeDataController::getNextTrace()
108  {
109  if (attributes->lineNum
110  < min(attributes->numPixelsV, attributes->endProcess - attributes->begProcess))
111  {
112  ProcessTimeline* toReturn = new ProcessTimeline(*attributes, attributes->lineNum, dataTrace,
113  minBegTime + attributes->begTime, headerSize);
114  attributes->lineNum++;
115  return toReturn;
116  }
117  return NULL;
118  }
119 
120  void SpaceTimeDataController::addNextTrace(ProcessTimeline* NextPtl)
121  {
122  if (NextPtl == NULL)
123  cerr << "Saving a null PTL?" << endl;
124  traces[NextPtl->line()] = NextPtl;
125  }
126 
127  //Don't call if in MPI mode
128  void SpaceTimeDataController::fillTraces()
129  {
130  //Traces might be null. resetTraces will fix that.
131  resetTraces();
132 
133 
134  //Taken straight from TimelineThread
135  ProcessTimeline* nextTrace = getNextTrace();
136  while (nextTrace != NULL)
137  {
138  nextTrace->readInData();
139  addNextTrace(nextTrace);
140 
141  nextTrace = getNextTrace();
142  }
143  }
144 
145  int* SpaceTimeDataController::getValuesXProcessID()
146  {
147  return dataTrace->getProcessIDs();
148  }
149  short* SpaceTimeDataController::getValuesXThreadID()
150  {
151  return dataTrace->getThreadIDs();
152  }
153 
154  void SpaceTimeDataController::resetTraces()
155  {
156 
157  int numTraces = min(attributes->numPixelsV,
158  attributes->endProcess - attributes->begProcess);
159 
160  deleteTraces();
161 
162  traces = new ProcessTimeline*[numTraces];
163  tracesLength = numTraces;
164  tracesInitialized = true;
165 
166  }
167  void SpaceTimeDataController::applyFilters(FilterSet filters)
168  {
169  dataTrace->setFilters(filters);
170  }
171  void SpaceTimeDataController::deleteTraces()
172  {
173  if (tracesInitialized) {
174 
175  for (int var = 0; var < tracesLength; var++)
176  {
177  delete (traces[var]);
178  }
179  delete[] traces;
180  }
181  traces = NULL;
182  tracesInitialized = false;
183  }
184  SpaceTimeDataController::~SpaceTimeDataController()
185  {
186  delete attributes;
187  delete dataTrace;
188 
189  //The MPI implementation actually doesn't use the Traces array at all!
190  //It does call getNextTrace, but changedBounds is always true so
191  //tracesInitialized is always false for MPI
192  deleteTraces();
193 
194  }
195 
196 } /* namespace TraceviewerServer */
#define NULL
Definition: ElfHelper.cpp:85