Profiling update, Bernhard Gscheider

This commit is contained in:
Hrvoje Jasak 2013-08-26 12:00:13 +01:00
parent a47a1b5577
commit 244849fac2
21 changed files with 186 additions and 175 deletions

View file

@ -3,10 +3,10 @@ global/dimensionedConstants/dimensionedConstants.C
global/argList/argList.C global/argList/argList.C
global/clock/clock.C global/clock/clock.C
global/Profiling/ProfilingInfo.C global/profiling/profilingInfo.C
global/Profiling/ProfilingPool.C global/profiling/profilingPool.C
global/Profiling/ProfilingStack.C global/profiling/profilingStack.C
global/Profiling/ProfilingTrigger.C global/profiling/profilingTrigger.C
bools = primitives/bools bools = primitives/bools
$(bools)/bool/bool.C $(bools)/bool/bool.C

View file

@ -27,8 +27,8 @@ License
#include "Time.H" #include "Time.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
#include "ProfilingPool.H" #include "profilingPool.H"
#include "Profiling.H" #include "profiling.H"
#include <sstream> #include <sstream>
@ -242,8 +242,10 @@ Foam::Time::Time
{ {
setControls(); setControls();
ProfilingPool::initProfiling( profilingPool::initprofiling
IOobject( (
IOobject
(
"profilingInfo", "profilingInfo",
timeName(), timeName(),
"uniform", "uniform",
@ -310,8 +312,10 @@ Foam::Time::Time
{ {
setControls(); setControls();
ProfilingPool::initProfiling( profilingPool::initprofiling
IOobject( (
IOobject
(
"profilingInfo", "profilingInfo",
timeName(), timeName(),
"uniform", "uniform",
@ -374,8 +378,10 @@ Foam::Time::Time
readLibs_(controlDict_, "libs"), readLibs_(controlDict_, "libs"),
functionObjects_(*this, enableFunctionObjects) functionObjects_(*this, enableFunctionObjects)
{ {
ProfilingPool::initProfiling( profilingPool::initprofiling
IOobject( (
IOobject
(
"profilingInfo", "profilingInfo",
timeName(), timeName(),
"uniform", "uniform",

View file

@ -27,7 +27,7 @@ License
#include "Time.H" #include "Time.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View file

@ -27,7 +27,7 @@ License
#include "functionObjectList.H" #include "functionObjectList.H"
#include "Time.H" #include "Time.H"
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //

View file

@ -25,7 +25,7 @@ License
Class Class
Description Description
Add everything necessary for Profiling plus a macro Add everything necessary for profiling plus a macro
Originally proposed in Originally proposed in
http://www.cfd-online.com/Forums/openfoam-bugs/64081-feature-proposal-application-level-profiling.html http://www.cfd-online.com/Forums/openfoam-bugs/64081-feature-proposal-application-level-profiling.html
@ -34,17 +34,17 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef Profiling_H #ifndef profiling_H
#define Profiling_H #define profiling_H
#include "ProfilingTrigger.H" #include "profilingTrigger.H"
// to be used at the beginning of a section to be profiled // to be used at the beginning of a section to be profiled
// profiling ends automatically at the end of a block // 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 // 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 // this is only needed if profiling should end before the end of a block
#define endProfile(name) profileTriggerFor##name.stop() #define endProfile(name) profileTriggerFor##name.stop()

View file

@ -24,21 +24,21 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ProfilingInfo.H" #include "profilingInfo.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * 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_++; nextId_++;
return nextId_; return nextId_;
} }
void Foam::ProfilingInfo::raiseID(label maxVal) void Foam::profilingInfo::raiseID(label maxVal)
{ {
if(maxVal>nextId_) { if(maxVal>nextId_) {
nextId_=maxVal; nextId_=maxVal;
@ -50,7 +50,7 @@ void Foam::ProfilingInfo::raiseID(label maxVal)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ProfilingInfo::ProfilingInfo() Foam::profilingInfo::profilingInfo()
: :
calls_(0), calls_(0),
totalTime_(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), calls_(0),
totalTime_(0.), totalTime_(0.),
@ -75,13 +75,13 @@ Foam::ProfilingInfo::ProfilingInfo(ProfilingInfo &parent,const string &descr)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ProfilingInfo::~ProfilingInfo() Foam::profilingInfo::~profilingInfo()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ProfilingInfo::update(scalar elapsedTimee) void Foam::profilingInfo::update(scalar elapsedTimee)
{ {
calls_++; calls_++;
totalTime_+=elapsedTimee; 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; dictionary tmp;
@ -112,7 +112,7 @@ void Foam::ProfilingInfo::writeWithOffset(Ostream &os,bool offset,scalar time,sc
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const ProfilingInfo& info) Foam::Ostream& Foam::operator<<(Ostream& os, const profilingInfo& info)
{ {
info.writeWithOffset(os); info.writeWithOffset(os);

View file

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::ProfilingInfo Foam::profilingInfo
Description Description
Information needed for profiling Information needed for profiling
SourceFiles SourceFiles
ProfilingInfo.C profilingInfo.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ProfilingInfo_H #ifndef profilingInfo_H
#define ProfilingInfo_H #define profilingInfo_H
#include "label.H" #include "label.H"
#include "scalar.H" #include "scalar.H"
@ -45,19 +45,20 @@ namespace Foam
{ {
// Forward declaration of classes // 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 // Private data
@ -74,7 +75,7 @@ class ProfilingInfo
label id_; label id_;
// pointer to the parent object (if there is any) // pointer to the parent object (if there is any)
ProfilingInfo &parent_; profilingInfo &parent_;
// what this does // what this does
string description_; string description_;
@ -85,10 +86,10 @@ class ProfilingInfo
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ProfilingInfo(const ProfilingInfo&); profilingInfo(const profilingInfo&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ProfilingInfo&); void operator=(const profilingInfo&);
// Static data members // Static data members
@ -110,7 +111,7 @@ protected:
{ onStack_=false; } { onStack_=false; }
//- Construct null - only the master-element //- Construct null - only the master-element
ProfilingInfo(); profilingInfo();
void writeWithOffset(Ostream &os,bool offset=false,scalar time=0,scalar childTime=0) const; void writeWithOffset(Ostream &os,bool offset=false,scalar time=0,scalar childTime=0) const;
@ -119,14 +120,14 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
ProfilingInfo(ProfilingInfo &parent,const string &descr); profilingInfo(profilingInfo &parent,const string &descr);
// //- Construct from Istream // //- Construct from Istream
// ProfilingInfo(Istream&); // profilingInfo(Istream&);
// Destructor // Destructor
~ProfilingInfo(); ~profilingInfo();
// Member Functions // Member Functions
@ -151,19 +152,19 @@ public:
const string &description() const const string &description() const
{ return description_; } { return description_; }
const ProfilingInfo &parent() const const profilingInfo &parent() const
{ return parent_; } { return parent_; }
//- Update it with a new timing information //- Update it with a new timing information
void update(scalar elapsedTime); void update(scalar elapsedTime);
friend class ProfilingStack; friend class profilingStack;
friend class ProfilingPool; friend class profilingPool;
// IOstream Operators // IOstream Operators
// friend Istream& operator>>(Istream&, ProfilingInfo&); // friend Istream& operator>>(Istream&, profilingInfo&);
friend Ostream& operator<<(Ostream&, const ProfilingInfo&); friend Ostream& operator<<(Ostream&, const profilingInfo&);
}; };

View file

@ -24,18 +24,18 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ProfilingPool.H" #include "profilingPool.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::ProfilingPool* Foam::ProfilingPool::thePool_(NULL); Foam::profilingPool* Foam::profilingPool::thePool_(NULL);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ProfilingPool::ProfilingPool(const IOobject &ob) Foam::profilingPool::profilingPool(const IOobject &ob)
: :
regIOobject(ob), regIOobject(ob),
globalTime_() globalTime_()
@ -45,7 +45,7 @@ Foam::ProfilingPool::ProfilingPool(const IOobject &ob)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ProfilingPool::~ProfilingPool() Foam::profilingPool::~profilingPool()
{ {
for(mapIterator it=map().begin();it!=map().end();++it) { for(mapIterator it=map().begin();it!=map().end();++it) {
delete it->second; delete it->second;
@ -56,32 +56,32 @@ Foam::ProfilingPool::~ProfilingPool()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ProfilingPool::initProfiling(const IOobject &ob) void Foam::profilingPool::initprofiling(const IOobject &ob)
{ {
if(thePool_!=NULL) { if(thePool_!=NULL) {
WarningIn("Foam::ProfilingPool::initProfiling(const IOobject &)") WarningIn("Foam::profilingPool::initprofiling(const IOobject &)")
<< "Singleton already initialized\n" << endl; << "Singleton already initialized\n" << endl;
} else { } else {
thePool_=new ProfilingPool(ob); thePool_=new profilingPool(ob);
ProfilingInfo *master=new ProfilingInfo(); profilingInfo *master=new profilingInfo();
thePool_->map().insert(make_pair(master->description(),master)); thePool_->map().insert(make_pair(master->description(),master));
thePool_->stack().push(*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) { if(thePool_==NULL) {
FatalErrorIn("Foam::ProfilingPool::addInfo(const string &name)") FatalErrorIn("Foam::profilingPool::addInfo(const string &name)")
<< "Sinleton not initialized\n" << endl << "Sinleton not initialized\n" << endl
<< abort(FatalError); << abort(FatalError);
} }
ProfilingStack &stack=thePool_->stack(); profilingStack &stack=thePool_->stack();
mapType &map=thePool_->map(); mapType &map=thePool_->map();
ProfilingInfo *found=NULL; profilingInfo *found=NULL;
for(mapIterator it=map.lower_bound(name);it!=map.upper_bound(name);++it) { for(mapIterator it=map.lower_bound(name);it!=map.upper_bound(name);++it) {
if(it->second->parent().id()==stack.top().id()) { if(it->second->parent().id()==stack.top().id()) {
@ -91,7 +91,7 @@ Foam::ProfilingInfo &Foam::ProfilingPool::getInfo(const string &name)
} }
if(found==NULL) { if(found==NULL) {
found=new ProfilingInfo(stack.top(),name); found=new profilingInfo(stack.top(),name);
map.insert(make_pair(name,found)); map.insert(make_pair(name,found));
} }
@ -100,10 +100,10 @@ Foam::ProfilingInfo &Foam::ProfilingPool::getInfo(const string &name)
return *found; return *found;
} }
void Foam::ProfilingPool::rememberTimer(const ProfilingInfo &info,clockTime &timer) void Foam::profilingPool::rememberTimer(const profilingInfo &info,clockTime &timer)
{ {
if(thePool_==NULL) { 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 << "Singleton not initialized\n" << endl
<< abort(FatalError); << abort(FatalError);
} }
@ -111,18 +111,18 @@ void Foam::ProfilingPool::rememberTimer(const ProfilingInfo &info,clockTime &tim
thePool_->stack().addTimer(info,timer); thePool_->stack().addTimer(info,timer);
} }
void Foam::ProfilingPool::remove(const ProfilingInfo &info) void Foam::profilingPool::remove(const profilingInfo &info)
{ {
if(thePool_==NULL) { if(thePool_==NULL) {
FatalErrorIn("Foam::ProfilingPool::addInfo(const string &name)") FatalErrorIn("Foam::profilingPool::addInfo(const string &name)")
<< "Singleton not initialized\n" << endl << "Singleton not initialized\n" << endl
<< abort(FatalError); << abort(FatalError);
} }
ProfilingStack &stack=thePool_->stack(); profilingStack &stack=thePool_->stack();
if(info.id()!=stack.top().id()) { 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() << "The id " << info.id() << " of the updated info " << info.description()
<< " is no the same as the one on top of the stack: " << " is no the same as the one on top of the stack: "
<< stack.top().id() << " (" << stack.top().description() << ")\n" << endl << stack.top().id() << " (" << stack.top().description() << ")\n" << endl
@ -132,7 +132,7 @@ void Foam::ProfilingPool::remove(const ProfilingInfo &info)
stack.pop(); 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; os << "profilingInfo" << nl << indent << token::BEGIN_LIST << incrIndent << nl;

View file

@ -23,26 +23,26 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::ProfilingPool Foam::profilingPool
Description Description
Collects all the data for Profiling Collects all the data for profiling
SourceFiles SourceFiles
ProfilingPool.C profilingPool.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ProfilingPool_H #ifndef profilingPool_H
#define ProfilingPool_H #define profilingPool_H
#include "regIOobject.H" #include "regIOobject.H"
#include "clockTime.H" #include "clockTime.H"
#include <map> #include <map>
#include "ProfilingInfo.H" #include "profilingInfo.H"
#include "ProfilingStack.H" #include "profilingStack.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,50 +54,50 @@ namespace Foam
class Ostream; class Ostream;
// // Forward declaration of friend functions and operators // // Forward declaration of friend functions and operators
// Istream& operator>>(Istream&, ProfilingPool&); // Istream& operator>>(Istream&, profilingPool&);
// Ostream& operator<<(Ostream&, const ProfilingPool&); // Ostream& operator<<(Ostream&, const profilingPool&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ProfilingPool Declaration Class profilingPool Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class ProfilingPool class profilingPool
: :
public regIOobject public regIOobject
{ {
// Private data // Private data
typedef std::multimap<Foam::string,Foam::ProfilingInfo*> mapType; typedef std::multimap<Foam::string,Foam::profilingInfo*> mapType;
typedef std::pair<Foam::string,Foam::ProfilingInfo*> mapValues; typedef std::pair<Foam::string,Foam::profilingInfo*> mapValues;
typedef mapType::iterator mapIterator; typedef mapType::iterator mapIterator;
typedef mapType::const_iterator mapConstIterator; typedef mapType::const_iterator mapConstIterator;
mapType allInfo_; mapType allInfo_;
ProfilingStack theStack_; profilingStack theStack_;
clockTime globalTime_; clockTime globalTime_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ProfilingPool(const ProfilingPool&); profilingPool(const profilingPool&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ProfilingPool&); void operator=(const profilingPool&);
// Static data members // Static data members
//- the only possible Pool-Object //- the only possible Pool-Object
static ProfilingPool *thePool_; static profilingPool *thePool_;
//- Construct null //- Construct null
ProfilingPool(const IOobject &); profilingPool(const IOobject &);
// Destructor // Destructor
~ProfilingPool(); ~profilingPool();
mapType &map() mapType &map()
{ return allInfo_; } { return allInfo_; }
@ -105,21 +105,21 @@ class ProfilingPool
const mapType &map() const const mapType &map() const
{ return allInfo_; } { return allInfo_; }
ProfilingStack &stack() profilingStack &stack()
{ return theStack_; } { return theStack_; }
const ProfilingStack &stack() const const profilingStack &stack() const
{ return theStack_; } { return theStack_; }
public: 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; virtual bool writeData(Ostream &) const;
}; };

View file

@ -24,56 +24,56 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ProfilingStack.H" #include "profilingStack.H"
#include "ProfilingInfo.H" #include "profilingInfo.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ProfilingStack::ProfilingStack() Foam::profilingStack::profilingStack()
: :
LIFOStack<ProfilingInfo*>() LIFOStack<profilingInfo*>()
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ProfilingStack::~ProfilingStack() Foam::profilingStack::~profilingStack()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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(); top().addedToStack();
} }
Foam::ProfilingInfo &Foam::ProfilingStack::pop() Foam::profilingInfo &Foam::profilingStack::pop()
{ {
top().removedFromStack(); 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()) { if(empty()) {
return; return;
@ -81,7 +81,7 @@ void Foam::ProfilingStack::writeStackContents(Ostream &os) const
const_iterator it=begin(); const_iterator it=begin();
scalar oldElapsed=0; scalar oldElapsed=0;
do { do {
const ProfilingInfo &info=*(*it); const profilingInfo &info=*(*it);
scalar elapsed=timers_[info.id()]->elapsedTime(); scalar elapsed=timers_[info.id()]->elapsedTime();
info.writeWithOffset(os,true,elapsed,oldElapsed); info.writeWithOffset(os,true,elapsed,oldElapsed);
@ -91,7 +91,7 @@ void Foam::ProfilingStack::writeStackContents(Ostream &os) const
} while(it!=end()); } 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); timers_.insert(info.id(),&timer);
} }

View file

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::ProfilingStack Foam::profilingStack
Description Description
Stack of the ProfilingInfo-items that are currently used Stack of the profilingInfo-items that are currently used
SourceFiles SourceFiles
ProfilingStack.C profilingStack.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ProfilingStack_H #ifndef profilingStack_H
#define ProfilingStack_H #define profilingStack_H
#include "LIFOStack.H" #include "LIFOStack.H"
#include "clockTime.H" #include "clockTime.H"
@ -45,57 +45,57 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class ProfilingInfo; class profilingInfo;
class ProfilingPool; class profilingPool;
class Ostream; class Ostream;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ProfilingStack Declaration Class profilingStack Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class ProfilingStack class profilingStack
: :
private LIFOStack<ProfilingInfo *> private LIFOStack<profilingInfo *>
{ {
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ProfilingStack(const ProfilingStack&); profilingStack(const profilingStack&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ProfilingStack&); void operator=(const profilingStack&);
//- remember the timers for the correct stack-output //- remember the timers for the correct stack-output
HashTable<clockTime *,label> timers_; HashTable<clockTime *,label> timers_;
protected: protected:
void writeStackContents(Ostream &) const; void writeStackContents(Ostream &) const;
void addTimer(const ProfilingInfo &info,clockTime &timer); void addTimer(const profilingInfo &info,clockTime &timer);
public: public:
// Constructors // Constructors
//- Construct null //- Construct null
ProfilingStack(); profilingStack();
// Destructor // Destructor
~ProfilingStack(); ~profilingStack();
// Members that encapsulate the original stack-class // Members that encapsulate the original stack-class
ProfilingInfo &top() const; profilingInfo &top() const;
ProfilingInfo &bottom() const; profilingInfo &bottom() const;
bool empty() const; bool empty() const;
void push(ProfilingInfo &); void push(profilingInfo &);
ProfilingInfo &pop(); profilingInfo &pop();
friend class ProfilingPool; friend class profilingPool;
}; };

View file

@ -24,28 +24,28 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ProfilingTrigger.H" #include "profilingTrigger.H"
#include "ProfilingPool.H" #include "profilingPool.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ProfilingTrigger::ProfilingTrigger(const string &name) Foam::profilingTrigger::profilingTrigger(const string &name)
: :
clock_(), clock_(),
info_(ProfilingPool::getInfo(name)), info_(profilingPool::getInfo(name)),
running_(true) running_(true)
{ {
ProfilingPool::rememberTimer(info(),clock()); profilingPool::rememberTimer(info(),clock());
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ProfilingTrigger::~ProfilingTrigger() Foam::profilingTrigger::~profilingTrigger()
{ {
stop(); stop();
} }
@ -53,12 +53,12 @@ Foam::ProfilingTrigger::~ProfilingTrigger()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ProfilingTrigger::stop() void Foam::profilingTrigger::stop()
{ {
if(running_) { if(running_) {
scalar elapsed=clock_.elapsedTime(); scalar elapsed=clock_.elapsedTime();
info_.update(elapsed); info_.update(elapsed);
ProfilingPool::remove(info_); profilingPool::remove(info_);
running_=false; running_=false;
} }
} }

View file

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::ProfilingTrigger Foam::profilingTrigger
Description Description
The object that does the actual measuring The object that does the actual measuring
SourceFiles SourceFiles
ProfilingTrigger.C profilingTrigger.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ProfilingTrigger_H #ifndef profilingTrigger_H
#define ProfilingTrigger_H #define profilingTrigger_H
#include "clockTime.H" #include "clockTime.H"
#include "string.H" #include "string.H"
@ -44,50 +44,50 @@ SourceFiles
namespace Foam namespace Foam
{ {
class ProfilingInfo; class profilingInfo;
class ProfilingPool; class profilingPool;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ProfilingTrigger Declaration Class profilingTrigger Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class ProfilingTrigger class profilingTrigger
{ {
// Private data // Private data
clockTime clock_; clockTime clock_;
ProfilingInfo &info_; profilingInfo &info_;
bool running_; bool running_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ProfilingTrigger(const ProfilingTrigger&); profilingTrigger(const profilingTrigger&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ProfilingTrigger&); void operator=(const profilingTrigger&);
protected: protected:
clockTime &clock() clockTime &clock()
{ return clock_; } { return clock_; }
const ProfilingInfo &info() const const profilingInfo &info() const
{ return info_; } { return info_; }
public: public:
// Constructors // Constructors
ProfilingTrigger(const string &name); profilingTrigger(const string &name);
~ProfilingTrigger(); ~profilingTrigger();
void stop(); void stop();
friend class ProfilingPool; friend class profilingPool;
}; };

View file

@ -67,6 +67,9 @@ void Foam::BlockLduMatrix<Type>::AmulCore
const TypeCoeffField& Diag = this->diag(); const TypeCoeffField& Diag = this->diag();
const TypeCoeffField& Upper = this->upper(); const TypeCoeffField& Upper = this->upper();
// Create multiplication function object
typename BlockCoeff<Type>::multiply mult;
// Diagonal multiplication, no indirection // Diagonal multiplication, no indirection
multiply(Ax, Diag, x); multiply(Ax, Diag, x);

View file

@ -60,8 +60,7 @@ SourceFiles
#include "typeInfo.H" #include "typeInfo.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "profilingTrigger.H"
#include "ProfilingTrigger.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -276,7 +275,7 @@ public:
const lduInterfaceFieldPtrsList& interfaces_; const lduInterfaceFieldPtrsList& interfaces_;
ProfilingTrigger profile_; profilingTrigger profile_;
// Protected Member Functions // Protected Member Functions

View file

@ -26,7 +26,7 @@ License
#include "smoothSolver.H" #include "smoothSolver.H"
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -90,7 +90,7 @@ Foam::lduSolverPerformance Foam::smoothSolver::solve
// If the nSweeps_ is negative do a fixed number of sweeps // If the nSweeps_ is negative do a fixed number of sweeps
if (nSweeps_ < 0) if (nSweeps_ < 0)
{ {
ProfilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName()); profilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
autoPtr<lduMatrix::smoother> smootherPtr = lduMatrix::smoother::New autoPtr<lduMatrix::smoother> smootherPtr = lduMatrix::smoother::New
( (
@ -139,7 +139,7 @@ Foam::lduSolverPerformance Foam::smoothSolver::solve
// Check convergence, solve if not converged // Check convergence, solve if not converged
if (!stop(solverPerf)) if (!stop(solverPerf))
{ {
ProfilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName()); profilingTrigger smoothProfile("lduMatrix::smoother_"+fieldName());
autoPtr<lduMatrix::smoother> smootherPtr = autoPtr<lduMatrix::smoother> smootherPtr =
lduMatrix::smoother::New lduMatrix::smoother::New

View file

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
const dictionary& solverControls const dictionary& solverControls
) )
{ {
ProfilingTrigger profSolve("fvMatrix::solve_"+psi_.name()); profilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
if (debug) if (debug)
{ {

View file

@ -27,7 +27,7 @@ License
#include "fvScalarMatrix.H" #include "fvScalarMatrix.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -143,7 +143,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
const dictionary& solverControls const dictionary& solverControls
) )
{ {
ProfilingTrigger profSolve("fvMatrix::solve_"+psi_.name()); profilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
if (debug) if (debug)
{ {

View file

@ -37,7 +37,7 @@ License
#include "fvCFD.H" #include "fvCFD.H"
#include "ProfilingTrigger.H" #include "profilingTrigger.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,7 +50,7 @@ void Foam::MULES::explicitSolve
const scalar psiMin const scalar psiMin
) )
{ {
ProfilingTrigger trigger("MULES::explicitSolve"); profilingTrigger trigger("MULES::explicitSolve");
explicitSolve explicitSolve
( (
geometricOneField(), geometricOneField(),
@ -72,7 +72,7 @@ void Foam::MULES::implicitSolve
const scalar psiMin const scalar psiMin
) )
{ {
ProfilingTrigger trigger("MULES::implicitSolve"); profilingTrigger trigger("MULES::implicitSolve");
implicitSolve implicitSolve
( (
geometricOneField(), geometricOneField(),

View file

@ -32,7 +32,7 @@ License
#include "Time.H" #include "Time.H"
#include "OFstream.H" #include "OFstream.H"
#include "Profiling.H" #include "profiling.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View file

@ -30,5 +30,7 @@ $(amg)/coarseAmgLevel.C
amgPolicy = $(amg)/amgPolicy amgPolicy = $(amg)/amgPolicy
$(amgPolicy)/amgPolicy.C $(amgPolicy)/amgPolicy.C
$(amgPolicy)/pamgPolicy.C $(amgPolicy)/pamgPolicy.C
$(amgPolicy)/aamgPolicy.C
$(amgPolicy)/samgPolicy.C
LIB = $(FOAM_LIBBIN)/liblduSolvers LIB = $(FOAM_LIBBIN)/liblduSolvers