parallel agent based simulation on pc cluster

31
1 Parallel Agent Based Simulation on PC Cluster Seif Haridi Konstantin Popov Mahmoud Rafea Fredrik Holmgren Swedish Institute of Computer Science www.sics.se/~seif [email protected]

Upload: vuthu

Post on 02-Jan-2017

230 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Parallel Agent Based Simulation on PC Cluster

1

Parallel Agent Based Simulation on PC Cluster

Seif HaridiKonstantin PopovMahmoud Rafea

Fredrik HolmgrenSwedish Institute of Computer Science

www.sics.se/[email protected]

Page 2: Parallel Agent Based Simulation on PC Cluster

2

Abstract Architecture

ScenarioAgents

Behavior

State

LandscapePlaceholder

Physical Space

Simulation SystemSimulation Manager

Interaction

Scheduling

WorkersBehavior invocation

MonitorsTrack behavior

Page 3: Parallel Agent Based Simulation on PC Cluster

3

Example simulation model

• A bottom up agent based simulation

• Agents: users, sites representing web surfers, and web sites

• Landscapes: users are connected in Small World network (social network, 1-lattice), sites are connected in a similar network

• The model of time is discrete

• The implementation system is Mozart, language is Oz (http://www.mozart-oz.org)

Page 4: Parallel Agent Based Simulation on PC Cluster

4

Oz and Mozart at a glancehttp://www.mozart-oz.org

• Oz Language– Multiparadigm language, strong support for compositionality and concurrency

– Component-based programming– Simple formal semantics and efficient implementation

• Strengths– Concurrency: ultra lightweight threads, dataflow– Distribution: network transparent, network aware, open, fault detection

– Inferencing: constraint, logic, and symbolic programming– Flexibility: dynamic, no limits, first-class compiler

Page 5: Parallel Agent Based Simulation on PC Cluster

5

Web Word of Mouth Model

User characteristics:• Have preferences for specific categories of content

• Participate in “local” social networks

• Maintain a portfolio of frequently visited sites

• Have memory about visited sites and their perceived utility

• Have an evaluation method in order to evaluate sites they visit.

User behavior

• Asks friends to propose their favorite sites and visit them.

• Visits some sites from his portfolio.

• Surf along the links of the already visited sites.

• Replace a site in the portfolio by a new site if that new site maintained a higher utility for a longer period of time.

Page 6: Parallel Agent Based Simulation on PC Cluster

6

Model dynamics

LEFT: Distribution of web sites by size

RIGHT: Progressive evolution of the histogram “number of sites/number of users” towards a power-law distribution

Page 7: Parallel Agent Based Simulation on PC Cluster

7

Abstract Architecture

ScenarioAgents

Behavior

State

LandscapePlaceholder

Physical Space

Simulation SystemSimulation Manager

Interaction

Scheduling

WorkersBehavior invocation

MonitorsTrack behavior

Page 8: Parallel Agent Based Simulation on PC Cluster

8

Component-based Programming

• Implements abstract data-types– Encapsulation of internal state– Interface of external operations– Instantiation (component instances, modules)

• Compositionality– Specifies required (imported) components in

terms of their operations only – Decouples linking of the exact modules from

import specification. – Connecting component instances are done by the

component-manager at runtime (allows linking different component instances depending on runtime conditions

Page 9: Parallel Agent Based Simulation on PC Cluster

9

Component-based Programming

Interface

Component instance

Externalworld

Page 10: Parallel Agent Based Simulation on PC Cluster

10

Sequential Simulator Components

• Landscape– Small World (SM) graph

– Internet Sites (IS) graph

– Other graphs

• Agent state collections (set of agents)– Users collections, and Sites collections

• Agents behaviors– ExploreSites, GetRecommedations,

UpdatePortfolio, etc

Page 11: Parallel Agent Based Simulation on PC Cluster

11

Architecture Sequential - Simplified(component instances)

UsersSites

(One-step) Behavior Simulator

Simulator Control

A uses Ops of B

A B

Page 12: Parallel Agent Based Simulation on PC Cluster

12

Users

• Places the User agents on the SW graph

• Provides the Ops. of the Users abstract data-type needed to express behaviors

• Sites done in similar way

Users

Small WorldGraph

UserCollectionState

Page 13: Parallel Agent Based Simulation on PC Cluster

13

Behavior Simulator

UsersSites

One-step behavior Simulator

-Iterates over agents (users) behaviors as specified by CB

Beh n

Beh 1

ComposedBehaviorsCB

Page 14: Parallel Agent Based Simulation on PC Cluster

14

Parallel Simulator Requirements

• Goals

• Goal: 1000000+ sites/users, 1000+steps AFAP• Today's sequential system takes ≈1min for 10000

sites/users +100 steps on a 1Ghz processor• WORSE: at best linear memory requirements: ≈

0.25Gb per 100000 sites/users• Developing techniques & tools for high

performance parallel computation in Mozart• Study and improvement of [distributed] Mozart

Page 15: Parallel Agent Based Simulation on PC Cluster

15

Parallel Simulator

• Sites and Users collections are partitioned among N computers (N workers)

• A Manager computer is responsible for creating Sites and Users component instances and partitioning them to the workers according to their relative performance

• The behavior-simulator component is unchanged• The User and Sites component instances are

wrapped using a distribution abstraction that allows transparent access to remote user-agents and site-agents

Page 16: Parallel Agent Based Simulation on PC Cluster

16

Architecture Parallel Simulator

Users#nSites#n

One-step Simulator

Simulator Control

Users#1Sites#1

One-step Simulator

Manager

Page 17: Parallel Agent Based Simulation on PC Cluster

17

Distributed Users

• Abstracts the network

• Services requests from remote workers

• Send requests from local worker to remote ones

Local Users

Small WorldGraph

UserCollectionState

Remote usersproxy

Local users server

Network

Page 18: Parallel Agent Based Simulation on PC Cluster

18

Simple set-up

• Manager partitions user and site agents according to the workers performance

• Manager initiates work at each time step

• Each worker performs the work as specified by its one-step simulator

• Workers report to manager at the end of each time step

• This process is reiterated

Page 19: Parallel Agent Based Simulation on PC Cluster

19

Ways of performing Ops. on agents (sites/users)

• Remote (operation to data)– A request to perform an operation on a

site/user is sent to the responsible worker

• Replication (data to operation)– State of agent is replicated to requesting site– Works for stateless (immutable) data– Eager / Lazy

• One-Step Caching (data to operation)– State is cached at the worker when requested– State updates are done locally– At the end of a simulation step operations are

merged/performed at the agent’s worker– The cache is evicted (cleaned)

Page 20: Parallel Agent Based Simulation on PC Cluster

20

Sequential, 10000 sitesusers/time

0

100

200

300

400

500

600

62500 125000

time sec

users

Page 21: Parallel Agent Based Simulation on PC Cluster

21

Threading the Behavior Simulator (BS)

• Sequential BS is running a single thread• In the Parallel Simulator, multiple threads

are executed to hide network latency• This can be done in Mozart without

changing ‘Behaviors’ due to Mozart’s dataflow property

• A thread issues operations sequentially, blocks transparently on variables until bound

• How many threads per worker? depends on network latency

Page 22: Parallel Agent Based Simulation on PC Cluster

22

Number of Threads

0

100

200

300

400

500

600

700

800

900

3 6 12 24 49 98 196

391

782

1564

3190

6254

1250

825

015

5002

9

Threads

Tim

e (s

ec.)

Page 23: Parallel Agent Based Simulation on PC Cluster

23

Scalability

• We Want to study the scalability of the example application w.r.t. Problem size.

• As can been seen on next slide 1000K agents/ 16 workers experiment take similar time as 62,5K agents/one worker

Page 24: Parallel Agent Based Simulation on PC Cluster

24

Scalability

0

100

200

300

400

500

600

1W/6

2500

2W/1

2500

0

4W/2

5000

0

8W/5

0000

0

16W

/100

0000

Workers/Users

Tim

e (s

ec.)

Replication

Lazy Replication

Caching

Remote

Page 25: Parallel Agent Based Simulation on PC Cluster

25

Speed-up

• The speed-ups are good.

• The most general case with one-step caching obtains 10 times speedup on 16 workers.

• The speedup increases with larger problem size.

Page 26: Parallel Agent Based Simulation on PC Cluster

26

Speedup

0

2

4

6

8

10

12

14

16

1 2 4 8 16

Workers

Sp

eedu

p

Replication (125K users)

Replication (250K users)

Replication (500K users)

Replication (1000K users)

Caching (125K users)

Caching (250K users)

Caching (500K users)

Caching (1000K users)

Page 27: Parallel Agent Based Simulation on PC Cluster

27

Dataflow synchronization

• A worker at step N can serve requests for steps N-1, and N

• Serving a request at step N+1 state is delayed until the worker advances to N+1

• For any worker at step N, each other worker is either in step N-1, N , or N+1

Page 28: Parallel Agent Based Simulation on PC Cluster

28

Dataflow synchronization

• At the end of step N-1, a worker sends a sync(N) message to all other workers

• The worker waits for all sync(N-1) messages from all other workers, before starting step N

• For any worker at step N, each other worker is either in step N-1, N , or N+1

Page 29: Parallel Agent Based Simulation on PC Cluster

29

Barrier vs. Dataflow Synchronization

• 10k sites, 1M users, caching, 16 workers– 426 sec. with dataflow synchronization

– 500 sec. with barrier synchronization

Page 30: Parallel Agent Based Simulation on PC Cluster

30

Synchronous Garbage Collection

• 10k sites, 1M users, caching, 16 workers– 426 sec. with synchronous GC

– 491 sec. with asynchronous GC

Page 31: Parallel Agent Based Simulation on PC Cluster

31

Conclusions

• Component-based programming is essential for flexible agent-based bottom-up simulation.

• It is possible to simulate large number of agents 1000k agents using the right techniques on cheap PC clusters

• Mozart’s network transparency, dataflow synchronization, light-weight threads and component-based techniques eases the application development