Commit 0cb97237 authored by hrchilds's avatar hrchilds
Browse files

Update from April 21, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@227 18c085ea-50e0-402c-830e-de6fd14e8384
parent cca4a4f7
......@@ -3,7 +3,10 @@
// ************************************************************************* //
#include <TimingsManager.h>
#include <snprintf.h>
#include <map>
#include <float.h>
#include <fstream.h>
#include <time.h>
#include <stdio.h>
......@@ -23,9 +26,71 @@ int ftime(struct timeb *);
#endif
#endif
TimingsManager *visitTimer = TimingsManager::Initialize("default");
// ****************************************************************************
// Function:GetCurrentTimeInfo
//
// Programmer: Mark C. Miller
// Creation: April 20, 2004
//
// ****************************************************************************
static void
GetCurrentTimeInfo(struct TIMEINFO &timeInfo)
{
#if defined(_WIN32)
_ftime(&timeInfo);
#elif defined(__APPLE__)
gettimeofday(&timeInfo, 0);
#else
ftime(&timeInfo);
#endif
}
// ****************************************************************************
// Method: TimingsManager::TimeSinceLastCall
//
// Purpose:
// Computes time since last called with same key
//
// Programmer: Mark C. Miller
// Creation: April 20, 2004
//
// ****************************************************************************
double
TimingsManager::TimeSinceLastCall(const char *file, int line)
{
static std::map<std::string, TIMEINFO> keyMap;
// a way to re-initilize this static function's static member if
// ever needed
if ((file == 0) && (line < 0))
{
keyMap.clear();
return 0.0;
}
struct TIMEINFO currentTime;
GetCurrentTimeInfo(currentTime);
char key[256];
SNPRINTF(key, sizeof(key), "%s#%d", file, line);
if (keyMap.find(key) == keyMap.end())
{
keyMap[key] = currentTime;
return DBL_MAX;
}
else
{
struct TIMEINFO lastTime = keyMap[key];
keyMap[key] = currentTime;
return DiffTime(lastTime, currentTime);
}
}
// ****************************************************************************
// Method: TimingsManager constructor
//
......@@ -337,6 +402,55 @@ TimingsManager::DumpTimings(ostream &out)
summaries.clear();
}
// ****************************************************************************
// Method: TimingsManager::DiffTime
//
// Purpose:
// Compute the difference in time from platform specific time structures
//
// Returns: The elapsed time in seconds as a double.
//
// Programmer: Hank Childs
// Creation: March 10, 2001
//
// Modifications:
//
// Mark C. Miller, Tue Apr 20 21:12:05 PDT 2004
// Relocated from PlatformStopTimer
//
// ****************************************************************************
double
TimingsManager::DiffTime(const struct TIMEINFO &startTime,
const struct TIMEINFO &endTime)
{
#if defined(__APPLE__)
double seconds = double(endTime.tv_sec - startTime.tv_sec) +
double(endTime.tv_usec - startTime.tv_usec) / 1000000.;
return seconds;
#else
//
// Figure out how many milliseconds between start and end times
//
int ms = (int) difftime(endTime.time, startTime.time);
if (ms == 0)
{
ms = endTime.millitm - startTime.millitm;
}
else
{
ms = ((ms - 1) * 1000);
ms += (1000 - startTime.millitm) + endTime.millitm;
}
return (ms/1000.);
#endif
}
// ****************************************************************************
// Method: SystemTimingsManager::PlatformStartTimer
......@@ -357,26 +471,19 @@ TimingsManager::DumpTimings(ostream &out)
// Brad Whitlock, Mon May 19 12:37:44 PDT 2003
// I made it work on MacOS X.
//
// Mark C. Miller Wed Apr 21 12:42:13 PDT 2004
// I made it use GetCurrentTime
//
// ****************************************************************************
void
SystemTimingsManager::PlatformStartTimer(void)
{
#if defined(_WIN32)
struct _timeb t;
_ftime(&t);
#elif defined(__APPLE__)
struct timeval t;
gettimeofday(&t, 0);
#else
struct timeb t;
ftime(&t);
#endif
struct TIMEINFO t;
GetCurrentTimeInfo(t);
values.push_back(t);
}
// ****************************************************************************
// Method: SystemTimingsManager::PlatformStopTimer
//
......@@ -403,50 +510,20 @@ SystemTimingsManager::PlatformStartTimer(void)
// Brad Whitlock, Mon May 19 12:37:58 PDT 2003
// I made it work on MacOS X.
//
// Mark C. Miller, Tue Apr 20 21:12:05 PDT 2004
// Moved bulk of implementation to DiffTime so code could be shared
// with TOATimer
//
// ****************************************************************************
double
SystemTimingsManager::PlatformStopTimer(int index)
{
#if defined(__APPLE__)
struct timeval endTime;
gettimeofday(&endTime, 0);
struct timeval &startTime = values[index];
double seconds = double(endTime.tv_sec - startTime.tv_sec) +
double(endTime.tv_usec - startTime.tv_usec) / 1000000.;
return seconds;
#else
#if defined(_WIN32)
struct _timeb endTime;
_ftime(&endTime);
struct _timeb &startTime = values[index];
#else
struct timeb endTime;
ftime(&endTime);
struct timeb &startTime = values[index];
#endif
//
// Figure out how many milliseconds the rendering took.
//
int ms = (int) difftime(endTime.time, startTime.time);
if (ms == 0)
{
ms = endTime.millitm - startTime.millitm;
}
else
{
ms = ((ms - 1) * 1000);
ms += (1000 - startTime.millitm) + endTime.millitm;
}
return (ms/1000.);
#endif
struct TIMEINFO endTime;
GetCurrentTimeInfo(endTime);
return DiffTime(values[index], endTime);
}
// ****************************************************************************
// Method: MPITimingsManager::PlatformStartTimer
//
......
......@@ -17,6 +17,18 @@
#include <vector>
#include <misc_exports.h>
// useful macro for declaring time info structs
#if defined(_WIN32)
# define TIMEINFO _timeb
#elif defined(__APPLE__)
# define TIMEINFO timeval
#else
# define TIMEINFO timeb
#endif
// useful macro for computing time of arrival at a particular line of code
#define DELTA_TOA_HERE TimingsManager::TimeSinceLastCall(__FILE__, __LINE__)
// ****************************************************************************
// Class: TimingsManager
//
......@@ -42,6 +54,10 @@
// Brad Whitlock, Mon May 19 12:36:50 PDT 2003
// Added MacOS X code.
//
// Mark C. Miller, Wed Apr 21 12:42:13 PDT 2004
// I added static methods, TimeSinceLastArrival, DiffTime
// I defined the TIMEINFO macro and restructured code to use it
//
// ****************************************************************************
class MISC_API TimingsManager
......@@ -50,6 +66,8 @@ class MISC_API TimingsManager
TimingsManager();
virtual ~TimingsManager() {;};
static double TimeSinceLastCall(const char *file, int line);
static TimingsManager *Initialize(const char *);
void SetFilename(const std::string &s);
......@@ -59,6 +77,8 @@ class MISC_API TimingsManager
int StartTimer(void);
double StopTimer(int, const std::string &);
static double DiffTime();
void DumpTimings(void);
void DumpTimings(ostream &);
......@@ -72,6 +92,9 @@ class MISC_API TimingsManager
std::vector<double> times;
std::vector<std::string> summaries;
static double DiffTime(const struct TIMEINFO &startTime,
const struct TIMEINFO &endTime);
virtual void PlatformStartTimer(void) = 0;
virtual double PlatformStopTimer(int) = 0;
};
......@@ -83,13 +106,7 @@ class MISC_API SystemTimingsManager : public TimingsManager
virtual ~SystemTimingsManager() {;};
protected:
#if defined(_WIN32)
std::vector<_timeb> values;
#elif defined(__APPLE__)
std::vector<timeval> values;
#else
std::vector<timeb> values;
#endif
std::vector<TIMEINFO> values;
virtual void PlatformStartTimer(void);
virtual double PlatformStopTimer(int);
};
......
......@@ -2,6 +2,8 @@
#include <Observer.h>
#include <MessageAttributes.h>
#include <TimingsManager.h> // for DELTA_TOA_HERE
#include <qapplication.h>
#include <qlabel.h>
#include <qmultilineedit.h>
......@@ -103,6 +105,10 @@ QvisMessageWindow::~QvisMessageWindow()
// Brad Whitlock, Wed Sep 10 09:44:44 PDT 2003
// I made the cursor get reset for error and warning messages.
//
// Mark C. Miller Wed Apr 21 12:42:13 PDT 2004
// I made it smarter about dealing with messages that occur close together in time.
// Now, it will catenate them.
//
// *************************************************************************************
void
......@@ -110,23 +116,55 @@ QvisMessageWindow::Update(Subject *)
{
MessageAttributes *ma = (MessageAttributes *)subject;
double secondsSinceLastMessage = DELTA_TOA_HERE;
QString msgText;
MessageAttributes::Severity severity = ma->GetSeverity();
if (secondsSinceLastMessage < 5.0)
{
MessageAttributes::Severity oldSeverity;
QString oldSeverityLabel = severityLabel->text();
if (oldSeverityLabel == "Error!")
oldSeverity = MessageAttributes::Error;
else if (oldSeverityLabel == "Warning")
oldSeverity = MessageAttributes::Warning;
else if (oldSeverityLabel == "Message")
oldSeverity = MessageAttributes::Message;
else
oldSeverity = MessageAttributes::Error;
// set severity to whichever is worse
if (oldSeverity < severity)
severity = oldSeverity;
// catenate new message onto old
msgText = messageText->text();
msgText += "\n\nShortly thereafter, the following occured...\n\n";
QString newMsgText = QString(ma->GetText().c_str());
msgText += newMsgText;
}
else
{
msgText = QString(ma->GetText().c_str());
}
// Set the severity label text.
if(ma->GetSeverity() == MessageAttributes::Error)
if(severity == MessageAttributes::Error)
{
show();
qApp->beep();
severityLabel->setText(QString("Error!"));
RestoreCursor();
}
else if(ma->GetSeverity() == MessageAttributes::Warning)
else if(severity == MessageAttributes::Warning)
{
show();
severityLabel->setText(QString("Warning"));
RestoreCursor();
}
else if(ma->GetSeverity() == MessageAttributes::Message)
else if(severity == MessageAttributes::Message)
severityLabel->setText(QString("Message"));
// Set the message text.
messageText->setText(QString(ma->GetText().c_str()));
messageText->setText(msgText);
}
......@@ -13,7 +13,7 @@ import java.lang.Double;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Fri Jan 23 14:13:29 PST 2004
// Creation: Tue Apr 20 16:04:33 PST 2004
//
// Modifications:
//
......@@ -31,7 +31,7 @@ public class DatabaseCorrelation extends AttributeSubject
public DatabaseCorrelation()
{
super(8);
super(10);
name = new String("(null)");
numStates = 1;
......@@ -41,11 +41,13 @@ public class DatabaseCorrelation extends AttributeSubject
databaseTimes = new Vector();
databaseCycles = new Vector();
indices = new Vector();
condensedTimes = new Vector();
condensedCycles = new Vector();
}
public DatabaseCorrelation(DatabaseCorrelation obj)
{
super(8);
super(10);
int i;
......@@ -81,6 +83,19 @@ public class DatabaseCorrelation extends AttributeSubject
Integer iv = (Integer)obj.indices.elementAt(i);
indices.addElement(new Integer(iv.intValue()));
}
condensedTimes = new Vector(obj.condensedTimes.size());
for(i = 0; i < obj.condensedTimes.size(); ++i)
{
Double dv = (Double)obj.condensedTimes.elementAt(i);
condensedTimes.addElement(new Double(dv.doubleValue()));
}
condensedCycles = new Vector();
for(i = 0; i < obj.condensedCycles.size(); ++i)
{
Integer iv = (Integer)obj.condensedCycles.elementAt(i);
condensedCycles.addElement(new Integer(iv.intValue()));
}
SelectAll();
}
......@@ -97,7 +112,9 @@ public class DatabaseCorrelation extends AttributeSubject
(databaseNStates == obj.databaseNStates) &&
(databaseTimes == obj.databaseTimes) &&
(databaseCycles == obj.databaseCycles) &&
(indices == obj.indices));
(indices == obj.indices) &&
(condensedTimes == obj.condensedTimes) &&
(condensedCycles == obj.condensedCycles));
}
// Property setting methods
......@@ -149,6 +166,18 @@ public class DatabaseCorrelation extends AttributeSubject
Select(7);
}
public void SetCondensedTimes(Vector condensedTimes_)
{
condensedTimes = condensedTimes_;
Select(8);
}
public void SetCondensedCycles(Vector condensedCycles_)
{
condensedCycles = condensedCycles_;
Select(9);
}
// Property getting methods
public String GetName() { return name; }
public int GetNumStates() { return numStates; }
......@@ -158,6 +187,8 @@ public class DatabaseCorrelation extends AttributeSubject
public Vector GetDatabaseTimes() { return databaseTimes; }
public Vector GetDatabaseCycles() { return databaseCycles; }
public Vector GetIndices() { return indices; }
public Vector GetCondensedTimes() { return condensedTimes; }
public Vector GetCondensedCycles() { return condensedCycles; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -178,6 +209,10 @@ public class DatabaseCorrelation extends AttributeSubject
buf.WriteIntVector(databaseCycles);
if(WriteSelect(7, buf))
buf.WriteIntVector(indices);
if(WriteSelect(8, buf))
buf.WriteDoubleVector(condensedTimes);
if(WriteSelect(9, buf))
buf.WriteIntVector(condensedCycles);
}
public void ReadAtts(int n, CommunicationBuffer buf)
......@@ -211,6 +246,12 @@ public class DatabaseCorrelation extends AttributeSubject
case 7:
SetIndices(buf.ReadIntVector());
break;
case 8:
SetCondensedTimes(buf.ReadDoubleVector());
break;
case 9:
SetCondensedCycles(buf.ReadIntVector());
break;
}
}
}
......@@ -225,5 +266,7 @@ public class DatabaseCorrelation extends AttributeSubject
private Vector databaseTimes; // vector of Double objects
private Vector databaseCycles; // vector of Integer objects
private Vector indices; // vector of Integer objects
private Vector condensedTimes; // vector of Double objects
private Vector condensedCycles; // vector of Integer objects
}
......@@ -11,7 +11,7 @@ import java.util.Vector;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Fri Jan 23 14:13:33 PST 2004
// Creation: Tue Apr 20 16:04:39 PST 2004
//
// Modifications:
//
......@@ -19,16 +19,25 @@ import java.util.Vector;
public class DatabaseCorrelationList extends AttributeSubject
{
// Constants
public final static int WHENTOCORRELATE_CORRELATEALWAYS = 0;
public final static int WHENTOCORRELATE_CORRELATENEVER = 1;
public final static int WHENTOCORRELATE_CORRELATEONLYIFSAMELENGTH = 2;
public DatabaseCorrelationList()
{
super(1);
super(4);
correlations = new Vector();
needPermission = true;
defaultCorrelationMethod = 0;
whenToCorrelate = WHENTOCORRELATE_CORRELATEONLYIFSAMELENGTH;
}
public DatabaseCorrelationList(DatabaseCorrelationList obj)
{
super(1);
super(4);
int i;
......@@ -40,6 +49,9 @@ public class DatabaseCorrelationList extends AttributeSubject
correlations.addElement(new DatabaseCorrelation(newObj));
}
needPermission = obj.needPermission;
defaultCorrelationMethod = obj.defaultCorrelationMethod;
whenToCorrelate = obj.whenToCorrelate;
SelectAll();
}
......@@ -58,12 +70,36 @@ public class DatabaseCorrelationList extends AttributeSubject
}
// Create the return value
return (correlations_equal);
return (correlations_equal &&
(needPermission == obj.needPermission) &&
(defaultCorrelationMethod == obj.defaultCorrelationMethod) &&
(whenToCorrelate == obj.whenToCorrelate));
}
// Property setting methods
public void SetNeedPermission(boolean needPermission_)
{
needPermission = needPermission_;
Select(1);
}
public void SetDefaultCorrelationMethod(int defaultCorrelationMethod_)
{
defaultCorrelationMethod = defaultCorrelationMethod_;
Select(2);
}
public void SetWhenToCorrelate(int whenToCorrelate_)
{
whenToCorrelate = whenToCorrelate_;
Select(3);
}
// Property getting methods
public Vector GetCorrelations() { return correlations; }
public Vector GetCorrelations() { return correlations; }
public boolean GetNeedPermission() { return needPermission; }
public int GetDefaultCorrelationMethod() { return defaultCorrelationMethod; }
public int GetWhenToCorrelate() { return whenToCorrelate; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -77,22 +113,45 @@ public class DatabaseCorrelationList extends AttributeSubject
tmp.Write(buf);
}
}
if(WriteSelect(1, buf))
buf.WriteBool(needPermission);
if(WriteSelect(2, buf))
buf.WriteInt(defaultCorrelationMethod);
if(WriteSelect(3, buf))
buf.WriteInt(whenToCorrelate);
}
public void ReadAtts(int n, CommunicationBuffer buf)
{
buf.ReadByte();
for(int i = 0; i < n; ++i)
{
int len = buf.ReadInt();
correlations.clear();
for(int j = 0; j < len; ++j)
int index = (int)buf.ReadByte();
switch(index)
{
DatabaseCorrelation tmp = new DatabaseCorrelation();
tmp.Read(buf);
correlations.addElement(tmp);
case 0:
{
int len = buf.ReadInt();
correlations.clear();
for(int j = 0; j < len; ++j)
{
DatabaseCorrelation tmp = new DatabaseCorrelation();
tmp.Read(buf);
correlations.addElement(tmp);
}
}
Select(0);
break;
case 1:
SetNeedPermission(buf.ReadBool());
break;
case 2:
SetDefaultCorrelationMethod(buf.ReadInt());
break;
case 3:
SetWhenToCorrelate(buf.ReadInt());