/usr/include/trilinos/Amesos_Time.h is in libtrilinos-amesos-dev 12.12.1-5.
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 | #ifndef AMESOS_TIME_H
#define AMESOS_TIME_H
#include "Epetra_Comm.h"
#include "Epetra_Time.h"
#include "Teuchos_Array.hpp"
#include "Teuchos_RCP.hpp"
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_Assert.hpp"
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::Array;
/*!
\struct Amesos_Time_Data
\brief Amesos_Time_Data: Simple struct for storing associated data for Amesos_Time.
\author Heidi Thornquist, SNL 1437
\date Last updated on 26-March-07
*/
struct Amesos_Time_Data {
//! Character string identifying this timing data.
std::string timeName_;
//! Current timing data.
double timeVal_;
//! Constructor
Amesos_Time_Data( std::string timeName, double timeVal ) :
timeName_(timeName),
timeVal_(timeVal)
{}
//! Destructor
virtual ~Amesos_Time_Data()
{}
};
/*!
\class Amesos_Time
\brief Amesos_Time: Container for timing information.
\author Marzio Sala, SNL 9214
\date Last updated on 26-March-07 by Heidi Thornquist
*/
class Amesos_Time
{
public:
//! Default constructor to create \c size timers.
Amesos_Time() :
size_(1)
{}
//! Default destructor.
virtual ~Amesos_Time()
{}
//! Initializes the Time object.
inline void CreateTimer(const Epetra_Comm& Comm, int size = 1)
{
size_ = size;
time_.resize(size_);
for (int i = 0 ; i < size_ ; ++i)
time_[i] = rcp(new Epetra_Time(Comm));
}
//! Resets the internally stored time object.
inline void ResetTimer(const int timerID = 0)
{
time_[timerID]->ResetStartTime();
}
//! Adds to field \c what the time elapsed since last call to ResetTimer().
inline int AddTime(const std::string what, int dataID, const int timerID = 0)
{
// A valid data id is assumed to be > 0, if the id < 0,
// then a new entry in the array is created.
if (dataID < 0) {
data_.push_back( Amesos_Time_Data( what, time_[timerID]->ElapsedTime() ) );
return data_.size()-1;
}
// Check to make sure the data id is valid
TEUCHOS_TEST_FOR_EXCEPTION(
timerID >= (int)(data_.size()), std::logic_error,
"Amesos_Time::AddTime(...): Error, dataID="<<dataID
<<" is >= data_.size()="<<data_.size() <<" for dataName=\""<<what<<"\"!"
);
// The id is valid and the current elapsed time from the indicated timer will be added in.
data_[dataID].timeVal_ += time_[timerID]->ElapsedTime();
return dataID;
}
//! Gets the cumulative time using the string.
inline double GetTime(const std::string what) const
{
int dataSize = (int)(data_.size());
for (int i=0; i<dataSize; ++i) {
if ( data_[i].timeName_ == what ) {
return data_[i].timeVal_;
}
}
return 0.0;
}
//! Gets the cumulative time using the dataID.
inline double GetTime(const int dataID) const
{
// Return zero if the dataID is not valid
if ( dataID < 0 || dataID >= (int)(data_.size()) ) {
return 0.0;
}
return data_[dataID].timeVal_;
}
//! Load up the current timing information into the parameter list.
inline void GetTiming( Teuchos::ParameterList& list ) const
{
int dataSize = (int)(data_.size());
for (int i=0; i<dataSize; ++i) {
list.set( data_[i].timeName_, data_[i].timeVal_ );
}
}
private:
//! Number of Epetra_Time objects allocated in \c this object.
int size_;
//! Time object.
Array<RCP<Epetra_Time> > time_;
//! Fast accessable container for timing data.
Array< Amesos_Time_Data > data_;
};
#endif
|