faudes::ParallelExecutor Class Reference
[Simulator PlugIn]

Synchronized parallel execution of TimedGenerators. More...

#include <sp_pexecutor.h>

List of all members.

Classes

class  ParallelTimedState
 Typedef for parallel timed state, incl token io. More...

Public Types

typedef std::vector< IdxParallelState
 Typedef for parallel discrete state.
typedef std::vector< std::map
< Idx, tpTime::Type > > 
ParallelClock
 Typedef for parallel clock values.
typedef Executor::TimedState TimedState
 Provide typedef from Executor.
typedef std::vector< Executor >
::const_iterator 
Iterator
 Read-only access to individual executors.

Public Member Functions

 ParallelExecutor (void)
 Construct an emtpy ParallelExecuter.
 ParallelExecutor (const ParallelExecutor &rOther)
 Copy constructor.
 ParallelExecutor (const std::string &rFileName)
 Construct from file.
virtual ~ParallelExecutor (void)
 Explicit destructor.
virtual void Clear (void)
 Clear all data.
Idx Size (void) const
 Number of TimedGenerators.
void Insert (const std::string &rFileName)
 Add a TimedGenerator from file.
void Insert (const TimedGenerator &rGen)
 Add a TimedGenerator.
const EventSetAlphabet (void) const
 Overall alphabet.
virtual void Reset (void)
 Goto initial state.
Iterator Begin (void) const
Iterator End (void) const
const ExecutorAt (int i) const
Idx EventIndex (const std::string &rName) const
 Event index lookup.
std::string EventName (Idx index) const
 Event name lookup.
tpTime::Type CurrentTime (void) const
 Get clock time.
int CurrentStep (void) const
 Get logical time, ie number of transitions so far,.
bool IsDeadlocked () const
 Test for deadlocked.
virtual bool Valid (void) const
 Check validity of executors.
const ParallelTimedStateCurrentParallelTimedState (void) const
 Get current state of the ParallelExecutor.
const ParallelStateCurrentParallelState (void) const
 Get current discrete state vector of the ParallelExecutor.
virtual void CurrentTime (tpTime::Type time)
 Set clock time.
