Barnes Hut N-body Simulation Martin Burtscher Fall 2009.

Slides:



Advertisements
Similar presentations
Instructor Notes Lecture discusses parallel implementation of a simple embarrassingly parallel nbody algorithm We aim to provide some correspondence between.
Advertisements

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Planar point location -- example
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
BackTracking Algorithms
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Chapter 4: Trees Part II - AVL Tree
Honor Thesis Presentation Mike Bantegui, Hofstra University Advisor: Dr. Xiang Fu, Hofstra University EFFICIENT SOLUTION OF THE N-BODY PROBLEM.
ParaMeter: A profiling tool for amorphous data-parallel programs Donald Nguyen University of Texas at Austin.
Data Structures: A Pseudocode Approach with C 1 Chapter 6 Objectives Upon completion you will be able to: Understand and use basic tree terminology and.
Parallel Strategies Partitioning consists of the following steps –Divide the problem into parts –Compute each part separately –Merge the results Divide.
Chapter 6: Transform and Conquer
Course Outline Introduction in algorithms and applications Parallel machines and architectures Overview of parallel machines, trends in top-500 Cluster.
CS267, Yelick1 Cosmology Applications N-Body Simulations Credits: Lecture Slides of Dr. James Demmel, Dr. Kathy Yelick, University of California, Berkeley.
Hierarchical Methods for the N-Body problem based on lectures by James Demmel
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
Adaptive dynamics for Articulated Bodies. Articulated Body dynamics Optimal forward dynamics algorithm –Linear time complexity –e.g. Featherstone’s DCA.
Daniel Blackburn Load Balancing in Distributed N-Body Simulations.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
CSE 160/Berman Mapping and Scheduling W+A: Chapter 4.
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
Efficient Distance Computation between Non-Convex Objects By Sean Quinlan Presented by Sean Augenstein and Nicolas Lee.
Chapter 3: Cluster Analysis  3.1 Basic Concepts of Clustering  3.2 Partitioning Methods  3.3 Hierarchical Methods The Principle Agglomerative.
Advanced Topics in Algorithms and Data Structures 1 An example.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
Course Outline Introduction in algorithms and applications Parallel machines and architectures Overview of parallel machines, trends in top-500, clusters,
VAST 2011 Sebastian Bremm, Tatiana von Landesberger, Martin Heß, Tobias Schreck, Philipp Weil, and Kay Hamacher Interactive-Graphics Systems TU Darmstadt,
Topic 17 Introduction to Trees
Introduction to Particle Simulations Daniel Playne.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
CSCI-455/552 Introduction to High Performance Computing Lecture 11.5.
1 Algorithms CSCI 235, Fall 2015 Lecture 14 Analysis of Heap Sort.
Foundation of Computing Systems
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
R-Trees: A Dynamic Index Structure For Spatial Searching Antonin Guttman.
An Efficient CUDA Implementation of the Tree-Based Barnes Hut n-body Algorithm By Martin Burtscher and Keshav Pingali Jason Wengert.
Mayur Jain, John Verboncoeur, Andrew Christlieb [jainmayu, johnv, Supported by AFOSR Abstract Electrostatic particle based models Developing.
Lecture 15 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Hierarchical Volume Rendering
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Barnes Hut N-body Simulation Martin Burtscher Fall 2009.
Clustering (1) Chapter 7. Outline Introduction Clustering Strategies The Curse of Dimensionality Hierarchical k-means.
Example Apply hierarchical clustering with d min to below data where c=3. Nearest neighbor clustering d min d max will form elongated clusters!
Some Computational Science Algorithms and Data Structures Keshav Pingali University of Texas, Austin.
UNC Chapel Hill David A. O’Brien Automatic Simplification of Particle System Dynamics David O’Brien Susan Fisher Ming C. Lin Department of Computer Science.
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! 1 ITCS 4/5145 Parallel Computing,
Sink particles ● Introduce sink particles whenever the density in a cell violates the Jeans criterion or and set the mass of the sink particle to: so that.
Sorting With Priority Queue In-place Extra O(N) space
ChaNGa: Design Issues in High Performance Cosmology
Tree traversal from Introduction to Trees Chapter 6 Objectives
CS223 Advanced Data Structures and Algorithms
Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms
Course Outline Introduction in algorithms and applications
Chapter 6: Transform and Conquer
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
Cosmology Applications N-Body Simulations
Plants from Images CS 658.
Birch presented by : Bahare hajihashemi Atefeh Rahimi
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
More advanced aspects of search
Adaptive dynamics for Articulated Bodies
N-Body Gravitational Simulations
Computational Science Algorithms
Introduction to Trees Chapter 6 Objectives
Introduction to Scientific Computing II
Presentation transcript:

Barnes Hut N-body Simulation Martin Burtscher Fall 2009

Introduction  Physical system simulation (time evolution)  System consists of bodies  “n” is the number of bodies  Bodies interact via pair-wise forces  Many systems can be modeled in these terms  Galaxy clusters (gravitational force)  Particles (electric force, magnetic force) Barnes Hut N-body Simulation 2

Barnes Hut Idea  Precise force calculation  Requires O(n 2 ) operations (O(n 2 ) body pairs)  Barnes and Hut (1986)  Algorithm to approximately compute forces  Bodies’ initial position & velocity are also approximate  Requires only O(n log n) operations  Idea is to “combine” far away bodies  Error should be small because force  1/r 2 Barnes Hut N-body Simulation 3

Barnes Hut Algorithm  Set bodies’ initial position and velocity  Iterate over time steps 1. Subdivide space until at most one body per cell  Record this spatial hierarchy in an octree 2. Compute mass and center of mass of each cell 3. Compute force on bodies by traversing octree  Stop traversal path when encountering a leaf (body) or an internal node (cell) that is far enough away 4. Update each body’s position and velocity Barnes Hut N-body Simulation 4

Build Tree (Level 1) Barnes Hut N-body Simulation 5 Subdivide space until at most one body per cell

Build Tree (Level 2) Barnes Hut N-body Simulation 6 Subdivide space until at most one body per cell

Build Tree (Level 3) Barnes Hut N-body Simulation 7 Subdivide space until at most one body per cell

Build Tree (Level 4) Barnes Hut N-body Simulation 8 Subdivide space until at most one body per cell

Build Tree (Level 5) Barnes Hut N-body Simulation 9 Subdivide space until at most one body per cell

Compute Cells’ Center of Mass Barnes Hut N-body Simulation 10 For each internal cell, compute sum of mass and weighted average of position of all bodies in subtree; example shows two cells only

Compute Forces Barnes Hut N-body Simulation 11 Compute force, for example, acting upon green body

Compute Force (short distance) Barnes Hut N-body Simulation 12 Scan tree depth first from left to right; green portion already completed

Compute Force (down one level) Barnes Hut N-body Simulation 13 Red center of mass is too close, need to go down one level

Compute Force (long distance) Barnes Hut N-body Simulation 14 Yellow center of mass is far enough away

Compute Force (skip subtree) Barnes Hut N-body Simulation 15 Therefore, entire subtree rooted in the yellow cell can be skipped

Pseudocode Set bodySet =... foreach timestep do { Octree octree = new Octree(); foreach Body b in bodySet { octree.Insert(b); } OrderedList cellList = octree.CellsByLevel(); foreach Cell c in cellList { c.Summarize(); } foreach Body b in bodySet { b.ComputeForce(octree); } foreach Body b in bodySet { b.Advance(); } Barnes Hut N-body Simulation 16

Complexity Set bodySet =... foreach timestep do { // O(n log n) Octree octree = new Octree(); foreach Body b in bodySet { // O(n log n) octree.Insert(b); } OrderedList cellList = octree.CellsByLevel(); foreach Cell c in cellList { // O(n) c.Summarize(); } foreach Body b in bodySet { // O(n log n) b.ComputeForce(octree); } foreach Body b in bodySet { // O(n) b.Advance(); } Barnes Hut N-body Simulation 17

Parallelism Set bodySet =... foreach timestep do { // sequential Octree octree = new Octree(); foreach Body b in bodySet { // tree building octree.Insert(b); } OrderedList cellList = octree.CellsByLevel(); foreach Cell c in cellList { // tree traversal c.Summarize(); } foreach Body b in bodySet { // fully parallel b.ComputeForce(octree); } foreach Body b in bodySet { // fully parallel b.Advance(); } Barnes Hut N-body Simulation 18

Amorphous Data-Parallelism (1)  Top-down tree building  Topology: tree  Operator: morph (refinement)  Ordering: unordered  Active nodes: new nodes  Neighborhoods: active nodes and their parents (the path leading to the parent is only read)  Parallelism: increasing from none to a lot Barnes Hut N-body Simulation 19

Amorphous Data-Parallelism (2)  Bottom-up tree summarization  Topology: tree  Operator: local computation (structure driven)  Ordering: ordered (children first, priority is determined by tree level)  Active nodes: internal nodes  Neighborhoods: active nodes and their children  Parallelism: decreasing from a lot to none Barnes Hut N-body Simulation 20

Amorphous Data-Parallelism (3)  Force computation  Topology: tree + set  Operator: reader + local computation (structure driven)  Ordering: unordered/unordered  Active nodes: nodes in set  Neighborhoods: active nodes (the tree is only read)  Parallelism: full Barnes Hut N-body Simulation 21

Amorphous Data-Parallelism (4)  Advancing bodies  Topology: set  Operator: local computation (structure driven)  Ordering: unordered  Active nodes: nodes  Neighborhoods: active nodes  Parallelism: full Barnes Hut N-body Simulation 22