1 / 67

Matrix Trees

Matrix Trees. Nate Andrysco Xavier Tricoche Purdue University Department of Computer Science. Overview of Matrix Trees. Spatial subdivision trees are basic building blocks of graphics and visualization Octree KD-Tree BSP Tree Same underlying data structures for 30+ years

Download Presentation

Matrix Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Matrix Trees Nate Andrysco Xavier Tricoche Purdue University Department of Computer Science EuroVis 2010

  2. Overview of Matrix Trees • Spatial subdivision trees are basic building blocks of graphics and visualization • Octree • KD-Tree • BSP Tree • Same underlying data structures for 30+ years • A solved problem?

  3. Overview of Matrix Trees • An octree and kd-tree data structure that is…

  4. Overview of Matrix Trees • An octree and kd-tree data structure that is… Smaller!

  5. Overview of Matrix Trees • An octree and kd-tree data structure that is… Smaller! Faster!

  6. Overview of Matrix Trees • An octree and kd-tree data structure that is… Smaller! Faster! Versatile!

  7. Overview of Matrix Trees • An octree and kd-tree data structure that is… Smaller! Faster! Versatile! GPU Friendly!

  8. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Applications • Ray Casting • Unstructured Mesh

  9. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Ray Casting Application • Unstructured Mesh Application

  10. Previous Tree Representations • Pointer-based Trees • Each node contains some data

  11. Previous Tree Representations • Pointer-based Trees • Each node contains some data • Now add in pointers

  12. Previous Tree Representations • Pointer-based Trees • Each node contains some data • Now add in pointers • … add position information

  13. Previous Tree Representations • Pointer-based Trees • Each node contains some data • Now add in pointers • … add position information

  14. Previous Tree Representations • Pointer-based Trees • Each node contains some data • Now add in pointers • Extra programming difficulty

  15. Previous Tree Representations • Pointer-based Trees • Each node contains some data • Now add in pointers • Extra programming difficulty • Memory required by tree is linear to nodes in tree

  16. Previous Tree Representations • Pointerless Trees • Each node contains some data

  17. Previous Tree Representations • Pointerless Trees • Each node contains some data • Derive position in memory of parents, children, neighbors, etc • Derive position information

  18. Previous Tree Representations • Pointerless Trees • Each node contains some data • Derive position in memory of parents, children, neighbors, etc • Derive position information • GPU ready data structure

  19. Previous Tree Representations • Pointerless Trees • Each node contains some data • Derive position in memory of parents, children, neighbors, etc • Derive position information • GPU ready data structure • Total memory is exponential to height of tree

  20. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Applications • Ray Casting • Unstructured Mesh

  21. Our Representation • Use matrices as underlying representation • Provides “best of both worlds” • A separate matrix per level of tree • Sparse matrix data structure • Allows for improvements to tree operations

  22. Quadtree Example 1x1 Matrix 2x2 Matrix 4x4 Matrix 8x8 Matrix

  23. Quadtree Example 1x1 Matrix 2x2 Matrix 4x4 Matrix 8x8 Matrix 1x1 Matrix 2x2 Matrix 4x4 Matrix ? 8x8 Matrix ?

  24. Quadtree Example 1x1 Matrix 2x2 Matrix 4x4 Matrix 8x8 Matrix 1x1 Matrix 2x2 Matrix 4x4 Sparse Rep. 8x8 Sparse Rep.

  25. Underlying Representation • Array of matrices • Each node is represented by a 4-tuple • Level in tree • (x,y,z) index position in matrix Level = 0 Level = 1 Level = 2 (1,1) (0,1) (x=0, y=0) (2,3) (3,3) (0,0) (1,0) (2,2) (3,2)

  26. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Ray Casting Application • Unstructured Mesh Application

  27. Deriving Node Indices • Given the node tuple, [ level, x, y ]: • Parent = [ level-1, x/2, y/2 ] Level = 0 Level = 1 Level = 2 (x=0, y=0) (1,0) (3,2)

  28. Deriving Node Indices • Given the node tuple, [ level, x, y ]: • Child = [ level+1, x*2 + i, y*2 + j ] • Where (i,j)represent the relational index Level = 0 Level = 1 Level = 2 (x=0, y=0) (1,0) (3,2)

  29. Deriving Node Indices • Given the node tuple, [ level, x, y ]: • Neighbor = [ level, x + i, y + j ] • Where (i,j)represent the relational index Level = 0 Level = 1 Level = 2 (1,1) (0,1) (0,0) (1,0)

  30. Deriving Node Indices • KD-Trees need to keep track of split directions • i.e. for y-splits, parent = [ level-1, x, y/2 ] Level = 0 Level = 1 Level = 2 (0,3) (0,1) (0,2) (x=0, y=0)

  31. Deriving Spatial Information • Cells have the same size • Easily derive matrix dimensions • Can spatially hash into any node at any level

  32. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Ray Casting Application • Unstructured Mesh Application

  33. Sparse Matrix Data Structure • Naïve approach – nested vectors • Easy to implement • Low cost insertions (dynamic) • Poor lookup performance • Compressed Sparse Row (CSR) • Quicker random access • Costly random insertions (static) • Easily and quickly transform naïve to CSR

  34. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Lookup data at ( 2 , 1 ) 5.4 0 2.0 0 0 0 0 1.5 4.8 3.4 8.2 0 0 7.7 9.1 0

  35. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Row index vector • O(1) lookup

  36. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Lookup data at ( 2 , 1 ) 5.4 0 2.0 0 0 0 0 1.5 4.8 3.4 8.2 0 0 7.7 9.1 0

  37. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Row index vector • O(1) lookup • Column index vector • O(lg m) lookup

  38. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Lookup data at ( 2 , 1 ) 5.4 0 2.0 0 0 0 0 1.5 4.8 3.4 8.2 0 0 7.7 9.1 0

  39. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Row index vector • O(1) lookup • Column index vector • O(lg m) lookup • Data vector • O(1) lookup

  40. Sparse Matrix Data Structure • Compressed Sparse Row (2D) • Lookup data at ( 2 , 1 ) 5.4 0 2.0 0 0 0 0 1.5 4.8 3.4 8.2 0 0 7.7 9.1 0

  41. Complementary CSR • Compressed Sparse Row (2D) • If our matrix is dense… 5.4 0 2.0 0 0 2.2 0 1.5 4.8 3.4 8.2 0 4.2 7.7 9.1 1.3

  42. Complementary CSR • Compressed Sparse Row (2D) • If our matrix is dense… • Keep track of non-zeros 5.4 0 2.0 0 0 2.2 0 1.5 4.8 3.4 8.2 0 4.2 7.7 9.1 1.3

  43. Complementary CSR • Compressed Sparse Row (2D) • If our matrix is dense… • Keep track of non-zeros • If we only care if a node exists 1 0 1 0 0 1 0 1 1 1 1 0 1 1 1 1

  44. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Ray Casting Application • Unstructured Mesh Application

  45. GPU Implementation • Data and indices are stored as vectors on CPU • Concatenate CPU vectors and store in GPU textures • Use helper vectors • Matrix types • Data offsets • CSR index vector offsets

  46. Outline • Previous Tree Representations • Our Representation • Deriving Information • Sparse Matrix Data Structure • GPU Implementation • Tree Operations (Leaf and Neighbor Finding) • Theoretical Analysis • Applications • Ray Casting • Unstructured Mesh

  47. Previous Leaf Finding • Given a point, find the leaf that contains it • Majority of previous methods are top-down • O(log N) average • … or O(h) 1 2 3 4 5

  48. Our Improved Leaf Finding • Initial hash, O(1), eliminates N-h nodes

  49. Our Improved Leaf Finding • Binary search along path, O (log2 h) 2 3 1

  50. Improved Neighbor Finding • Previous method for pointer-based trees: • Can result in full leaf finding operation • Our method: • Neighbors at same level • Simply derive information • Neighbors at other levels • Do limited binary search

More Related