virtual void CurrentStep (int step)
 Set logical time (# of steps).
virtual bool CurrentParallelTimedState (const ParallelTimedState &ptstate)
 Set current state of the ParallelExecutor.
virtual bool ExecuteTime (tpTime::Type duration)
 Let time pass without executing a transition.
virtual bool ExecuteEvent (Idx event)
 Execute transition.
const TimeIntervalEnabledTime () const
 Get maximal duration that can pass without executing an event.
const EventSetEnabledEvents () const
 Get events that are enabled at current (timed) state.
const EventSetDisabledEvents () const
 Get events that are disabled at current (timed) state.
const TimeIntervalEnabledInterval () const
 Get an interval on which the set of enabled events is constant.
TimeInterval EnabledEventTime (Idx event) const
 Get interval on which the specified event is enabled.
TimeInterval EnabledGuardTime (Idx event) const
 Get interval on which the respective guard is satisfied.
EventSet ActiveEventSet (const ParallelState &stateVec) const
 Get events that are active in all TimedGenerators.
bool Active (Idx ev, const ParallelState &stateVec) const
 Test whether an event is active in a given discrete state.
bool Active (Idx ev) const
 Test whether an event is active at current (discrete) state.
std::string PTSStr (const ParallelTimedState &ptstate) const
 Pretty printable string of timed parallel state.
std::string PSStr (const ParallelState &pstate) const
 Pretty printable string of parallel state.
std::string TEStr (const TimedEvent &tevent) const
 Pretty printable string of timed event.
std::string CStr (Idx clock) const
 Pretty printable string of clock name.
std::string EStr (Idx event) const
 Pretty printable string of event.
std::string CurrentParallelTimedStateStr (void) const
 Pretty printable string of current state.
std::string CurrentParallelStateStr (void) const
 Pretty printable string of parallel state.
void ComputeEnabled (void) const
 Compute enabled events and enabled interval (fake const).
void ComputeEnabledNonConst (void)
 Compute enabled core routine (non const).

Protected Member Functions

virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads parallel executor from TokenReader, see also public wrappers Read() in faudes::Type.
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see also public wrappers Write() in faudes::Type.
virtual void DoReadGenerators (TokenReader &rTr)
 Write to TokenWriter, see also public wrappers XWrite() in faudes::Type.
virtual void DoWriteGenerators (TokenWriter &rTw) const
 Write generator files section to TokenWriter.
virtual void DoAssign (const ParallelExecutor &rSrc)
 Assignment method.
virtual void Compile ()
 compile internal data (eg overall alphabet)

Protected Attributes

Idx mRecentEvent
 recent event

Private Types

typedef std::vector< Executor >
::iterator 
iterator
 Internal non-const iterator.

Private Member Functions

void UpdateParallelTimedState (void)
 update parallel timed state()

Private Attributes

std::vector< ExecutormExecutors
 list of executors
std::vector< std::string > mExecutorNames
 list of executors
EventSet mAlphabet
 overall alphabet
tpTime::Type mCurrentTime
 global time (real)
int mCurrentStep
 global time (step)
TimeInterval mETime
 enabled time
EventSet mEEvents
 enabled events
EventSet mDEvents
 disabled events
TimeInterval mEInterval
 enabled interval
bool mEValid
 validity flag for fevents and ftime
ParallelTimedState mCurrentParallelTimedState
 current state

Detailed Description

Synchronized parallel execution of TimedGenerators.

Synchronisation

The ParallelExecutor executes a family of timed generators with synchronized shared events according to Alur semantics. That is, we assume disjoint clock sets and synchronize shared events w.r.t. occurence at clock time.

Implementation

The external interface of a ParallelExecutor is the same as the single Executor, in that it indicats enabled events and in that it provides methods for executing events or letting time pass.

Technically, a ParallelExecutor is a vector of executors. Clocks are treated on a per executor basis. That is, values of clocks in one generator are not effected by the reset of another generator, even if the respestive clock variables have the same index and name.

File IO

For token IO, the ParallelExecutor reads and writes the generators to execute within a section with default label "Executor". For disk space efficiency, the token IO format will use refernces by (relative) filename if the latter is known. Since TimedGenerators read any generator type from file, so does the ParallelExecutor. Example:

 <Executor>
 <Generators>
 "./some_generator.gen"
 "./other_generator.gen"
 </Generators>
 </Executor>

Definition at line 64 of file sp_pexecutor.h.


Member Typedef Documentation

typedef std::vector<Executor>::iterator faudes::ParallelExecutor::iterator [private]

Internal non-const iterator.

Definition at line 580 of file sp_pexecutor.h.

typedef std::vector<Executor>::const_iterator faudes::ParallelExecutor::Iterator

Read-only access to individual executors.

Definition at line 180 of file sp_pexecutor.h.

typedef std::vector< std::map<Idx,tpTime::Type> > faudes::ParallelExecutor::ParallelClock

Typedef for parallel clock values.

Definition at line 73 of file sp_pexecutor.h.

Typedef for parallel discrete state.

Definition at line 70 of file sp_pexecutor.h.

Provide typedef from Executor.

Definition at line 86 of file sp_pexecutor.h.


Constructor & Destructor Documentation

faudes::ParallelExecutor::ParallelExecutor ( void   ) 

Construct an emtpy ParallelExecuter.

Definition at line 22 of file sp_pexecutor.cpp.

faudes::ParallelExecutor::ParallelExecutor ( const ParallelExecutor rOther  ) 

Copy constructor.

Definition at line 27 of file sp_pexecutor.cpp.

faudes::ParallelExecutor::ParallelExecutor ( const std::string &  rFileName  ) 

Construct from file.

This constructor uses the DoRead method to initialize from file.

Parameters:
rFileName Filename
Exceptions:
Exception 
  • non-deteministic generator (id 501)
  • token mismatch (id 502)
  • IO errors (id 1)

Definition at line 33 of file sp_pexecutor.cpp.

faudes::ParallelExecutor::~ParallelExecutor ( void   )  [virtual]

Explicit destructor.

Definition at line 39 of file sp_pexecutor.cpp.


Member Function Documentation

bool faudes::ParallelExecutor::Active ( Idx  ev  )  const

Test whether an event is active at current (discrete) state.

By "active" we refer to the untimed transition structure, that is, we ignore clock values etc.

Parameters:
ev Event ro test
Returns:
True for active in all generators

Definition at line 532 of file sp_pexecutor.cpp.

bool faudes::ParallelExecutor::Active ( Idx  ev,
const ParallelState stateVec 
) const

Test whether an event is active in a given discrete state.

By "active" we refer to the untimed transition structure, that is, we ignore clock values etc.

Parameters:
ev Event to test
stateVec ParallelState
Returns:
True for active in all generators

Definition at line 537 of file sp_pexecutor.cpp.

EventSet faudes::ParallelExecutor::ActiveEventSet ( const ParallelState stateVec  )  const

Get events that are active in all TimedGenerators.

By "active" we refer to the untimed transition structure, that is, we ignore clock values etc.

Parameters:
stateVec Discrete state
Returns:
Active EventSet

Definition at line 521 of file sp_pexecutor.cpp.

const EventSet & faudes::ParallelExecutor::Alphabet ( void   )  const

Overall alphabet.

Reimplemented in faudes::ProposingExecutor.

Definition at line 229 of file sp_pexecutor.cpp.

const Executor& faudes::ParallelExecutor::At ( int  i  )  const [inline]

Definition at line 183 of file sp_pexecutor.h.

Iterator faudes::ParallelExecutor::Begin ( void   )  const [inline]

Definition at line 181 of file sp_pexecutor.h.

void faudes::ParallelExecutor::Clear ( void   )  [virtual]

Clear all data.

Removes all generators/executors and resets the current state to a void value.

Reimplemented from faudes::Type.

Reimplemented in faudes::DeviceExecutor, faudes::LoggingExecutor, and faudes::ProposingExecutor.

Definition at line 115 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::Compile ( void   )  [protected, virtual]

compile internal data (eg overall alphabet)

Reimplemented in faudes::LoggingExecutor.

Definition at line 62 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::ComputeEnabled ( void   )  const

Compute enabled events and enabled interval (fake const).

this is public only for performance experiments --- dont use

Definition at line 234 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::ComputeEnabledNonConst ( void   ) 

Compute enabled core routine (non const).

Definition at line 240 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::CStr ( Idx  clock  )  const

Pretty printable string of clock name.

Definition at line 505 of file sp_pexecutor.cpp.

const ParallelExecutor::ParallelState & faudes::ParallelExecutor::CurrentParallelState ( void   )  const

Get current discrete state vector of the ParallelExecutor.

By "the current discrete state" we refer to a vector of indices that indicate the current state of the untimed transition structure.

Returns:
Discrete state vector

Definition at line 319 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::CurrentParallelStateStr ( void   )  const

Pretty printable string of parallel state.

Definition at line 516 of file sp_pexecutor.cpp.

bool faudes::ParallelExecutor::CurrentParallelTimedState ( const ParallelTimedState ptstate  )  [virtual]

Set current state of the ParallelExecutor.

This resets the parallel executor to the given state, incl clock values. Both, clock time and logical time is also reset (to 0).

Returns:
True for success

Reimplemented in faudes::LoggingExecutor.

Definition at line 329 of file sp_pexecutor.cpp.

const ParallelExecutor::ParallelTimedState & faudes::ParallelExecutor::CurrentParallelTimedState ( void   )  const

Get current state of the ParallelExecutor.

With "the current state" w refer to all data relevant for events generated in future. This data consists of a discrete state vector and a mapping from clocks to closk values.

Returns:
Discrete state vector and clock value maps

Reimplemented in faudes::LoggingExecutor.

Definition at line 324 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::CurrentParallelTimedStateStr ( void   )  const

Pretty printable string of current state.

Definition at line 511 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::CurrentStep ( int  step  )  [virtual]

Set logical time (# of steps).

This does not affect clocks and, hence, is purely cosmetic. Note that, in contrast to clock time, the individual generators do not agree in logical time. The trace buffer will get out of order and should be cleared.

Parameters:
step New logical time

Reimplemented in faudes::LoggingExecutor.

Definition at line 432 of file sp_pexecutor.cpp.

int faudes::ParallelExecutor::CurrentStep ( void   )  const

Get logical time, ie number of transitions so far,.

Reimplemented in faudes::LoggingExecutor.

Definition at line 440 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::CurrentTime ( tpTime::Type  time  )  [virtual]

Set clock time.

This does not affect clocks and, hence, is purely cosmetic. The trace buffer will record an invalid event.

Parameters:
time New clock time

Reimplemented in faudes::LoggingExecutor.

Definition at line 419 of file sp_pexecutor.cpp.

tpTime::Type faudes::ParallelExecutor::CurrentTime ( void   )  const

Get clock time.

Reimplemented in faudes::LoggingExecutor.

Definition at line 427 of file sp_pexecutor.cpp.

const EventSet & faudes::ParallelExecutor::DisabledEvents ( void   )  const

Get events that are disabled at current (timed) state.

By "disabled" we refer to the synchronizes timed generators, that is, we do care about clock values, invariants and guards.

Returns:
Set of disabled events

Definition at line 283 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::DoAssign ( const ParallelExecutor rSrc  )  [protected, virtual]

Assignment method.

Parameters:
rSrc Source to assign from

Definition at line 44 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
) [protected, virtual]

Reads parallel executor from TokenReader, see also public wrappers Read() in faudes::Type.

Parameters:
rTr TokenReader to read from
rLabel Section to read, defaults to "Executor"
pContext Read context to provide contextual information (ignored)
Exceptions:
Exception 
  • non-deterministic generator(s) (id 501)
  • token mismatch (id 502)
  • IO error (id 1)

Reimplemented from faudes::Type.

Reimplemented in faudes::LoggingExecutor, and faudes::ProposingExecutor.

Definition at line 175 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::DoReadGenerators ( TokenReader rTr  )  [protected, virtual]

Write to TokenWriter, see also public wrappers XWrite() in faudes::Type.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to "Executor"
pContext Write context to provide contextual information (ignored)
Exceptions:
Exception 
  • IO errors (id 2) Reads generator files section from TokenReader
Parameters:
rTr TokenReader to read from
Exceptions:
Exception 
  • non-deterministic generator(s) (id 501)
  • token mismatch (id 502)
  • IO error (id 1)

Definition at line 194 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [protected, virtual]

Write to TokenWriter, see also public wrappers Write() in faudes::Type.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to "Executor"
pContext Write context to provide contextual information (ignored)
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::Type.

Reimplemented in faudes::LoggingExecutor, and faudes::ProposingExecutor.

Definition at line 130 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::DoWriteGenerators ( TokenWriter rTw  )  const [protected, virtual]

Write generator files section to TokenWriter.

Parameters:
rTw Reference to TokenWriter
Exceptions:
Exception 
  • IO errors (id 2)

Definition at line 159 of file sp_pexecutor.cpp.

const EventSet & faudes::ParallelExecutor::EnabledEvents ( void   )  const

Get events that are enabled at current (timed) state.

By "enabled" we refer to the synchronizes timed generators, that is, we do care about clock values, invariants and guards.

Returns:
Set of enabled events

Definition at line 277 of file sp_pexecutor.cpp.

TimeInterval faudes::ParallelExecutor::EnabledEventTime ( Idx  event  )  const

Get interval on which the specified event is enabled.

Returns empty, if the event is not active or never simultanuosly enabled in all executors.

Parameters:
event 
Returns:
TimeInterval

Definition at line 295 of file sp_pexecutor.cpp.

TimeInterval faudes::ParallelExecutor::EnabledGuardTime ( Idx  event  )  const

Get interval on which the respective guard is satisfied.

Returns empty, if the event is not active or if the guards are never simultanuosly satisfied in all executors.

Parameters:
event 
Returns:
TimeInterval

Definition at line 307 of file sp_pexecutor.cpp.

const TimeInterval & faudes::ParallelExecutor::EnabledInterval ( void   )  const

Get an interval on which the set of enabled events is constant.

Note: while this implementation tries to come up with a potentially large interval, it is not guaranteed to be maximal.

Returns:
TimeInterval

Definition at line 289 of file sp_pexecutor.cpp.

const TimeInterval & faudes::ParallelExecutor::EnabledTime ( void   )  const

Get maximal duration that can pass without executing an event.

Returns:
TimeInterval

Definition at line 270 of file sp_pexecutor.cpp.

Iterator faudes::ParallelExecutor::End ( void   )  const [inline]

Definition at line 182 of file sp_pexecutor.h.

std::string faudes::ParallelExecutor::EStr ( Idx  event  )  const

Pretty printable string of event.

Definition at line 499 of file sp_pexecutor.cpp.

Idx faudes::ParallelExecutor::EventIndex ( const std::string &  rName  )  const [inline]

Event index lookup.

This convenience method refers to the global event symbol table.

Parameters:
rName Name of event to lookup
Returns:
Valid index or 0 if non-existent

Definition at line 197 of file sp_pexecutor.h.

std::string faudes::ParallelExecutor::EventName ( Idx  index  )  const [inline]

Event name lookup.

This convenience method refers to the global event symbol table.

Parameters:
index Index of event to look up
Returns:
Name or empty std::string if non-existent

Definition at line 210 of file sp_pexecutor.h.

bool faudes::ParallelExecutor::ExecuteEvent ( Idx  event  )  [virtual]

Execute transition.

Returns false if the transition cannot be executed at the current time.

Parameters:
event Indicate transition to execute
Returns:
True on success

Reimplemented in faudes::DeviceExecutor, faudes::LoggingExecutor, and faudes::ProposingExecutor.

Definition at line 389 of file sp_pexecutor.cpp.

bool faudes::ParallelExecutor::ExecuteTime ( tpTime::Type  duration  )  [virtual]

Let time pass without executing a transition.

Return false if the duration specified cannot elapse without an event being executed.

Parameters:
duration Amount of time that shall elapse.
Returns:
True for success

Reimplemented in faudes::LoggingExecutor, and faudes::ProposingExecutor.

Definition at line 364 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::Insert ( const TimedGenerator rGen  ) 

Add a TimedGenerator.

After inserting generators and before starting to execute, you must call Reset() to update internal datastructures.

Parameters:
rGen Generator to add
Exceptions:
Exception 
  • non-deteministic generator (id 501)

Definition at line 106 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::Insert ( const std::string &  rFileName  ) 

Add a TimedGenerator from file.

This method uses the TimedGenerator's read to find the first generator in the file. If the generator found is not a TimedGenerator, timing data defaults to infinite invariants/guards and empty resets. After inserting generators and before starting to execute, you must call Reset() to update internal datastructures.

Parameters:
rFileName File to read
Exceptions:
Exception 
  • non-deteministic generator (id 501)
  • token mismatch (id 502)
  • IO errors (id 1)

Definition at line 91 of file sp_pexecutor.cpp.

bool faudes::ParallelExecutor::IsDeadlocked ( void   )  const

Test for deadlocked.

The parallel executor is deadlocked if neither time can pass nor an event can be executed. Prototypical examples for such a situation is that the indvidual executers fail to agree on a common time interval, at which shaered events are enabled.

Returns:
True/false

Definition at line 445 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::PSStr ( const ParallelState pstate  )  const

Pretty printable string of parallel state.

Definition at line 480 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::PTSStr ( const ParallelTimedState ptstate  )  const

Pretty printable string of timed parallel state.

Definition at line 453 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::Reset ( void   )  [virtual]

Goto initial state.

Reset all clock values to zero, assign initial states to each executor.

Reimplemented in faudes::LoggingExecutor.

Definition at line 84 of file sp_pexecutor.cpp.

Idx faudes::ParallelExecutor::Size ( void   )  const

Number of TimedGenerators.

Definition at line 123 of file sp_pexecutor.cpp.

std::string faudes::ParallelExecutor::TEStr ( const TimedEvent tevent  )  const

Pretty printable string of timed event.

Definition at line 493 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::UpdateParallelTimedState ( void   )  [private]

update parallel timed state()

Definition at line 52 of file sp_pexecutor.cpp.

virtual bool faudes::ParallelExecutor::Valid ( void   )  const [inline, virtual]

Check validity of executors.

This is currently not implemented.

Returns:
True on success

Reimplemented in faudes::LoggingExecutor.

Definition at line 244 of file sp_pexecutor.h.


Member Data Documentation

overall alphabet

Definition at line 583 of file sp_pexecutor.h.

global time (step)

Definition at line 589 of file sp_pexecutor.h.

global time (real)

Definition at line 586 of file sp_pexecutor.h.

disabled events

Definition at line 598 of file sp_pexecutor.h.

enabled events

Definition at line 595 of file sp_pexecutor.h.

enabled interval

Definition at line 601 of file sp_pexecutor.h.

enabled time

Definition at line 592 of file sp_pexecutor.h.

validity flag for fevents and ftime

Definition at line 604 of file sp_pexecutor.h.

std::vector<std::string> faudes::ParallelExecutor::mExecutorNames [private]

list of executors

Definition at line 577 of file sp_pexecutor.h.

list of executors

Definition at line 574 of file sp_pexecutor.h.

recent event

Definition at line 569 of file sp_pexecutor.h.


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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen