AGENT SIMULATIONS ON GRAPHICS HARDWARE Timothy Johnson -
[email protected] Supervisor: Dr. John Rankin
1
Slide 2
OUTLINE Agent Simulations Graphics Hardware System Model
Planning Code Generation Simulation Analysis Examples Performance
2
Slide 3
AGENT SIMULATIONS Simulations with hundreds or thousands of
software agents Agent-based simulations are becoming increasingly
more popular [1] Each entity simulated at the individual
microscopic level Emergence of interesting complex behaviour at the
macroscopic level Fields: air traffic control, disaster management,
biology, crime analysis, economics, pedestrian dynamics, military
simulations, etc Problems Expensive and time consuming to develop
Limited in scope by available processing power 3
Slide 4
GRAPHICS HARDWARE Graphical Processing Units (GPUs) are
outstripping Central Processing Units (CPUs) in terms of raw
performance [2] Performance gap continuing to widen Example Intel
Core i7-4930K [$679][187.2 GFLOPS] NVIDIA GTX 780 [$639][3977
GFLOPS] Programming Difficulties Dealing with hundreds or thousands
of cores and threads Data synchronisation Memory architecture Data
transfer between CPU and GPU Shortage of high quality learning
resources Prices retrieved from pccasegear.com on 04/11/2013 4
Slide 5
IDEA Increase processing power, allowing more agents to be
simulated than previously possible Make a system that does not
require the user to perform GPU programming 5
Slide 6
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 6
Slide 7
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 7
Slide 8
MODEL 8
Slide 9
Resources Items agents interact with Apple, Bread, Car, Gold,
Water Attributes Represent aspects of agents Age, Height, Health,
Hunger, Energy Rules Specify how an agent can interact with the
world Move, Use, Harvest, Trade, Combine Goals Define the agents
behaviour during simulation Maximize Attributes, Maximize Resources
Agent Types Built up with Attributes, Rules and Goals Farmer, Duck,
Bee, Policeman Communities Consists of one or more Agent Types
Town, Beehive, Sports team 9
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 11
Slide 12
PLANNING User enters resources, attributes, rules, goals,
agents, communities into our tool System then automatically links
goals and rules to create plans Goal One Rule One Rule Two Rule
Three 12
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 15
Slide 16
CODE GENERATION OpenCL code kernels are created for each agent
type defined OpenCL is programmed through a subset of C with its
own extensions Can run on both NVIDIA and AMD GPUs Algorithm For
each agent type Create a new kernel Prepare some initial
definitions and kernel arguments Iterate through each plan created
in the previous stage Generate segments of code for each rule in
each plan By automatically generated optimised code, we manage to
hide the difficulties of GPGPU from the user 16
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 18
Slide 19
SIMULATION Code kernels are compiled Data is generated on the
CPU Data is transferred across to GPU memory Each agent to be
simulated is assigned its own thread Simulation begins to run
19
Slide 20
SIMULATION: DUCK SIMULATION 20
Slide 21
SIMULATION: DUCK SIMULATION Yellow = Ducks, Green = Bugs, Blue
= Bread 21
Slide 22
SYSTEM OVERVIEW Model Code Generation Planning Simulation
Analysis 22
Slide 23
ANALYSIS All data from the simulation, including agent
positions, attribute values, resource values, plans chosen, etc can
be output to file during runtime After the simulation run has
completed, this data can then be analysed externally by other tools
23
PERFORMANCE TESTING Two versions of the Farming Simulation
created GPU version using our system Custom CPU-optimised version
Tests carried out on four GPUs and four CPUs Two laptop machines
and two desktop machines Millisecond per update and frame rates
were calculated Testing found modern GPUs are faster than CPUs in
most cases 26
Slide 27
SYSTEM PERFORMANCE 27
Slide 28
BEYOND SIMULATIONS Movies Games Advertisements 28
Slide 29
QUESTIONS? Timothy Johnson - [email protected]
Supervisor: Dr. John Rankin References: [1] Chan, W. K. V., Son Y.
J., Macal, C. M., Agent-based simulation tutorial - simulation of
emergent behavior and differences between agent-based simulation
and discrete-event simulation, In Proceedings of the Winter
Simulation Conference, WSC '10, 135-150, 2010. [2] Luebke, D.,
Humphreys, G., How GPUs Work, Computer, 40 (2), 96-100, 2007. [3]
Johnson, T. W. C., Rankin, J. R., Parallel Agent Systems on a GPU
for use with Simulations and Games, In Proceedings of the 1st
International Conference on Computing, Information Systems and
Communications, CISCO '01, 229-235, 2012. [4] Johnson, T. W. C.,
Rankin, J. R., User Friendly Agent-Oriented Simulation Builder, In
Proceedings of the 8th International Conference on Information
Technology and Applications, ICITA '08, 2013. 29