faudes::ParallelExecutor Class Reference
[Simulator Plugin]

#include <sp_pexecutor.h>

Inheritance diagram for faudes::ParallelExecutor:

faudes::Type faudes::LoggingExecutor faudes::ProposingExecutor faudes::DeviceExecutor 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 physical 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> 

Definition at line 65 of file sp_pexecutor.h.

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 physical 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 physical 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
 this is public only for performance experiments --- dont use
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 std::vector<Executor>::iterator faudes::ParallelExecutor::iterator [private]
 

Internal non-const iterator.

Definition at line 551 of file sp_pexecutor.h.

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

Read-only access to individual executors.

Definition at line 174 of file sp_pexecutor.h.

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

Typedef for parallel clock values.

Definition at line 72 of file sp_pexecutor.h.

typedef std::vector<Idx> faudes::ParallelExecutor::ParallelState
 

Typedef for parallel discrete state.

Definition at line 69 of file sp_pexecutor.h.

typedef Executor::TimedState faudes::ParallelExecutor::TimedState
 

Provide typedef from Executor.

Definition at line 85 of file sp_pexecutor.h.


Constructor & Destructor Documentation

faudes::ParallelExecutor::ParallelExecutor void   ) 
 

Construct an emtpy ParallelExecuter.

Definition at line 20 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 25 of file sp_pexecutor.cpp.

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

Explicit destructor.

Definition at line 31 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 496 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 501 of file sp_pexecutor.cpp.

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

Definition at line 485 of file sp_pexecutor.cpp.

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

Overall alphabet.

Reimplemented in faudes::ProposingExecutor.

Definition at line 194 of file sp_pexecutor.cpp.

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

Definition at line 177 of file sp_pexecutor.h.

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

Definition at line 175 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 99 of file sp_pexecutor.cpp.

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

compile internal data (eg overall alphabet)

Reimplemented in faudes::LoggingExecutor.

Definition at line 46 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::ComputeEnabled void   )  const
 

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

Definition at line 199 of file sp_pexecutor.cpp.

void faudes::ParallelExecutor::ComputeEnabledNonConst void   ) 
 

Compute enabled core routine (non const).

Definition at line 205 of file sp_pexecutor.cpp.

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

Pretty printable string of clock name.

Definition at line 469 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 284 of file sp_pexecutor.cpp.

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

Pretty printable string of parallel state.

Definition at line 480 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, physical and logical time is also reset (to 0).

Returns:
True for success

Definition at line 294 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 289 of file sp_pexecutor.cpp.

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

Pretty printable string of current state.

Definition at line 475 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 physical 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 396 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 404 of file sp_pexecutor.cpp.

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

Set physical time.

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

Parameters:
time New physicall time

Reimplemented in faudes::LoggingExecutor.

Definition at line 383 of file sp_pexecutor.cpp.

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

Get physical time.

Reimplemented in faudes::LoggingExecutor.

Definition at line 391 of file sp_pexecutor.cpp.

const EventSet & faudes::ParallelExecutor::DisabledEvents  )  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 248 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 140 of file sp_pexecutor.cpp.

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)

Definition at line 159 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 114 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 124 of file sp_pexecutor.cpp.

const EventSet & faudes::ParallelExecutor::EnabledEvents  )  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 242 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 260 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 272 of file sp_pexecutor.cpp.

const TimeInterval & faudes::ParallelExecutor::EnabledInterval  )  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 254 of file sp_pexecutor.cpp.

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

Get maximal duration that can pass without executing an event.

Returns:
TimeInterval

Definition at line 235 of file sp_pexecutor.cpp.

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

Definition at line 176 of file sp_pexecutor.h.

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

Pretty printable string of event.

Definition at line 463 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 191 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 204 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 353 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 329 of file sp_pexecutor.cpp.

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)

Definition at line 90 of file sp_pexecutor.cpp.

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)

Definition at line 75 of file sp_pexecutor.cpp.

bool faudes::ParallelExecutor::IsDeadlocked  )  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 409 of file sp_pexecutor.cpp.

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

Pretty printable string of parallel state.

Definition at line 444 of file sp_pexecutor.cpp.

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

Pretty printable string of timed parallel state.

Definition at line 417 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 68 of file sp_pexecutor.cpp.

Idx faudes::ParallelExecutor::Size void   )  const
 

Number of tGenerators.

Definition at line 107 of file sp_pexecutor.cpp.

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

Pretty printable string of timed event.

Definition at line 457 of file sp_pexecutor.cpp.

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

update parallel timed state()

Definition at line 36 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 238 of file sp_pexecutor.h.


Member Data Documentation

EventSet faudes::ParallelExecutor::mAlphabet [private]
 

overall alphabet

Definition at line 554 of file sp_pexecutor.h.

ParallelTimedState faudes::ParallelExecutor::mCurrentParallelTimedState [private]
 

current state

Definition at line 578 of file sp_pexecutor.h.

int faudes::ParallelExecutor::mCurrentStep [private]
 

global time (step)

Definition at line 560 of file sp_pexecutor.h.

tpTime::Type faudes::ParallelExecutor::mCurrentTime [private]
 

global time (real)

Definition at line 557 of file sp_pexecutor.h.

EventSet faudes::ParallelExecutor::mDEvents [private]
 

disabled events

Definition at line 569 of file sp_pexecutor.h.

EventSet faudes::ParallelExecutor::mEEvents [private]
 

enabled events

Definition at line 566 of file sp_pexecutor.h.

TimeInterval faudes::ParallelExecutor::mEInterval [private]
 

enabled interval

Definition at line 572 of file sp_pexecutor.h.

TimeInterval faudes::ParallelExecutor::mETime [private]
 

enabled time

Definition at line 563 of file sp_pexecutor.h.

bool faudes::ParallelExecutor::mEValid [private]
 

validity flag for fevents and ftime

Definition at line 575 of file sp_pexecutor.h.

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

list of executors

Definition at line 548 of file sp_pexecutor.h.

std::vector<Executor> faudes::ParallelExecutor::mExecutors [private]
 

list of executors

Definition at line 545 of file sp_pexecutor.h.

Idx faudes::ParallelExecutor::mRecentEvent [protected]
 

recent event

Definition at line 540 of file sp_pexecutor.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 08:13:18 2008 for libFAUDES 2.11v by  doxygen 1.4.4