PlasCom2  1.0
XPACC Multi-physics simluation application
GlobalObj< StackType, ErrorType, ProfilerType > Class Template Reference

Base global object. More...

Detailed Description

template<typename StackType, typename ErrorType, typename ProfilerType>
class ix::global::GlobalObj< StackType, ErrorType, ProfilerType >

Base global object.

Provides an interface for tracking errors, profiling, and user defined stack information. The idea is that this object or a derived object will be available to every rank local method.

Definition at line 25 of file Global.H.

#include <Global.H>

Public Member Functions

 GlobalObj ()
 Default constructor. Profiling is OFF by default. More...
 
 GlobalObj (int narg, char **args)
 Default constructor. More...
 
 GlobalObj (GlobalObj< StackType, ErrorType, ProfilerType > &globin)
 Constructor with args. More...
 
 GlobalObj (const StackType &name)
 Constructor with args. More...
 
 GlobalObj (const StackType &name, int id)
 Constructor with args. More...
 
virtual int Init (const StackType &name)
 Initializes the global object and it's profiler object /// Initializes the global object and it's profiler object Profiling is ON by default if Init is invoked. More...
 
virtual int Init (const StackType &name, unsigned int id)
 Initializes the global object and it's profiler object Profiling is ON by default if Init is invoked. More...
 
virtual int Finalize ()
 Finalizes the global object, and it's profiler object. More...
 
virtual bool WriteProfiles ()
 Get state of enablement for writing profile files. More...
 
virtual bool WriteProfiles (bool yn)
 Enable or disable profile file writing. More...
 
virtual bool Profiling ()
 Get profiling state. More...
 
virtual bool Profiling (bool yn)
 Enable or disable profiling. More...
 
virtual void Report (std::ostream &ReportStream)
 Creates the final profiling report on the specified stream. More...
 
virtual void Register (const StackType &stackentry)
 Register will push to the Stack only. More...
 
virtual void DeRegister (const StackType &stackentry)
 DeRegister will pop from the stack only. More...
 
virtual void FunctionEntry (const StackType &stackentry)
 FunctionEntry updates the Stack as well as the Profiler. More...
 
virtual void FunctionExit (const StackType &stackentry)
 FunctionExit updates the Stack as well as the Profiler. More...
 
virtual void FunctionExitAll ()
 FunctionExitAll exits all from the Profiler only. More...
 
virtual void Error (const ErrorType &error)
 Pushes an error onto the error stack. More...
 
virtual void DumpErrors (std::ostream &Ostr)
 Dumps the errors themselves to the indicated stream. More...
 
virtual void DumpStack (std::ostream &Ostr)
 Dumps the code construct statck to the indicated stream. More...
 
virtual void DumpProfile (std::ostream &Ostr)
 Dumps the timing profile to the indicated stream. More...
 
bool DebugStreamReady ()
 Checks debug stream. More...
 
void SetDebugStream (std::ostream &dbstream)
 Sets the debug stream object. More...
 
std::ostream & DebugStream ()
 Gets the debug stream object. More...
 
std::ostream * DebugStreamPtr ()
 Gets the debug stream pointer. More...
 
bool ErrStreamReady ()
 Checks error stream. More...
 
void SetErrStream (std::ostream &dbstream)
 Sets the error stream object. More...
 
std::ostream & ErrStream ()
 Gets the error stream object. More...
 
std::ostream * ErrStreamPtr ()
 Gets the error stream pointer. More...
 
bool OutStreamReady ()
 Checks out stream. More...
 
void SetOutStream (std::ostream &outstream)
 Sets the stdout stream object. More...
 
std::ostream & OutStream ()
 Gets the stdout stream object. More...
 
std::ostream * OutStreamPtr ()
 Gets the stdout stream pointer. More...
 
void UnsetOutStream ()
 Sets outstream to NULL. More...
 
bool LogStreamReady ()
 Checks log stream. More...
 
void SetLogStream (std::ostream &logstream)
 Sets the stdout stream object. More...
 
std::ostream & LogStream ()
 Gets the log stream object. More...
 
