modeling with parallel devs serialization in devs models select function implicit serialization of...

27
Modeling with Parallel DEVS

Upload: tobias-brown

Post on 14-Jan-2016

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

Modeling with Parallel DEVS

Page 2: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 3: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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))

Page 4: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 5: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 6: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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))

Page 7: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

Parallel-DEVS Coupled models• Components

• Couplings

– Internal– External Inputs– External Outputs

Fallowfield KingstonOttawa departure

arrival

departure

arrival

passengers passengers passengers

Ottawa-Toronto

Page 8: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 9: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 10: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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 )

Page 11: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 12: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

Coordinator

Coordinator

tN = 30 tN = 20tN = 15

( @, 15)

Page 13: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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++

Page 14: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 15: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 16: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 17: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 18: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 19: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 20: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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;

}

Page 21: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 22: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

• RADS (Carleton University)– Alpha network and Gamma network

Page 23: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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)

Page 24: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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.

Page 25: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 26: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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

Page 27: Modeling with Parallel DEVS Serialization in DEVS models Select function Implicit serialization of parallel models E-DEVS: internal transition first,

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