Modeling with Parallel DEVS
Serialization in DEVS models
• Select function• Implicit serialization of parallel models• E-DEVS: internal transition first, external transition after• Inadequate representation of DEVS models
with parallel components
Parallel DEVS Atomic Models
ta(s) ta(s) (1)(1)ss
DEVS = DEVS = < X< Xbb, S, Y, S, Ybb, , int int , , ext ext , , confconf , ta, , ta,
ss
yybb (3)(3)
ss’ ’ = = int int ss
xxbb (5)(5)
ss’ ’ = = ext ext ((s,e,xs,e,xbb)) (6a)(6a)
ss’ ’ = = conf conf ((s,e,xs,e,xbb))
((66bb))
Parallel DEVS Atomic models
ta(s) ta(s) (1)(1)ss
DEVS = DEVS = < X< Xbb, S, Y, S, Ybb, , int int , , ext ext , , confconf , ta, , ta,
ss
yybb (3)(3)
ss’ ’ = = int int ss
Parallel DEVS Atomic models
ta(s) ta(s) (1)(1)ss
DEVS = DEVS = < X< Xbb, S, Y, S, Ybb, , int int , , ext ext , , confconf , ta, , ta,
xxbb (5)(5)
ss’ ’ = = ext ext ((s,e,xs,e,xbb)) (6a)(6a)
Parallel DEVS Atomic models
ta(s) ta(s) (1)(1)ss
DEVS = DEVS = < X< Xbb, S, Y, S, Ybb, , int int , , ext ext , , confconf , ta, , ta,
xxbb (5)(5)
ss’ ’ = = conf conf ((s,e,xs,e,xbb))
((66bb))
Parallel-DEVS Coupled models• Components
• Couplings
– Internal– External Inputs– External Outputs
Fallowfield KingstonOttawa departure
arrival
departure
arrival
passengers passengers passengers
Ottawa-Toronto
Simulation mechanism
• Simulation advanced through message exchange
– Synchronization messagesType Action
( @, t ) Output execution
( *, t ) State transition
( done , t ) End of action
– Content messages( y , t ) Output event
( q , t ) External event
Simulator• Drives atomic models• State
tN = time of next transition
tL = time of last transition
message bag
• Upon receiving Do– ( @, t ) y =y = sssend ( y, t )send ( y, t )
– (q, t) Add q to message bagAdd q to message bag
– ( *, t )
• if t < tN ss extext ; tN = ta(s) ; tL = t; tN = ta(s) ; tL = t
• if t = tN bag = s s int int ; tN = ta(s) ; tL = t; tN = ta(s) ; tL = t
• if t = tN bag ss conf conf ; tN = ta(s) ; tL = t; tN = ta(s) ; tL = t
Coordinator Coordinates processor’s activities
Coordinator
tN = 10 tN = 10tN = 20
( @, 10)
( @, 10)
( @, 10)
( y, 10)( y, 10)
y =y = ss y =y = ss
( done, 10)
( done, 10)
( done, 10 )( y, 10 )
Coordinator
Coordinator
tN = 10 tN = 10tN = 20
( *, 10) (q, 10)
(q, 10)
(q, 10)
s =s = intints =s = extexts =s = confconf
( done, 30)
( done, 20)
(done, 15)
(done, 15)
( *, 10)
( *, 10)(*, 10)
Coordinator
Coordinator
tN = 30 tN = 20tN = 15
( @, 15)
Parallel CD++
• A tool to execute Parallel DEVS and Parallel Cell-DEVS models in parallel/distributed environments
• Layered architecture based on Warped
MPI (Message Passing Interface)
Warped
Parallel CD++
Parallel - DEVS simulation• Independent of the modelling technique
• Different simulators can be applied according to the needs.
• Examples of existing simulators:– Hierarchical– Flat– Centralized– Distributed– Real-Time
Parallel DEVS simulation
• Processors– Simulator: Atomic model– Coordinator: Coupled model
• Processor hierarchy = model hierarchy
Cellular model : a coupledmodel of 16 cell Coord.
Simulator
Processors: 1 coordinator16 simulators
Simulator SimulatorSimulator
CD++ Parallel simulator
• Model partitioned among available CPUs
– Atomic models• Each atomic model assigned to a CPU
– Coupled models• Coordinator is placed on each CPU where there is a component
CPU 1 CPU 2
Coord.
Simulator
Coord.
Simulator Simulator Simulator
Parallel simulation mechanism
CPU 1 CPU 2
Simulator
Master coord.
SimulatorSimulator Simulator
Slave coord.
(@,10)(@,10)
(y,10)
(done,10)
(done,10)
(@,10) (@,10)
(y,10) (y,10)(done,10) (done,10)
Parallel simulation mechanism
CPU 1 CPU 2
simulator
Master coord.
simulatorsimulator simulator
Slave coord.
(*,10)(*,10)
(done,tN)
(done, min tN)
(q,10) (q,10)
(done,tN) (done,tN)
(*,10) (*,10)
Extensions to CD++class Atomic : public Model{public:virtual ~Atomic(); // Destructor
protected:
//User defined functions.virtual Model &initFunction() = 0;virtual Model &externalFunction ( const MessageBag & );virtual Model &externalFunction( const ExternalMessage & );virtual Model &internalFunction( const InternalMessage & ) = 0 ;virtual Model &outputFunction( const CollectMessage & ) = 0 ;virtual Model &confluentFunction ( const InternalMessage &, const MessageBag & );virtual ModelState* allocateState();virtual string className() const
//Kernel servicesvoid nextChange(Vtime);Vtime nextChange();void lastChange(Vtime);Vtime lastChange();
Model &holdIn( const AtomicState::State &, const VTime & ) ;Model &sendOutput(const VTime &time, const Port & port , BasicMsgValue *value)Model &sendOutput(const VTime &time, const Port & port , Value value)Model &passivate();
//State functionsvirtual ModelState* getCurrentState() const;virtual ModelState* getCurrentState() ;
//State shortcutsModel &state( const AtomicState::State &s ){ ((AtomicState *)getCurrentState())->st = s; return *this; }
const AtomicState::State &state() const{return ((AtomicState *)getCurrentState())->st;}
}; // class Atomic
Extensions (cont.)class MessageBag {
public:
MessageBag();//Default Constructor~MessageBag();
MessageBag &add( const BasicPortMessage* );
bool portHasMsgs( const string& portName ) const;
const MessageList& msgsOnPort( const string& portName ) const;
int size() const
MessageBag& eraseAll();
const VTime& time() const;};
Model &Atomic::confluentFunction ( const InternalMessage &intMsg, constMessageBag &extMsgs ){//Default behavior for confluent function://Proceed with the internal transition and the with the externalinternalFunction( intMsg );
//Set the elapsed time to 0lastChange( intMsg.time() );
//Call the external functionexternalFunction( extMsgs );
return *this;
}
Partition Files
ProcNumber : modelName1 modelName2 cell(x,y) cell(x,y)..(x2, y2)
0 : generadorCalor generadorFrio0 : superficie(0,0)..(32,32)1 : superficie(0,33)..(32,65)2 : superficie(0,66)..(32,99)3 : superficie(33,0)..(65,32)4 : superficie(33,33)..(65,65)5 : superficie(33,66)..(65,99)6 : superficie(66,0)..(99,32)7 : superficie(66,33)..(99,65)8 : superficie(66,66)..(99,99)
• RADS (Carleton University)– Alpha network and Gamma network
Simulation Results
GPT
Generator
transducer
queue
processorthroughput
cpuusage
out
arrive
in
indone
solved out
• Generator- Processor-Transducer– Multiple instances (12, 48 and 96)– 1 to 12 CPUs (different machines)
ResultsGenerator - Processor - Transducer
0
500
1000
1500
2000
2500
3000
0 5 10 15
Number of CPUs
Tim
e (
sec) 12 Inst.
48 Inst.
96 Inst.
Results
• Heat diffusion model– 100 x 100 surface– Each cell holds a temperature value– Temperature is update periodically
• Partitions– 1, 2, 4 and 8 CPUs
• Quantization– Quantum sizes:
• 0 ; 0,001 ; 0,01 y 0,1
10000
Results
• Heat diffusion - Linux cluster
0100200300400500600700800900
1000
1 2 4 8
Number of CPUs
Tim
e (
sec) Q = 0
Q = 0.001
Q = 0.01
Q = 0.1
Results• Heat diffusion - 4 processors SMP
0
500
1000
1500
2000
2500
1 2 4
Number of CPUs
Tim
e (
sec) Q = 0
Q = 0.001
Q = 0.01
Q = 0.1