std::ostream * LogStreamPtr ()
 Gets the log stream pointer. More...
 
void SetProfiler (ProfilerType &profiler)
 Sets the Profiler object. More...
 
virtual void SetName (const std::string &name)
 
virtual void ReName (const std::string &name)
 
virtual const std::string & Name ()
 
ProfilerTypeProfiler ()
 Gets the debug stream object. More...
 
void SetDebugLevel (unsigned char l)
 Sets the level of debugging. More...
 
unsigned char DebugLevel ()
 Returns the debugging level. More...
 
void SetVerbLevel (unsigned char l)
 
unsigned char VerbLevel ()
 Returns the verbosity level. More...
 
void SetLogLevel (unsigned char l)
 
unsigned char LogLevel ()
 Returns the verbosity level. More...
 
void DeSyncIO ()
 DeSync IO - relinquish control over IO, revert to standard. More...
 
void SyncIO ()
 Syncronize IO - assume control over IO, using established streams. More...
 
virtual int ForceOut (const std::string &outstr, unsigned char inlev=1)
 
virtual int StdOut (const std::string &outstr, unsigned char inlev=1)
 
virtual int ErrOut (const std::string &outstr)
 
virtual int DebugOut (const std::string &outstr, int inlev=1)
 
virtual int LogOut (const std::string &outstr, int inlev=0)
 
virtual ~GlobalObj ()
 Destructor. More...
 

Protected Attributes

std::ostream * _DebugStream
 DebugStream is useful for parallel programs that cannot stream debugging information to the screen. More...
 
std::ostream * _OutStream
 
std::ostream * _LogStream
 
std::ostream * _ErrStream
 
ProfilerType_Profiler
 This is a placeholder for a generic profiling tool. More...
 

Private Member Functions

std::string FName ()
 

Private Attributes

unsigned char _debug_level
 Debugging level. More...
 
unsigned char _log_level
 Logging level. More...
 
unsigned char _verb_level
 Verbosity level. More...
 
std::list< StackType > _Stack
 Stack provides a list for storing the user defined "stack". More...
 
std::list< ErrorType > _Errors
 Errors provides a list for storing caught execution errors for later processing. More...
 
bool _initd
 has been initialized? More...
 
bool _profiling_enabled
 
bool _profiler_mine
 
bool _write_profiles
 
std::string _name
 
std::ostream * _OutStreamSave
 
std::ostream * _ErrStreamSave
 
std::ostream * _DebugStreamSave
 
Inheritance diagram for GlobalObj< StackType, ErrorType, ProfilerType >:
Collaboration diagram for GlobalObj< StackType, ErrorType, ProfilerType >:

Constructor & Destructor Documentation

◆ GlobalObj() [1/5]

GlobalObj ( )
inline

Default constructor. Profiling is OFF by default.

Definition at line 68 of file Global.H.

◆ GlobalObj() [2/5]

GlobalObj ( int  narg,
char **  args 
)
inline

Default constructor.

If no args, then profiling is OFF by default.

Definition at line 82 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::Init(), and ix::util::stripdirs().

Here is the call graph for this function:

◆ GlobalObj() [3/5]

GlobalObj ( GlobalObj< StackType, ErrorType, ProfilerType > &  globin)
inline

Constructor with args.

If this constructor is used, Init is invoked which turns profiling ON by default.

Definition at line 98 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::_Stack.

◆ GlobalObj() [4/5]

GlobalObj ( const StackType &  name)
inline

Constructor with args.

If this constructor is used, Init is invoked which turns profiling ON by default.

Definition at line 119 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::Init().

Here is the call graph for this function:

◆ GlobalObj() [5/5]

GlobalObj ( const StackType &  name,
int  id 
)
inline

Constructor with args.

If this constructor is used, Init is invoked which turns profiling ON by default.

Definition at line 128 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::Init().

Here is the call graph for this function:

◆ ~GlobalObj()

virtual ~GlobalObj ( )
inlinevirtual

Destructor.

