/usr/include/vtk-7.1/vtkParallelTimer.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkParallelTimer.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
//
/**
* @class vtkParallelTimer
*
*
* Provides ditributed log functionality. When the file is
* written each process data is collected by rank 0 who
* writes the data to a single file in rank order.
*
* The log works as an event stack. EventStart pushes the
* event identifier and its start time onto the stack. EventEnd
* pops the most recent event time and identifier computes the
* ellapsed time and adds an entry to the log recording the
* event, it's start and end times, and its ellapsed time.
* EndEventSynch includes a barrier before the measurement.
*
* The log class implements the singleton patern so that it
* may be shared accross class boundaries. If the log instance
* doesn't exist then one is created. It will be automatically
* destroyed at exit by the signleton destructor. It can be
* destroyed explicitly by calling DeleteGlobalInstance.
*/
#ifndef vtkParallelTimer_h
#define vtkParallelTimer_h
#define vtkParallelTimerDEBUG -1
#include "vtkObject.h"
#include "vtkRenderingParallelLICModule.h" // for export
#include <vector> // for vector
#include <string> // for string
#include <sstream> // for sstream
#if vtkParallelTimerDEBUG > 0
#include <iostream> // for cerr
#endif
class vtkParallelTimerBuffer;
class VTKRENDERINGPARALLELLIC_EXPORT vtkParallelTimer : public vtkObject
{
public:
static vtkParallelTimer *New();
vtkTypeMacro(vtkParallelTimer,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Type used to direct an output stream into the log's header. The header
* is a buffer used only by the root rank.
*/
class LogHeaderType
{
public:
template<typename T> LogHeaderType &operator<<(const T& s);
};
//@}
//@{
/**
* Type used to direct an output stream into the log's body. The body is a
* buffer that all ranks write to.
*/
class LogBodyType
{
public:
template<typename T> LogBodyType &operator<<(const T& s);
};
//@}
//@{
/**
* Set the rank who writes.
*/
vtkSetMacro(WriterRank,int);
vtkGetMacro(WriterRank,int);
//@}
//@{
/**
* Set the filename that is used during write when the object
* is used as a singleton. If nothing is set the default is
* ROOT_RANKS_PID.log
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
void SetFileName(const std::string &fileName)
{ this->SetFileName(fileName.c_str()); }
//@{
/**
* The log works as an event stack. EventStart pushes the
* event identifier and its start time onto the stack. EventEnd
* pops the most recent event time and identifier computes the
* ellapsed time and adds an entry to the log recording the
* event, it's start and end times, and its ellapsed time.
* EndEventSynch includes a barrier before the measurement.
*/
void StartEvent(const char *event);
void StartEvent(int rank, const char *event);
void EndEvent(const char *event);
void EndEvent(int rank, const char *event);
void EndEventSynch(const char *event);
void EndEventSynch(int rank, const char *event);
//@}
/**
* Insert text into the log header on the writer rank.
*/
template<typename T>
vtkParallelTimer &operator<<(const T& s);
/**
* stream output to the log's header(root rank only).
*/
vtkParallelTimer::LogHeaderType GetHeader()
{ return vtkParallelTimer::LogHeaderType(); }
/**
* stream output to log body(all ranks).
*/
vtkParallelTimer::LogBodyType GetBody()
{ return vtkParallelTimer::LogBodyType(); }
/**
* Clear the log.
*/
void Clear();
/**
* When an object is finished writing data to the log
* object it must call Update to send the data to the writer
* rank.
* This ensures that all data is transfered to the root before
* MPI_Finalize is called while allowing the write to occur
* after Mpi_finalize. Note: This is a collective call.
*/
void Update();
/**
* Write the log contents to a file.
*/
int Write();
/**
* The log class implements the singleton patern so that it
* may be shared accross class boundaries. If the log instance
* doesn't exist then one is created. It will be automatically
* destroyed at exit by the signleton destructor. It can be
* destroyed explicitly by calling DeleteGlobalInstance.
*/
static vtkParallelTimer *GetGlobalInstance();
/**
* Explicitly delete the singleton.
*/
static void DeleteGlobalInstance();
//@{
/**
* If enabled and used as a singleton the log will write
* it's contents to disk during program termination.
*/
vtkSetMacro(WriteOnClose, int);
vtkGetMacro(WriteOnClose, int);
//@}
//@{
/**
* Set/Get the global log level. Applications can set this to the
* desired level so that all pipeline objects will log data.
*/
vtkSetMacro(GlobalLevel, int);
vtkGetMacro(GlobalLevel, int);
//@}
protected:
vtkParallelTimer();
virtual ~vtkParallelTimer();
private:
vtkParallelTimer(const vtkParallelTimer&) VTK_DELETE_FUNCTION;
void operator=(const vtkParallelTimer&) VTK_DELETE_FUNCTION;
/**
* A class responsible for delete'ing the global instance of the log.
*/
class VTKRENDERINGPARALLELLIC_EXPORT vtkParallelTimerDestructor
{
public:
vtkParallelTimerDestructor() : Log(0) {}
~vtkParallelTimerDestructor();
void SetLog(vtkParallelTimer *log){ this->Log = log; }
private:
vtkParallelTimer *Log;
};
private:
int GlobalLevel;
int Initialized;
int WorldRank;
int WriterRank;
char *FileName;
int WriteOnClose;
std::vector<double> StartTime;
#if vtkParallelTimerDEBUG < 0
std::vector<std::string> EventId;
#endif
vtkParallelTimerBuffer *Log;
static vtkParallelTimer *GlobalInstance;
static vtkParallelTimerDestructor GlobalInstanceDestructor;
std::ostringstream HeaderBuffer;
friend class LogHeaderType;
friend class LogBodyType;
};
//-----------------------------------------------------------------------------
template<typename T>
vtkParallelTimer &vtkParallelTimer::operator<<(const T& s)
{
if (this->WorldRank == this->WriterRank)
{
this->HeaderBuffer << s;
#if vtkParallelTimerDEBUG > 0
std::cerr << s;
#endif
}
return *this;
}
//-----------------------------------------------------------------------------
template<typename T>
vtkParallelTimer::LogHeaderType &vtkParallelTimer::LogHeaderType::operator<<(const T& s)
{
vtkParallelTimer *log = vtkParallelTimer::GetGlobalInstance();
if (log->WorldRank == log->WriterRank)
{
log->HeaderBuffer << s;
#if vtkParallelTimerDEBUG > 0
std::cerr << s;
#endif
}
return *this;
}
//-----------------------------------------------------------------------------
template<typename T>
vtkParallelTimer::LogBodyType &vtkParallelTimer::LogBodyType::operator<<(const T& s)
{
vtkParallelTimer *log = vtkParallelTimer::GetGlobalInstance();
*(log->Log) << s;
#if vtkParallelTimerDEBUG > 0
std::cerr << s;
#endif
return *this;
}
#endif
|