Profiling update, Bernhard Gscheider
This commit is contained in:
parent
a47a1b5577
commit
244849fac2
21 changed files with 186 additions and 175 deletions
|
@ -3,10 +3,10 @@ global/dimensionedConstants/dimensionedConstants.C
|
|||
global/argList/argList.C
|
||||
global/clock/clock.C
|
||||
|
||||
global/Profiling/ProfilingInfo.C
|
||||
global/Profiling/ProfilingPool.C
|
||||
global/Profiling/ProfilingStack.C
|
||||
global/Profiling/ProfilingTrigger.C
|
||||
global/profiling/profilingInfo.C
|
||||
global/profiling/profilingPool.C
|
||||
global/profiling/profilingStack.C
|
||||
global/profiling/profilingTrigger.C
|
||||
|
||||
bools = primitives/bools
|
||||
$(bools)/bool/bool.C
|
||||
|
|
|
@ -27,8 +27,8 @@ License
|
|||
#include "Time.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
#include "ProfilingPool.H"
|
||||
#include "Profiling.H"
|
||||
#include "profilingPool.H"
|
||||
#include "profiling.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -242,8 +242,10 @@ Foam::Time::Time
|
|||
{
|
||||
setControls();
|
||||
|
||||
ProfilingPool::initProfiling(
|
||||
IOobject(
|
||||
profilingPool::initprofiling
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"profilingInfo",
|
||||
timeName(),
|
||||
"uniform",
|
||||
|
@ -310,8 +312,10 @@ Foam::Time::Time
|
|||
{
|
||||
setControls();
|
||||
|
||||
ProfilingPool::initProfiling(
|
||||
IOobject(
|
||||
profilingPool::initprofiling
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"profilingInfo",
|
||||
timeName(),
|
||||
"uniform",
|
||||
|
@ -374,8 +378,10 @@ Foam::Time::Time
|
|||
readLibs_(controlDict_, "libs"),
|
||||
functionObjects_(*this, enableFunctionObjects)
|
||||
{
|
||||
ProfilingPool::initProfiling(
|
||||
IOobject(
|
||||
profilingPool::initprofiling
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"profilingInfo",
|
||||
timeName(),
|
||||
"uniform",
|
||||
|
|
|
@ -27,7 +27,7 @@ License
|
|||
#include "Time.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ License
|
|||
#include "functionObjectList.H"
|
||||
#include "Time.H"
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ License
|
|||
Class
|
||||
|
||||
Description
|
||||
Add everything necessary for Profiling plus a macro
|
||||
Add everything necessary for profiling plus a macro
|
||||
|
||||
Originally proposed in
|
||||
http://www.cfd-online.com/Forums/openfoam-bugs/64081-feature-proposal-application-level-profiling.html
|
||||
|
@ -34,17 +34,17 @@ SourceFiles
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Profiling_H
|
||||
#define Profiling_H
|
||||
#ifndef profiling_H
|
||||
#define profiling_H
|
||||
|
||||
#include "ProfilingTrigger.H"
|
||||
#include "profilingTrigger.H"
|
||||
|
||||
// to be used at the beginning of a section to be profiled
|
||||
// profiling ends automatically at the end of a block
|
||||
#define addProfile(name) Foam::ProfilingTrigger profileTriggerFor##name (#name)
|
||||
#define addProfile(name) Foam::profilingTrigger profileTriggerFor##name (#name)
|
||||
|
||||
// Use this if a description with spaces, colons etc should be added
|
||||
#define addProfile2(name,descr) Foam::ProfilingTrigger profileTriggerFor##name (descr)
|
||||
#define addProfile2(name,descr) Foam::profilingTrigger profileTriggerFor##name (descr)
|
||||
|
||||
// this is only needed if profiling should end before the end of a block
|
||||
#define endProfile(name) profileTriggerFor##name.stop()
|
|
@ -24,21 +24,21 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ProfilingInfo.H"
|
||||
#include "profilingInfo.H"
|
||||
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::ProfilingInfo::nextId_(0);
|
||||
Foam::label Foam::profilingInfo::nextId_(0);
|
||||
|
||||
Foam::label Foam::ProfilingInfo::getID()
|
||||
Foam::label Foam::profilingInfo::getID()
|
||||
{
|
||||
nextId_++;
|
||||
return nextId_;
|
||||
}
|
||||
|
||||
void Foam::ProfilingInfo::raiseID(label maxVal)
|
||||
void Foam::profilingInfo::raiseID(label maxVal)
|
||||
{
|
||||
if(maxVal>nextId_) {
|
||||
nextId_=maxVal;
|
||||
|
@ -50,7 +50,7 @@ void Foam::ProfilingInfo::raiseID(label maxVal)
|
|||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingInfo::ProfilingInfo()
|
||||
Foam::profilingInfo::profilingInfo()
|
||||
:
|
||||
calls_(0),
|
||||
totalTime_(0.),
|
||||
|
@ -62,7 +62,7 @@ Foam::ProfilingInfo::ProfilingInfo()
|
|||
{}
|
||||
|
||||
|
||||
Foam::ProfilingInfo::ProfilingInfo(ProfilingInfo &parent,const string &descr)
|
||||
Foam::profilingInfo::profilingInfo(profilingInfo &parent,const string &descr)
|
||||
:
|
||||
calls_(0),
|
||||
totalTime_(0.),
|
||||
|
@ -75,13 +75,13 @@ Foam::ProfilingInfo::ProfilingInfo(ProfilingInfo &parent,const string &descr)
|
|||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingInfo::~ProfilingInfo()
|
||||
Foam::profilingInfo::~profilingInfo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ProfilingInfo::update(scalar elapsedTimee)
|
||||
void Foam::profilingInfo::update(scalar elapsedTimee)
|
||||
{
|
||||
calls_++;
|
||||
totalTime_+=elapsedTimee;
|
||||
|
@ -90,7 +90,7 @@ void Foam::ProfilingInfo::update(scalar elapsedTimee)
|
|||
}
|
||||
}
|
||||
|
||||
void Foam::ProfilingInfo::writeWithOffset(Ostream &os,bool offset,scalar time,scalar childTimes) const
|
||||
void Foam::profilingInfo::writeWithOffset(Ostream &os,bool offset,scalar time,scalar childTimes) const
|
||||
{
|
||||
dictionary tmp;
|
||||
|
||||
|
@ -112,7 +112,7 @@ void Foam::ProfilingInfo::writeWithOffset(Ostream &os,bool offset,scalar time,sc
|
|||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const ProfilingInfo& info)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const profilingInfo& info)
|
||||
{
|
||||
info.writeWithOffset(os);
|
||||
|
|
@ -23,18 +23,18 @@ License
|
|||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::ProfilingInfo
|
||||
Foam::profilingInfo
|
||||
|
||||
Description
|
||||
Information needed for profiling
|
||||
|
||||
SourceFiles
|
||||
ProfilingInfo.C
|
||||
profilingInfo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ProfilingInfo_H
|
||||
#define ProfilingInfo_H
|
||||
#ifndef profilingInfo_H
|
||||
#define profilingInfo_H
|
||||
|
||||
#include "label.H"
|
||||
#include "scalar.H"
|
||||
|
@ -45,19 +45,20 @@ namespace Foam
|
|||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// class Istream;
|
||||
class Ostream;
|
||||
class ProfilingStack;
|
||||
class ProfilingPool;
|
||||
class ProfilingInfo;
|
||||
|
||||
Ostream& operator<<(Ostream&, const ProfilingInfo&);
|
||||
// class Istream;
|
||||
class Ostream;
|
||||
class profilingStack;
|
||||
class profilingPool;
|
||||
class profilingInfo;
|
||||
|
||||
Ostream& operator<<(Ostream&, const profilingInfo&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ProfilingInfo Declaration
|
||||
Class profilingInfo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ProfilingInfo
|
||||
class profilingInfo
|
||||
{
|
||||
// Private data
|
||||
|
||||
|
@ -74,7 +75,7 @@ class ProfilingInfo
|
|||
label id_;
|
||||
|
||||
// pointer to the parent object (if there is any)
|
||||
ProfilingInfo &parent_;
|
||||
profilingInfo &parent_;
|
||||
|
||||
// what this does
|
||||
string description_;
|
||||
|
@ -85,10 +86,10 @@ class ProfilingInfo
|
|||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ProfilingInfo(const ProfilingInfo&);
|
||||
profilingInfo(const profilingInfo&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ProfilingInfo&);
|
||||
void operator=(const profilingInfo&);
|
||||
|
||||
// Static data members
|
||||
|
||||
|
@ -110,7 +111,7 @@ protected:
|
|||
{ onStack_=false; }
|
||||
|
||||
//- Construct null - only the master-element
|
||||
ProfilingInfo();
|
||||
profilingInfo();
|
||||
|
||||
void writeWithOffset(Ostream &os,bool offset=false,scalar time=0,scalar childTime=0) const;
|
||||
|
||||
|
@ -119,14 +120,14 @@ public:
|
|||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ProfilingInfo(ProfilingInfo &parent,const string &descr);
|
||||
profilingInfo(profilingInfo &parent,const string &descr);
|
||||
|
||||
// //- Construct from Istream
|
||||
// ProfilingInfo(Istream&);
|
||||
// profilingInfo(Istream&);
|
||||
|
||||
// Destructor
|
||||
|
||||
~ProfilingInfo();
|
||||
~profilingInfo();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
@ -151,19 +152,19 @@ public:
|
|||
const string &description() const
|
||||
{ return description_; }
|
||||
|
||||
const ProfilingInfo &parent() const
|
||||
const profilingInfo &parent() const
|
||||
{ return parent_; }
|
||||
|
||||
//- Update it with a new timing information
|
||||
void update(scalar elapsedTime);
|
||||
|
||||
friend class ProfilingStack;
|
||||
friend class ProfilingPool;
|
||||
friend class profilingStack;
|
||||
friend class profilingPool;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
// friend Istream& operator>>(Istream&, ProfilingInfo&);
|
||||
friend Ostream& operator<<(Ostream&, const ProfilingInfo&);
|
||||
// friend Istream& operator>>(Istream&, profilingInfo&);
|
||||
friend Ostream& operator<<(Ostream&, const profilingInfo&);
|
||||
};
|
||||
|
||||
|
|
@ -24,18 +24,18 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ProfilingPool.H"
|
||||
#include "profilingPool.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingPool* Foam::ProfilingPool::thePool_(NULL);
|
||||
Foam::profilingPool* Foam::profilingPool::thePool_(NULL);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingPool::ProfilingPool(const IOobject &ob)
|
||||
Foam::profilingPool::profilingPool(const IOobject &ob)
|
||||
:
|
||||
regIOobject(ob),
|
||||
globalTime_()
|
||||
|
@ -45,7 +45,7 @@ Foam::ProfilingPool::ProfilingPool(const IOobject &ob)
|
|||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingPool::~ProfilingPool()
|
||||
Foam::profilingPool::~profilingPool()
|
||||
{
|
||||
for(mapIterator it=map().begin();it!=map().end();++it) {
|
||||
delete it->second;
|
||||
|
@ -56,32 +56,32 @@ Foam::ProfilingPool::~ProfilingPool()
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ProfilingPool::initProfiling(const IOobject &ob)
|
||||
void Foam::profilingPool::initprofiling(const IOobject &ob)
|
||||
{
|
||||
if(thePool_!=NULL) {
|
||||
WarningIn("Foam::ProfilingPool::initProfiling(const IOobject &)")
|
||||
WarningIn("Foam::profilingPool::initprofiling(const IOobject &)")
|
||||
<< "Singleton already initialized\n" << endl;
|
||||
} else {
|
||||
thePool_=new ProfilingPool(ob);
|
||||
ProfilingInfo *master=new ProfilingInfo();
|
||||
thePool_=new profilingPool(ob);
|
||||
profilingInfo *master=new profilingInfo();
|
||||
thePool_->map().insert(make_pair(master->description(),master));
|
||||
thePool_->stack().push(*master);
|
||||
ProfilingPool::rememberTimer(*master,thePool_->globalTime_);
|
||||
profilingPool::rememberTimer(*master,thePool_->globalTime_);
|
||||
}
|
||||
}
|
||||
|
||||
Foam::ProfilingInfo &Foam::ProfilingPool::getInfo(const string &name)
|
||||
Foam::profilingInfo &Foam::profilingPool::getInfo(const string &name)
|
||||
{
|
||||
if(thePool_==NULL) {
|
||||
FatalErrorIn("Foam::ProfilingPool::addInfo(const string &name)")
|
||||
FatalErrorIn("Foam::profilingPool::addInfo(const string &name)")
|
||||
<< "Sinleton not initialized\n" << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
ProfilingStack &stack=thePool_->stack();
|
||||
profilingStack &stack=thePool_->stack();
|
||||
mapType &map=thePool_->map();
|
||||
|
||||
ProfilingInfo *found=NULL;
|
||||
profilingInfo *found=NULL;
|
||||
|
||||
for(mapIterator it=map.lower_bound(name);it!=map.upper_bound(name);++it) {
|
||||
if(it->second->parent().id()==stack.top().id()) {
|
||||
|
@ -91,7 +91,7 @@ Foam::ProfilingInfo &Foam::ProfilingPool::getInfo(const string &name)
|
|||
}
|
||||
|
||||
if(found==NULL) {
|
||||
found=new ProfilingInfo(stack.top(),name);
|
||||
found=new profilingInfo(stack.top(),name);
|
||||
|
||||
map.insert(make_pair(name,found));
|
||||
}
|
||||
|
@ -100,10 +100,10 @@ Foam::ProfilingInfo &Foam::ProfilingPool::getInfo(const string &name)
|
|||
return *found;
|
||||
}
|
||||
|
||||
void Foam::ProfilingPool::rememberTimer(const ProfilingInfo &info,clockTime &timer)
|
||||
void Foam::profilingPool::rememberTimer(const profilingInfo &info,clockTime &timer)
|
||||
{
|
||||
if(thePool_==NULL) {
|
||||
FatalErrorIn("Foam::ProfilingPool::rememberTimer(const ProfilingInfo &info,clockTime &timer)")
|
||||
FatalErrorIn("Foam::profilingPool::rememberTimer(const profilingInfo &info,clockTime &timer)")
|
||||
<< "Singleton not initialized\n" << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
@ -111,18 +111,18 @@ void Foam::ProfilingPool::rememberTimer(const ProfilingInfo &info,clockTime &tim
|
|||
thePool_->stack().addTimer(info,timer);
|
||||
}
|
||||
|
||||
void Foam::ProfilingPool::remove(const ProfilingInfo &info)
|
||||
void Foam::profilingPool::remove(const profilingInfo &info)
|
||||
{
|
||||
if(thePool_==NULL) {
|
||||
FatalErrorIn("Foam::ProfilingPool::addInfo(const string &name)")
|
||||
FatalErrorIn("Foam::profilingPool::addInfo(const string &name)")
|
||||
<< "Singleton not initialized\n" << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
ProfilingStack &stack=thePool_->stack();
|
||||
profilingStack &stack=thePool_->stack();
|
||||
|
||||
if(info.id()!=stack.top().id()) {
|
||||
FatalErrorIn("Foam::ProfilingPool::update(const string &name)")
|
||||
FatalErrorIn("Foam::profilingPool::update(const string &name)")
|
||||
<< "The id " << info.id() << " of the updated info " << info.description()
|
||||
<< " is no the same as the one on top of the stack: "
|
||||
<< stack.top().id() << " (" << stack.top().description() << ")\n" << endl
|
||||
|
@ -132,7 +132,7 @@ void Foam::ProfilingPool::remove(const ProfilingInfo &info)
|
|||
stack.pop();
|
||||
}
|
||||
|
||||
bool Foam::ProfilingPool::writeData(Ostream &os) const
|
||||
bool Foam::profilingPool::writeData(Ostream &os) const
|
||||
{
|
||||
os << "profilingInfo" << nl << indent << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
|
@ -23,26 +23,26 @@ License
|
|||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::ProfilingPool
|
||||
Foam::profilingPool
|
||||
|
||||
Description
|
||||
Collects all the data for Profiling
|
||||
Collects all the data for profiling
|
||||
|
||||
SourceFiles
|
||||
ProfilingPool.C
|
||||
profilingPool.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ProfilingPool_H
|
||||
#define ProfilingPool_H
|
||||
#ifndef profilingPool_H
|
||||
#define profilingPool_H
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "clockTime.H"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "ProfilingInfo.H"
|
||||
#include "ProfilingStack.H"
|
||||
#include "profilingInfo.H"
|
||||
#include "profilingStack.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -54,50 +54,50 @@ namespace Foam
|
|||
class Ostream;
|
||||
|
||||
// // Forward declaration of friend functions and operators
|
||||
// Istream& operator>>(Istream&, ProfilingPool&);
|
||||
// Ostream& operator<<(Ostream&, const ProfilingPool&);
|
||||
// Istream& operator>>(Istream&, profilingPool&);
|
||||
// Ostream& operator<<(Ostream&, const profilingPool&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ProfilingPool Declaration
|
||||
Class profilingPool Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ProfilingPool
|
||||
class profilingPool
|
||||
:
|
||||
public regIOobject
|
||||
{
|
||||
// Private data
|
||||
|
||||
typedef std::multimap<Foam::string,Foam::ProfilingInfo*> mapType;
|
||||
typedef std::pair<Foam::string,Foam::ProfilingInfo*> mapValues;
|
||||
typedef std::multimap<Foam::string,Foam::profilingInfo*> mapType;
|
||||
typedef std::pair<Foam::string,Foam::profilingInfo*> mapValues;
|
||||
typedef mapType::iterator mapIterator;
|
||||
typedef mapType::const_iterator mapConstIterator;
|
||||
|
||||
mapType allInfo_;
|
||||
|
||||
ProfilingStack theStack_;
|
||||
profilingStack theStack_;
|
||||
|
||||
clockTime globalTime_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ProfilingPool(const ProfilingPool&);
|
||||
profilingPool(const profilingPool&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ProfilingPool&);
|
||||
void operator=(const profilingPool&);
|
||||
|
||||
// Static data members
|
||||
|
||||
//- the only possible Pool-Object
|
||||
static ProfilingPool *thePool_;
|
||||
static profilingPool *thePool_;
|
||||
|
||||
//- Construct null
|
||||
ProfilingPool(const IOobject &);
|
||||
profilingPool(const IOobject &);
|
||||
|
||||
// Destructor
|
||||
|
||||
~ProfilingPool();
|
||||
~profilingPool();
|
||||
|
||||
mapType &map()
|
||||
{ return allInfo_; }
|
||||
|
@ -105,21 +105,21 @@ class ProfilingPool
|
|||
const mapType &map() const
|
||||
{ return allInfo_; }
|
||||
|
||||
ProfilingStack &stack()
|
||||
profilingStack &stack()
|
||||
{ return theStack_; }
|
||||
|
||||
const ProfilingStack &stack() const
|
||||
const profilingStack &stack() const
|
||||
{ return theStack_; }
|
||||
|
||||
public:
|
||||
|
||||
static void initProfiling(const IOobject &);
|
||||
static void initprofiling(const IOobject &);
|
||||
|
||||
static ProfilingInfo &getInfo(const string &name);
|
||||
static profilingInfo &getInfo(const string &name);
|
||||
|
||||
static void remove(const ProfilingInfo &info);
|
||||
static void remove(const profilingInfo &info);
|
||||
|
||||
static void rememberTimer(const ProfilingInfo &info,clockTime &timer);
|
||||
static void rememberTimer(const profilingInfo &info,clockTime &timer);
|
||||
|
||||
virtual bool writeData(Ostream &) const;
|
||||
};
|
|
@ -24,56 +24,56 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ProfilingStack.H"
|
||||
#include "ProfilingInfo.H"
|
||||
#include "profilingStack.H"
|
||||
#include "profilingInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingStack::ProfilingStack()
|
||||
Foam::profilingStack::profilingStack()
|
||||
:
|
||||
LIFOStack<ProfilingInfo*>()
|
||||
LIFOStack<profilingInfo*>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingStack::~ProfilingStack()
|
||||
Foam::profilingStack::~profilingStack()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingInfo &Foam::ProfilingStack::top() const
|
||||
Foam::profilingInfo &Foam::profilingStack::top() const
|
||||
{
|
||||
return *LIFOStack<ProfilingInfo*>::top();
|
||||
return *LIFOStack<profilingInfo*>::top();
|
||||
}
|
||||
|
||||
Foam::ProfilingInfo &Foam::ProfilingStack::bottom() const
|
||||
Foam::profilingInfo &Foam::profilingStack::bottom() const
|
||||
{
|
||||
return *LIFOStack<ProfilingInfo*>::bottom();
|
||||
return *LIFOStack<profilingInfo*>::bottom();
|
||||
}
|
||||
|
||||
bool Foam::ProfilingStack::empty() const
|
||||
bool Foam::profilingStack::empty() const
|
||||
{
|
||||
return LIFOStack<ProfilingInfo*>::empty();
|
||||
return LIFOStack<profilingInfo*>::empty();
|
||||
}
|
||||
|
||||
void Foam::ProfilingStack::push(ProfilingInfo &a)
|
||||
void Foam::profilingStack::push(profilingInfo &a)
|
||||
{
|
||||
LIFOStack<ProfilingInfo*>::push(&a);
|
||||
LIFOStack<profilingInfo*>::push(&a);
|
||||
top().addedToStack();
|
||||
}
|
||||
|
||||
Foam::ProfilingInfo &Foam::ProfilingStack::pop()
|
||||
Foam::profilingInfo &Foam::profilingStack::pop()
|
||||
{
|
||||
top().removedFromStack();
|
||||
return *LIFOStack<ProfilingInfo*>::pop();
|
||||
return *LIFOStack<profilingInfo*>::pop();
|
||||
}
|
||||
|
||||
void Foam::ProfilingStack::writeStackContents(Ostream &os) const
|
||||
void Foam::profilingStack::writeStackContents(Ostream &os) const
|
||||
{
|
||||
if(empty()) {
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ void Foam::ProfilingStack::writeStackContents(Ostream &os) const
|
|||
const_iterator it=begin();
|
||||
scalar oldElapsed=0;
|
||||
do {
|
||||
const ProfilingInfo &info=*(*it);
|
||||
const profilingInfo &info=*(*it);
|
||||
scalar elapsed=timers_[info.id()]->elapsedTime();
|
||||
|
||||
info.writeWithOffset(os,true,elapsed,oldElapsed);
|
||||
|
@ -91,7 +91,7 @@ void Foam::ProfilingStack::writeStackContents(Ostream &os) const
|
|||
} while(it!=end());
|
||||
}
|
||||
|
||||
void Foam::ProfilingStack::addTimer(const ProfilingInfo &info,clockTime &timer)
|
||||
void Foam::profilingStack::addTimer(const profilingInfo &info,clockTime &timer)
|
||||
{
|
||||
timers_.insert(info.id(),&timer);
|
||||
}
|
|
@ -23,18 +23,18 @@ License
|
|||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::ProfilingStack
|
||||
Foam::profilingStack
|
||||
|
||||
Description
|
||||
Stack of the ProfilingInfo-items that are currently used
|
||||
Stack of the profilingInfo-items that are currently used
|
||||
|
||||
SourceFiles
|
||||
ProfilingStack.C
|
||||
profilingStack.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ProfilingStack_H
|
||||
#define ProfilingStack_H
|
||||
#ifndef profilingStack_H
|
||||
#define profilingStack_H
|
||||
|
||||
#include "LIFOStack.H"
|
||||
#include "clockTime.H"
|
||||
|
@ -45,57 +45,57 @@ namespace Foam
|
|||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class ProfilingInfo;
|
||||
class ProfilingPool;
|
||||
class profilingInfo;
|
||||
class profilingPool;
|
||||
class Ostream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ProfilingStack Declaration
|
||||
Class profilingStack Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ProfilingStack
|
||||
class profilingStack
|
||||
:
|
||||
private LIFOStack<ProfilingInfo *>
|
||||
private LIFOStack<profilingInfo *>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ProfilingStack(const ProfilingStack&);
|
||||
profilingStack(const profilingStack&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ProfilingStack&);
|
||||
void operator=(const profilingStack&);
|
||||
|
||||
//- remember the timers for the correct stack-output
|
||||
HashTable<clockTime *,label> timers_;
|
||||
protected:
|
||||
void writeStackContents(Ostream &) const;
|
||||
|
||||
void addTimer(const ProfilingInfo &info,clockTime &timer);
|
||||
void addTimer(const profilingInfo &info,clockTime &timer);
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
ProfilingStack();
|
||||
profilingStack();
|
||||
|
||||
// Destructor
|
||||
|
||||
~ProfilingStack();
|
||||
~profilingStack();
|
||||
|
||||
|
||||
// Members that encapsulate the original stack-class
|
||||
ProfilingInfo &top() const;
|
||||
profilingInfo &top() const;
|
||||
|
||||
ProfilingInfo &bottom() const;
|
||||
profilingInfo &bottom() const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
void push(ProfilingInfo &);
|
||||
void push(profilingInfo &);
|
||||
|
||||
ProfilingInfo &pop();
|
||||
profilingInfo &pop();
|
||||
|
||||
friend class ProfilingPool;
|
||||
friend class profilingPool;
|
||||
};
|
||||
|
||||
|
|
@ -24,28 +24,28 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ProfilingTrigger.H"
|
||||
#include "profilingTrigger.H"
|
||||
|
||||
#include "ProfilingPool.H"
|
||||
#include "profilingPool.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingTrigger::ProfilingTrigger(const string &name)
|
||||
Foam::profilingTrigger::profilingTrigger(const string &name)
|
||||
:
|
||||
clock_(),
|
||||
info_(ProfilingPool::getInfo(name)),
|
||||
info_(profilingPool::getInfo(name)),
|
||||
running_(true)
|
||||
{
|
||||
ProfilingPool::rememberTimer(info(),clock());
|
||||
profilingPool::rememberTimer(info(),clock());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ProfilingTrigger::~ProfilingTrigger()
|
||||
Foam::profilingTrigger::~profilingTrigger()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ Foam::ProfilingTrigger::~ProfilingTrigger()
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ProfilingTrigger::stop()
|
||||
void Foam::profilingTrigger::stop()
|
||||
{
|
||||
if(running_) {
|
||||
scalar elapsed=clock_.elapsedTime();
|
||||
info_.update(elapsed);
|
||||
ProfilingPool::remove(info_);
|
||||
profilingPool::remove(info_);
|
||||
running_=false;
|
||||
}
|
||||
}
|
|
@ -23,18 +23,18 @@ License
|
|||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::ProfilingTrigger
|
||||
Foam::profilingTrigger
|
||||
|
||||
Description
|
||||
The object that does the actual measuring
|
||||
|
||||
SourceFiles
|
||||
ProfilingTrigger.C
|
||||
profilingTrigger.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ProfilingTrigger_H
|
||||
#define ProfilingTrigger_H
|
||||
#ifndef profilingTrigger_H
|
||||
#define profilingTrigger_H
|
||||
|
||||
#include "clockTime.H"
|
||||
#include "string.H"
|
||||
|
@ -44,50 +44,50 @@ SourceFiles
|
|||
namespace Foam
|
||||
{
|
||||
|
||||
class ProfilingInfo;
|
||||
class ProfilingPool;
|
||||
class profilingInfo;
|
||||
class profilingPool;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ProfilingTrigger Declaration
|
||||
Class profilingTrigger Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ProfilingTrigger
|
||||
class profilingTrigger
|
||||
{
|
||||
// Private data
|
||||
|
||||
clockTime clock_;
|
||||
|
||||
ProfilingInfo &info_;
|
||||
profilingInfo &info_;
|
||||
|
||||
bool running_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ProfilingTrigger(const ProfilingTrigger&);
|
||||
profilingTrigger(const profilingTrigger&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ProfilingTrigger&);
|
||||
void operator=(const profilingTrigger&);
|
||||
|
||||
protected:
|
||||
|
||||
clockTime &clock()
|
||||
{ return clock_; }
|
||||
|
||||
const ProfilingInfo &info() const
|
||||
const profilingInfo &info() const
|
||||
{ return info_; }
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
ProfilingTrigger(const string &name);
|
||||
profilingTrigger(const string &name);
|
||||
|
||||
~ProfilingTrigger();
|
||||
~profilingTrigger();
|
||||
|
||||
void stop();
|
||||
|
||||
friend class ProfilingPool;
|
||||
friend class profilingPool;
|
||||
};
|
||||
|
||||
|
|
@ -67,6 +67,9 @@ void Foam::BlockLduMatrix<Type>::AmulCore
|
|||
const TypeCoeffField& Diag = this->diag();
|
||||
const TypeCoeffField& Upper = this->upper();
|
||||
|
||||
// Create multiplication function object
|
||||
typename BlockCoeff<Type>::multiply mult;
|
||||
|
||||
// Diagonal multiplication, no indirection
|
||||
multiply(Ax, Diag, x);
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ SourceFiles
|
|||
#include "typeInfo.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
#include "ProfilingTrigger.H"
|
||||
#include "profilingTrigger.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -276,7 +275,7 @@ public:
|
|||
const lduInterfaceFieldPtrsList& interfaces_;
|
||||
|
||||
|
||||
ProfilingTrigger profile_;
|
||||
profilingTrigger profile_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ License
|
|||
|
||||
#include "smoothSolver.H"
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -90,7 +90,7 @@ Foam::lduSolverPerformance Foam::smoothSolver::solve
|
|||
// If the nSweeps_ is negative do a fixed number of sweeps
|
||||
if (nSweeps_ < 0)
|
||||
{
|
||||
ProfilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
|
||||
profilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
|
||||
|
||||
autoPtr<lduMatrix::smoother> smootherPtr = lduMatrix::smoother::New
|
||||
(
|
||||
|
@ -139,7 +139,7 @@ Foam::lduSolverPerformance Foam::smoothSolver::solve
|
|||
// Check convergence, solve if not converged
|
||||
if (!stop(solverPerf))
|
||||
{
|
||||
ProfilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
|
||||
profilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
|
||||
|
||||
autoPtr<lduMatrix::smoother> smootherPtr =
|
||||
lduMatrix::smoother::New
|
||||
|
|
|
@ -24,7 +24,7 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -58,7 +58,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
|
|||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
ProfilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
|
||||
profilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ License
|
|||
#include "fvScalarMatrix.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -143,7 +143,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
|
|||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
ProfilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
|
||||
profilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ License
|
|||
|
||||
#include "fvCFD.H"
|
||||
|
||||
#include "ProfilingTrigger.H"
|
||||
#include "profilingTrigger.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -50,7 +50,7 @@ void Foam::MULES::explicitSolve
|
|||
const scalar psiMin
|
||||
)
|
||||
{
|
||||
ProfilingTrigger trigger("MULES::explicitSolve");
|
||||
profilingTrigger trigger("MULES::explicitSolve");
|
||||
explicitSolve
|
||||
(
|
||||
geometricOneField(),
|
||||
|
@ -72,7 +72,7 @@ void Foam::MULES::implicitSolve
|
|||
const scalar psiMin
|
||||
)
|
||||
{
|
||||
ProfilingTrigger trigger("MULES::implicitSolve");
|
||||
profilingTrigger trigger("MULES::implicitSolve");
|
||||
implicitSolve
|
||||
(
|
||||
geometricOneField(),
|
||||
|
|
|
@ -32,7 +32,7 @@ License
|
|||
#include "Time.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include "Profiling.H"
|
||||
#include "profiling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -30,5 +30,7 @@ $(amg)/coarseAmgLevel.C
|
|||
amgPolicy = $(amg)/amgPolicy
|
||||
$(amgPolicy)/amgPolicy.C
|
||||
$(amgPolicy)/pamgPolicy.C
|
||||
$(amgPolicy)/aamgPolicy.C
|
||||
$(amgPolicy)/samgPolicy.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/liblduSolvers
|
||||
|
|
Reference in a new issue