Definition at line 510 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::_Profiler, and GlobalObj< StackType, ErrorType, ProfilerType >::Finalize().

Here is the call graph for this function:

Member Function Documentation

◆ DebugLevel()

unsigned char DebugLevel ( )
inline

Returns the debugging level.

Definition at line 391 of file Global.H.

◆ DebugOut()

virtual int DebugOut ( const std::string &  outstr,
int  inlev = 1 
)
inlinevirtual

Definition at line 473 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::Name().

Here is the call graph for this function:

◆ DebugStream()

std::ostream& DebugStream ( )
inline

Gets the debug stream object.

Definition at line 320 of file Global.H.

◆ DebugStreamPtr()

std::ostream* DebugStreamPtr ( )
inline

Gets the debug stream pointer.

Definition at line 323 of file Global.H.

◆ DebugStreamReady()

bool DebugStreamReady ( )
inline

Checks debug stream.

Definition at line 312 of file Global.H.

◆ DeRegister()

virtual void DeRegister ( const StackType &  stackentry)
inlinevirtual

DeRegister will pop from the stack only.

Should be called upon exit of user defined code constructs where a previous call to Register was made upon entry.

Definition at line 260 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::FName().

Here is the call graph for this function:

◆ DeSyncIO()

void DeSyncIO ( )
inline

◆ DumpErrors()

virtual void DumpErrors ( std::ostream &  Ostr)
inlinevirtual

Dumps the errors themselves to the indicated stream.

Definition at line 296 of file Global.H.

References ix::util::DumpContents().

Referenced by program::Finalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpProfile()

virtual void DumpProfile ( std::ostream &  Ostr)
inlinevirtual

Dumps the timing profile to the indicated stream.

Definition at line 306 of file Global.H.

References ProfilerObj::Dump().

Here is the call graph for this function:

◆ DumpStack()

virtual void DumpStack ( std::ostream &  Ostr)
inlinevirtual

Dumps the code construct statck to the indicated stream.

Definition at line 301 of file Global.H.

References ix::util::DumpContents().

Here is the call graph for this function:

◆ Error()

virtual void Error ( const ErrorType &  error)
inlinevirtual

Pushes an error onto the error stack.

Definition at line 291 of file Global.H.

◆ ErrOut()

◆ ErrStream()

std::ostream& ErrStream ( )
inline

Gets the error stream object.

Definition at line 334 of file Global.H.

Referenced by program::Finalize(), and program::Initialize().

Here is the caller graph for this function:

◆ ErrStreamPtr()

std::ostream* ErrStreamPtr ( )
inline

Gets the error stream pointer.

Definition at line 337 of file Global.H.

◆ ErrStreamReady()

bool ErrStreamReady ( )
inline

Checks error stream.

Definition at line 326 of file Global.H.

◆ Finalize()

◆ FName()

◆ ForceOut()

virtual int ForceOut ( const std::string &  outstr,
unsigned char  inlev = 1 
)
inlinevirtual

Definition at line 422 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::Name().

Here is the call graph for this function:

◆ FunctionEntry()

virtual void FunctionEntry ( const StackType &  stackentry)
inlinevirtual

FunctionEntry updates the Stack as well as the Profiler.

Reimplemented in ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType >.

Definition at line 267 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::FName(), and ProfilerObj::FunctionEntry().

Referenced by ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType >::FunctionEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FunctionExit()

virtual void FunctionExit ( const StackType &  stackentry)
inlinevirtual

FunctionExit updates the Stack as well as the Profiler.

Reimplemented in ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType >.

Definition at line 276 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::FName(), and ProfilerObj::FunctionExit().

Referenced by ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType >::FunctionExit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FunctionExitAll()

virtual void FunctionExitAll ( )
inlinevirtual

FunctionExitAll exits all from the Profiler only.

Definition at line 285 of file Global.H.

References ProfilerObj::FunctionExitAll().

Here is the call graph for this function:

◆ Init() [1/2]

virtual int Init ( const StackType &  name)
inlinevirtual

Initializes the global object and it's profiler object /// Initializes the global object and it's profiler object Profiling is ON by default if Init is invoked.

