flavors library for fast parallel lookup using custom
play

Flavors Library for Fast Parallel Lookup Using Custom Radix Trees - PowerPoint PPT Presentation

Flavors Library for Fast Parallel Lookup Using Custom Radix Trees Presentation ID 23269 Albert Wolant Warsaw University of Technology GTC Europe 11 October 2017 1 Acknowledgements Krzysztof Kaczmarski, Ph.D - my Ph.D thesis advisor


  1. Flavors Library for Fast Parallel Lookup Using Custom Radix Trees Presentation ID 23269 Albert Wolant Warsaw University of Technology GTC Europe 11 October 2017 1

  2. Acknowledgements • Krzysztof Kaczmarski, Ph.D - my Ph.D thesis advisor • Faculty of Mathematics and Information Science 2

  3. What I will talk about? • What is Flavors and how it came to be? • Overview of algorithms. • Experimental results and benchmarks. • Customization using machine learning 3

  4. From where it came? Presentation on GTC 2016 on GTC On-Demand platform: 4

  5. What it can do? • Flavors provides algorithm to build and search radix-tree with configurable bit stride on the GPU. • Values can be of constant length (keys) or can vary in length (masks). • Search can be done to find values exactly or perform longest-prefix matching. 5

  6. Tree for keys Example of tree for bit strides sequence { 3 , 2 , 1 } . 6

  7. Tree for keys - searching example Example search for key 010 − 01 − 1 7

  8. Tree for keys - searching example Example search for key 010 − 01 − 1 8

  9. Tree for keys - searching example Example search for key 010 − 01 − 1 9

  10. Tree for keys - searching example Example search for key 010 − 01 − 1 10

  11. Tree for keys - searching example Example search for key 010 − 01 − 1 11

  12. Tree for keys - searching example Example search for key 010 − 01 − 1 12

  13. Tree for keys - searching example Example search for key 010 − 01 − 1 13

  14. Tree for keys - searching example Example search for key 010 − 01 − 1 14

  15. Tree for keys - searching example Example search for key 010 − 01 − 1 15

  16. Tree for keys - searching example Example search for key 010 − 01 − 1 16

  17. Tree for keys - node structure In practice, cells hold indexes of nodes on next level instead of pointers. Last level keeps original indexes of keys. 17

  18. Tree for keys - node structure In practice, cells hold indexes of nodes on next level instead of pointers. Last level keeps original indexes of keys. 18

  19. Tree construction - input data 19

  20. Tree construction - data sorting 20

  21. Tree construction - values 21

  22. Tree construction - nodes borders 22

  23. Tree construction - nodes borders 23

  24. Tree construction - nodes borders 24

  25. Tree construction - nodes borders 25

  26. Tree construction - nodes borders 26

  27. Tree construction - nodes indexes 27

  28. Tree construction - nodes indexes 28

  29. Tree construction - nodes indexes 29

  30. Tree construction - nodes allocation 30

  31. Tree construction - nodes allocation Last row of nodesIndexes array has node counts for each level. Since size of node on level is known (based on bit stride), memory for all nodes can be allocated. 31

  32. Tree construction - nodes allocation Last row of nodesIndexes array has node counts for each level. Since size of node on level is known (based on bit stride), memory for all nodes can be allocated. Values in arrays above can also be used to link nodes between levels. 32

  33. Tree construction - linking nodes Let V be values array, B be nodesBorders , and N be nodesIndexes . Let’s consider one cell of this arrays, in row ′ key ′ and column ′ level ′ . 33

  34. Tree construction - linking nodes Let V be values array, B be nodesBorders , and N be nodesIndexes . Let’s consider one cell of this arrays, in row ′ key ′ and column ′ level ′ . Let v = V [ key ][ level ] and n = N [ key ][ level ] and b = B [ key ][ level ]. 34

  35. Tree construction - linking nodes Let V be values array, B be nodesBorders , and N be nodesIndexes . Let’s consider one cell of this arrays, in row ′ key ′ and column ′ level ′ . Let v = V [ key ][ level ] and n = N [ key ][ level ] and b = B [ key ][ level ]. Let C be 2D array pointing to all of the nodes (for example C [1][2] points to the beginning of second node on first level, since indexing is done from 1). 35

  36. Tree construction - linking nodes Let V be values array, B be nodesBorders , and N be nodesIndexes . Let’s consider one cell of this arrays, in row ′ key ′ and column ′ level ′ . Let v = V [ key ][ level ] and n = N [ key ][ level ] and b = B [ key ][ level ]. Let C be 2D array pointing to all of the nodes (for example C [1][2] points to the beginning of second node on first level, since indexing is done from 1). Then: C [ level ][ n ] + v ← − N [ key ][ level + 1] 36

  37. Tree construction - linking nodes Let V be values array, B be nodesBorders , and N be nodesIndexes . Let’s consider one cell of this arrays, in row ′ key ′ and column ′ level ′ . Let v = V [ key ][ level ] and n = N [ key ][ level ] and b = B [ key ][ level ]. Let C be 2D array pointing to all of the nodes (for example C [1][2] points to the beginning of second node on first level, since indexing is done from 1). Then: C [ level ][ n ] + v ← − N [ key ][ level + 1] To avoid multiple writes to the same cell, above is done only, if b is equal to 1. 37

  38. Tree construction - linking nodes On last level, we do: C [ level ][ n ] + v ← − P [ key ] where P is permutation containing original indexes of keys. 38

  39. Tree construction - linking nodes On last level, we do: C [ level ][ n ] + v ← − P [ key ] where P is permutation containing original indexes of keys. This operation is done for every key. 39

  40. Tree construction - linking nodes example 40

  41. Tree construction - linking nodes example level = 2, key = 8 41

  42. Tree construction - linking nodes example level = 2, key = 8, v = 0, n = 4, b = 1 42

  43. Tree construction - linking nodes example level = 2, key = 8, v = 0, n = 4, b = 1 C [ level ][ n ] + v = C [2][4] 43

  44. Tree construction - linking nodes example level = 2, key = 8, v = 0, n = 4, b = 1 C [ level ][ n ] + v = C [2][4] 44

  45. Tree construction - what about masks? 45

  46. Tree construction - what about masks? 46

  47. Tree construction - removing empty nodes Some of the nodes are no longer needed, because masks that would occupy them were shorter. 47

  48. Tree construction - removing empty nodes Some of the nodes are no longer needed, because masks that would occupy them were shorter. How to allocate memory and link nodes together? 48

  49. Tree construction - removing empty nodes 49

  50. Tree construction - removing empty nodes After calculating nodesIndexes array, cells are cleared (values set to 0), if mask does not reach level. 50

  51. Tree construction - removing empty nodes Then ′ 1 ′ in nodesBorders representing no longer needed nodes are cleared. 51

  52. Tree construction - removing empty nodes After that, nodesIndexes can be recalculated and nodes allocated and linked exactly as before. 52

  53. Tree construction - containers For bit stride { 3, 2, 1 } , masks: 010 − 0 X − X 010 − 00 − X land in the same place in the tree. 53

  54. Tree construction - containers For bit stride { 3, 2, 1 } , masks: 010 − 0 X − X 010 − 00 − X land in the same place in the tree. Solution is attaching containers for masks to each node. 54

  55. Tree construction - containers For bit stride { 3, 2, 1 } , masks: 010 − 0 X − X 010 − 00 − X land in the same place in the tree. Solution is attaching containers for masks to each node. Since masks are kept in this containers, last tree level, holding original indexes, is no longer needed. On this level we only need containers. 55

  56. Tree construction - containers 56

  57. Tree construction - containers 57

  58. Tree construction - containers Current implementation uses simple lists kept in single array and each of them is sorted by masks length. 58

  59. Tree construction - building lists Lists are build in few steps: 59

  60. Tree construction - building lists Lists are build in few steps: 1. Masks are marked with index of node to which they belong ( nodesIndexes on mask level, 0 otherwise). 60

  61. Tree construction - building lists Lists are build in few steps: 1. Masks are marked with index of node to which they belong ( nodesIndexes on mask level, 0 otherwise). 2. Lists lengths are calculated, using reduce by key operation. 61

  62. Tree construction - building lists Lists are build in few steps: 1. Masks are marked with index of node to which they belong ( nodesIndexes on mask level, 0 otherwise). 2. Lists lengths are calculated, using reduce by key operation. 3. All masks belong to some list, so memory for all lists is allocated. Only list start and list length is kept with the node (in yellow rectangle). 62

  63. Tree construction - building lists Lists are build in few steps: 1. Masks are marked with index of node to which they belong ( nodesIndexes on mask level, 0 otherwise). 2. Lists lengths are calculated, using reduce by key operation. 3. All masks belong to some list, so memory for all lists is allocated. Only list start and list length is kept with the node (in yellow rectangle). 4. Lists starts are calculated by performing exclusive scan operation. 63

Recommend


More recommend