libFAUDES

Sections

Index

faudes::ParallelExecutor Class Reference
[Simulator PlugIn]

#include <sp_pexecutor.h>

Inherits faudes::Type.

Inherited by faudes::LoggingExecutor.

List of all members.


Detailed Description

Synchronized parallel execution of tGenerators.

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 tGenerators read any generator type from file, so does the ParallelExecutor. Example:

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

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 std::string &rFileName)
 Construct from file.
virtual ~ParallelExecutor (void)
 Explicit destructor.
virtual void Clear (void)
 Clear all data.
Idx Size (void) const
 Number of tGenerators.
void Insert (const std::string &rFileName)
 Add a tGenerator from file.
void Insert (const tGenerator &rGen)
 Add a tGenerator.
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 tGenerators.
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)
 Reads generator files section from TokenReader.
virtual void DoWriteGenerators (TokenWriter &rTw) const
 Write generator files section to TokenWriter.
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

Classes

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

Member Typedef Documentation

Typedef for parallel discrete state.

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

Typedef for parallel clock values.

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

Read-only access to individual executors.

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

Internal non-const iterator.


Constructor & Destructor Documentation

faudes::ParallelExecutor::ParallelExecutor ( void   ) 

Construct an emtpy ParallelExecuter.

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)

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

Explicit destructor.


Member Function Documentation

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.

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

Number of tGenerators.

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

Add a tGenerator from file.

This method uses the tGenerator's read to find the first generator in the file. If the generator found is not a tGenerator, 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)

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

Add a tGenerator.

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)

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

Overall alphabet.

Reimplemented in faudes::ProposingExecutor.

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.

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

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

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

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

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

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

Get clock time.

Reimplemented in faudes::LoggingExecutor.

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

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

Reimplemented in faudes::LoggingExecutor.

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

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.

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.

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

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.

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.

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.

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.

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.

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

Get maximal duration that can pass without executing an event.

Returns:
TimeInterval

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

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

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

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

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

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

Get events that are active in all tGenerators.

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

Parameters:
stateVec Discrete state
Returns:
Active EventSet

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

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

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

Pretty printable string of timed parallel state.

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

Pretty printable string of parallel state.

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

Pretty printable string of timed event.

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

Pretty printable string of clock name.

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

Pretty printable string of event.

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

Pretty printable string of current state.

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

Pretty printable string of parallel state.

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

Compute enabled events and enabled interval (fake const).

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

void faudes::ParallelExecutor::ComputeEnabledNonConst ( void   ) 

Compute enabled core routine (non const).

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.

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.

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

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)

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)

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

compile internal data (eg overall alphabet)

Reimplemented in faudes::LoggingExecutor.

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

update parallel timed state()


Member Data Documentation

recent event

list of executors

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

list of executors

overall alphabet

global time (step)

enabled events

disabled events

validity flag for fevents and ftime


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

libFAUDES 2.13a c++ source docu by doxygen 1.5.6