Definition at line 136 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::_DebugStream, GlobalObj< StackType, ErrorType, ProfilerType >::_ErrStream, GlobalObj< StackType, ErrorType, ProfilerType >::_OutStream, GlobalObj< StackType, ErrorType, ProfilerType >::_Profiler, and ProfilerObj::Init().

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::GlobalObj(), and ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType >::ParallelGlobalObj().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init() [2/2]

virtual int Init ( const StackType &  name,
unsigned int  id 
)
inlinevirtual

Initializes the global object and it's profiler object Profiling is ON by default if Init is invoked.

Definition at line 168 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::_DebugStream, GlobalObj< StackType, ErrorType, ProfilerType >::_ErrStream, GlobalObj< StackType, ErrorType, ProfilerType >::_OutStream, GlobalObj< StackType, ErrorType, ProfilerType >::_Profiler, and ProfilerObj::Init().

Here is the call graph for this function:

◆ LogLevel()

unsigned char LogLevel ( )
inline

Returns the verbosity level.

Definition at line 401 of file Global.H.

◆ LogOut()

virtual int LogOut ( const std::string &  outstr,
int  inlev = 0 
)
inlinevirtual

Definition at line 490 of file Global.H.

References ix::sys::LogTime(), and GlobalObj< StackType, ErrorType, ProfilerType >::Name().

Here is the call graph for this function:

◆ LogStream()

std::ostream& LogStream ( )
inline

Gets the log stream object.

Definition at line 365 of file Global.H.

◆ LogStreamPtr()

std::ostream* LogStreamPtr ( )
inline

Gets the log stream pointer.

Definition at line 368 of file Global.H.

◆ LogStreamReady()

bool LogStreamReady ( )
inline

Checks log stream.

Definition at line 357 of file Global.H.

◆ Name()

◆ OutStream()

std::ostream& OutStream ( )
inline

Gets the stdout stream object.

Definition at line 348 of file Global.H.

Referenced by program::Finalize(), and ix::MyTestProgram().

Here is the caller graph for this function:

◆ OutStreamPtr()

std::ostream* OutStreamPtr ( )
inline

Gets the stdout stream pointer.

Definition at line 351 of file Global.H.

◆ OutStreamReady()

bool OutStreamReady ( )
inline

Checks out stream.

Definition at line 340 of file Global.H.

Referenced by program::Finalize().

Here is the caller graph for this function:

◆ Profiler()

ProfilerType& Profiler ( )
inline

Gets the debug stream object.

Definition at line 385 of file Global.H.

◆ Profiling() [1/2]

◆ Profiling() [2/2]

virtual bool Profiling ( bool  yn)
inlinevirtual

Enable or disable profiling.

Definition at line 234 of file Global.H.

◆ Register()

virtual void Register ( const StackType &  stackentry)
inlinevirtual

Register will push to the Stack only.

Can be called upon entry of user defined code constructs where profiling is not desired.

Definition at line 251 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::FName().

Here is the call graph for this function:

◆ ReName()

virtual void ReName ( const std::string &  name)
inlinevirtual

Definition at line 382 of file Global.H.

◆ Report()

virtual void Report ( std::ostream &  ReportStream)
inlinevirtual

Creates the final profiling report on the specified stream.

Definition at line 240 of file Global.H.

References ProfilerObj::Finalize(), and ProfilerObj::SummarizeSerialExecution().

Referenced by program::Finalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDebugLevel()

void SetDebugLevel ( unsigned char  l)
inline

Sets the level of debugging.

Definition at line 388 of file Global.H.

Referenced by program::Initialize().

Here is the caller graph for this function:

◆ SetDebugStream()

void SetDebugStream ( std::ostream &  dbstream)
inline

Sets the debug stream object.

Definition at line 315 of file Global.H.

Referenced by program::Initialize().

Here is the caller graph for this function:

◆ SetErrStream()

void SetErrStream ( std::ostream &  dbstream)
inline

Sets the error stream object.

Definition at line 329 of file Global.H.

◆ SetLogLevel()

void SetLogLevel ( unsigned char  l)
inline

Definition at line 398 of file Global.H.

◆ SetLogStream()

void SetLogStream ( std::ostream &  logstream)
inline

Sets the stdout stream object.

Definition at line 360 of file Global.H.

◆ SetName()

virtual void SetName ( const std::string &  name)
inlinevirtual

Definition at line 381 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::FName().

Here is the call graph for this function:

◆ SetOutStream()

void SetOutStream ( std::ostream &  outstream)
inline

Sets the stdout stream object.

Definition at line 343 of file Global.H.

◆ SetProfiler()

void SetProfiler ( ProfilerType profiler)
inline

Sets the Profiler object.

Definition at line 371 of file Global.H.

References GlobalObj< StackType, ErrorType, ProfilerType >::_Profiler, ProfilerObj::Finalize(), and ProfilerObj::FinalizeReady().

Here is the call graph for this function:

◆ SetVerbLevel()

◆ StdOut()

◆ SyncIO()

void SyncIO ( )
inline

◆ UnsetOutStream()

void UnsetOutStream ( )
inline

Sets outstream to NULL.

Definition at line 354 of file Global.H.

◆ VerbLevel()

unsigned char VerbLevel ( )
inline

Returns the verbosity level.

Definition at line 396 of file Global.H.

◆ WriteProfiles() [1/2]

virtual bool WriteProfiles ( )
inlinevirtual

Get state of enablement for writing profile files.

Definition at line 219 of file Global.H.

◆ WriteProfiles() [2/2]

virtual bool WriteProfiles ( bool  yn)
inlinevirtual

Enable or disable profile file writing.

Definition at line 224 of file Global.H.

Member Data Documentation

◆ _debug_level

unsigned char _debug_level
private

Debugging level.

Definition at line 29 of file Global.H.

◆ _DebugStream

std::ostream* _DebugStream
protected

DebugStream is useful for parallel programs that cannot stream debugging information to the screen.

Each rank can use this to stream debugging output to it's own file for separate analysis.

Definition at line 51 of file Global.H.

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::DeSyncIO(), and GlobalObj< StackType, ErrorType, ProfilerType >::Init().

◆ _DebugStreamSave

std::ostream* _DebugStreamSave
private

Definition at line 64 of file Global.H.

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::SyncIO().

◆ _Errors

std::list< ErrorType > _Errors
private

Errors provides a list for storing caught execution errors for later processing.

Definition at line 42 of file Global.H.

◆ _ErrStream

std::ostream* _ErrStream
protected

◆ _ErrStreamSave

std::ostream* _ErrStreamSave
private

Definition at line 63 of file Global.H.

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::SyncIO().

◆ _initd

bool _initd
private

has been initialized?

Definition at line 45 of file Global.H.

◆ _log_level

unsigned char _log_level
private

Logging level.

Definition at line 32 of file Global.H.

◆ _LogStream

std::ostream* _LogStream
protected

Definition at line 53 of file Global.H.

◆ _name

std::string _name
private

Definition at line 61 of file Global.H.

◆ _OutStream

std::ostream* _OutStream
protected

◆ _OutStreamSave

std::ostream* _OutStreamSave
private

Definition at line 62 of file Global.H.

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::SyncIO().

◆ _Profiler

◆ _profiler_mine

bool _profiler_mine
private

Definition at line 59 of file Global.H.

◆ _profiling_enabled

bool _profiling_enabled
private

Definition at line 58 of file Global.H.

◆ _Stack

std::list< StackType > _Stack
private

Stack provides a list for storing the user defined "stack".

It's not a real call stack, but a stack of user defined code constructs.

Definition at line 39 of file Global.H.

Referenced by GlobalObj< StackType, ErrorType, ProfilerType >::GlobalObj().

◆ _verb_level

unsigned char _verb_level
private

Verbosity level.

Definition at line 35 of file Global.H.

◆ _write_profiles

bool _write_profiles
private

Definition at line 60 of file Global.H.


The documentation for this class was generated from the following file: