Top Banner
R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary Using Graphics Processing in Spatial Indexing Algorithms Mayuresh Kunjir Aditya Manthramurthy Indian Institute of Science, Bangalore November 27, 2009 1 / 22 Using Graphics Processing in Spatial Indexing Algorithms
83

Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

May 27, 2018

Download

Documents

lamkien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Using Graphics Processing in Spatial Indexing Algorithms

Mayuresh Kunjir Aditya Manthramurthy

Indian Institute of Science, Bangalore

November 27, 2009

1 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 2: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Outline

1 R-Tree basics

2 Search using CUDA

3 Visualization tool

4 Geometry Intersection

5 Summary

2 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 3: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 4: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 5: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 6: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 7: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 8: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial Indexing in Databases

The availability of detailed maps of locations has lead to a variety ofapplications that make queries on geometry. For example:

1 Which parks are in Yeshwanthpur?2 What water bodies are present in fertile areas of Karnataka?

Databases provide indexing facilities for such geometric data, usingtree structures - the most important one being the R-Tree.

R-Trees allow querying geometric objects for intersection,containment, nearest neighbours, etc.

All query operations on the R-Tree require a tree traversal thatsearches for the input geometry.

R-Trees index objects based on theMinimum Bounding Rectangle (MBR) of the geometry.

3 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 9: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An example R-Tree

4 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 10: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

How is an intersection query executed?

It takes multiple steps:

1 The MBR of the input geometry is first computed.

2 The R-Tree is searched and intersecting MBRs of geometries arefound.

3 The MBRs returned from the R-Tree undergo a full geometryintersection test.

4 All intersecting geometries are returned as output.

In this project we try to speed up this process by usingthe GPU to

parallelize R-Tree searching; andgive a hardware based geometry intersection test.

We also provide a visualizer that demonstrates theexecution of a Join query on R-Trees.

5 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 11: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

How is an intersection query executed?

It takes multiple steps:

1 The MBR of the input geometry is first computed.

2 The R-Tree is searched and intersecting MBRs of geometries arefound.

3 The MBRs returned from the R-Tree undergo a full geometryintersection test.

4 All intersecting geometries are returned as output.

In this project we try to speed up this process by usingthe GPU to

parallelize R-Tree searching; andgive a hardware based geometry intersection test.

We also provide a visualizer that demonstrates theexecution of a Join query on R-Trees.

5 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 12: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

How is an intersection query executed?

It takes multiple steps:

1 The MBR of the input geometry is first computed.

2 The R-Tree is searched and intersecting MBRs of geometries arefound.

3 The MBRs returned from the R-Tree undergo a full geometryintersection test.

4 All intersecting geometries are returned as output.

In this project we try to speed up this process by usingthe GPU to

parallelize R-Tree searching; andgive a hardware based geometry intersection test.

We also provide a visualizer that demonstrates theexecution of a Join query on R-Trees.

5 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 13: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

How is an intersection query executed?

It takes multiple steps:

1 The MBR of the input geometry is first computed.

2 The R-Tree is searched and intersecting MBRs of geometries arefound.

3 The MBRs returned from the R-Tree undergo a full geometryintersection test.

4 All intersecting geometries are returned as output.

In this project we try to speed up this process by usingthe GPU to

parallelize R-Tree searching; andgive a hardware based geometry intersection test.

We also provide a visualizer that demonstrates theexecution of a Join query on R-Trees.

5 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 14: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

How is an intersection query executed?

It takes multiple steps:

1 The MBR of the input geometry is first computed.

2 The R-Tree is searched and intersecting MBRs of geometries arefound.

3 The MBRs returned from the R-Tree undergo a full geometryintersection test.

4 All intersecting geometries are returned as output.

In this project we try to speed up this process by usingthe GPU to

parallelize R-Tree searching; andgive a hardware based geometry intersection test.

We also provide a visualizer that demonstrates theexecution of a Join query on R-Trees.

5 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 15: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 16: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 17: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 18: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 19: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 20: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

CUDA is NVidia’s general purpose GPU computing architecture.

1 C for CUDA allows us to define kernel functions that are executedby executed by multiple thread blocks.

2 A thread block is a group of threads that run independently ofother thread blocks, and can share memory.

3 Thread blocks are organised into grids for convenience.

4 Only threads in the same thread block can be synchronized.

5 Each thread has private memory and also has access to the sameglobal memory.

6 Data required for computations should be copied to the GPUmemory from RAM, and results need to copied from the GPU foroutput.

6 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 21: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

The CUDA programming model

Thread HierarchyTypes of Memory

7 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 22: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

R-Tree Representation for GPU

We use two structures to represent the R-Tree in the GPU.

1 The Coord array contains the coordinates of the MBRs of eachgeometry indexed by the tree and also of the internal nodes of thetree.

2 The Nodes array contains records that represent nodes of the tree.Each element contains an index into the Coord array and an array ofchild node indexes.

Things to note:

Second array can be large, but space used is still linear in thenumber of objects in the tree.

These arrays are created after the R-Tree has been formed in mainmemory and then transported to the GPU device.

It needs to be redone if the R-Tree changes in main memory.

8 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 23: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

R-Tree Representation for GPU

We use two structures to represent the R-Tree in the GPU.

1 The Coord array contains the coordinates of the MBRs of eachgeometry indexed by the tree and also of the internal nodes of thetree.

2 The Nodes array contains records that represent nodes of the tree.Each element contains an index into the Coord array and an array ofchild node indexes.

Things to note:

Second array can be large, but space used is still linear in thenumber of objects in the tree.

These arrays are created after the R-Tree has been formed in mainmemory and then transported to the GPU device.

It needs to be redone if the R-Tree changes in main memory.

8 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 24: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

R-Tree Representation for GPU

We use two structures to represent the R-Tree in the GPU.

1 The Coord array contains the coordinates of the MBRs of eachgeometry indexed by the tree and also of the internal nodes of thetree.

2 The Nodes array contains records that represent nodes of the tree.Each element contains an index into the Coord array and an array ofchild node indexes.

Things to note:

Second array can be large, but space used is still linear in thenumber of objects in the tree.

These arrays are created after the R-Tree has been formed in mainmemory and then transported to the GPU device.

It needs to be redone if the R-Tree changes in main memory.

8 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 25: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

R-Tree Representation for GPU

We use two structures to represent the R-Tree in the GPU.

1 The Coord array contains the coordinates of the MBRs of eachgeometry indexed by the tree and also of the internal nodes of thetree.

2 The Nodes array contains records that represent nodes of the tree.Each element contains an index into the Coord array and an array ofchild node indexes.

Things to note:

Second array can be large, but space used is still linear in thenumber of objects in the tree.

These arrays are created after the R-Tree has been formed in mainmemory and then transported to the GPU device.

It needs to be redone if the R-Tree changes in main memory.

8 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 26: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

R-Tree Representation for GPU

We use two structures to represent the R-Tree in the GPU.

1 The Coord array contains the coordinates of the MBRs of eachgeometry indexed by the tree and also of the internal nodes of thetree.

2 The Nodes array contains records that represent nodes of the tree.Each element contains an index into the Coord array and an array ofchild node indexes.

Things to note:

Second array can be large, but space used is still linear in thenumber of objects in the tree.

These arrays are created after the R-Tree has been formed in mainmemory and then transported to the GPU device.

It needs to be redone if the R-Tree changes in main memory.

8 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 27: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Parallel R-Tree Search algorithm1

(this algorithm differs significantly from the reference)

1 Threads copy tree representation into shared memory if it is smallenough.

2 Threads next declare two more shared bit-arrays, currentSearch andnextSearch, which represent the nodes being searched.

3 The bit corresponding to the root is set in currentSearch, andnextSearch is cleared.

Threads simultaneously manipulate different array entries, so nolocking is necessary - done using the unique ids of threads.

1Xiao X., Shi T., Vaidya P., Lee J., R-Tree: A Hardware Implementation, In2008, 3-9. Proc. of International Conf. on Computer Design.

9 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 28: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Parallel R-Tree Search algorithm1

(this algorithm differs significantly from the reference)

1 Threads copy tree representation into shared memory if it is smallenough.

2 Threads next declare two more shared bit-arrays, currentSearch andnextSearch, which represent the nodes being searched.

3 The bit corresponding to the root is set in currentSearch, andnextSearch is cleared.

Threads simultaneously manipulate different array entries, so nolocking is necessary - done using the unique ids of threads.

1Xiao X., Shi T., Vaidya P., Lee J., R-Tree: A Hardware Implementation, In2008, 3-9. Proc. of International Conf. on Computer Design.

9 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 29: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Parallel R-Tree Search algorithm1

(this algorithm differs significantly from the reference)

1 Threads copy tree representation into shared memory if it is smallenough.

2 Threads next declare two more shared bit-arrays, currentSearch andnextSearch, which represent the nodes being searched.

3 The bit corresponding to the root is set in currentSearch, andnextSearch is cleared.

Threads simultaneously manipulate different array entries, so nolocking is necessary - done using the unique ids of threads.

1Xiao X., Shi T., Vaidya P., Lee J., R-Tree: A Hardware Implementation, In2008, 3-9. Proc. of International Conf. on Computer Design.

9 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 30: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Parallel R-Tree Search algorithm1

(this algorithm differs significantly from the reference)

1 Threads copy tree representation into shared memory if it is smallenough.

2 Threads next declare two more shared bit-arrays, currentSearch andnextSearch, which represent the nodes being searched.

3 The bit corresponding to the root is set in currentSearch, andnextSearch is cleared.

Threads simultaneously manipulate different array entries, so nolocking is necessary - done using the unique ids of threads.

1Xiao X., Shi T., Vaidya P., Lee J., R-Tree: A Hardware Implementation, In2008, 3-9. Proc. of International Conf. on Computer Design.

9 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 31: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Main loop of the algorithm

The following is the main loop and is executed until (currentSearch= 0):

1 Clear the nextSearch array (in parallel). SyncThreads.

2 For each bit i in currentSearch that is set:

1 For each child j of node i (looked up from Node), that overlaps thequery MBR,

1 If j is a leaf, mark it as part of the output.2 If j is not a leaf, mark it in nextSearch.

3 SyncThreads.

4 Copy nextSearch into currentSearch (in parallel). SyncThreads.

The output is finally copied to main memory.This algorithm uses linear space, as opposed to quadratic spaceused by the referenced paper.

10 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 32: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Main loop of the algorithm

The following is the main loop and is executed until (currentSearch= 0):

1 Clear the nextSearch array (in parallel). SyncThreads.

2 For each bit i in currentSearch that is set:

1 For each child j of node i (looked up from Node), that overlaps thequery MBR,

1 If j is a leaf, mark it as part of the output.2 If j is not a leaf, mark it in nextSearch.

3 SyncThreads.

4 Copy nextSearch into currentSearch (in parallel). SyncThreads.

The output is finally copied to main memory.This algorithm uses linear space, as opposed to quadratic spaceused by the referenced paper.

10 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 33: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Main loop of the algorithm

The following is the main loop and is executed until (currentSearch= 0):

1 Clear the nextSearch array (in parallel). SyncThreads.

2 For each bit i in currentSearch that is set:

1 For each child j of node i (looked up from Node), that overlaps thequery MBR,

1 If j is a leaf, mark it as part of the output.2 If j is not a leaf, mark it in nextSearch.

3 SyncThreads.

4 Copy nextSearch into currentSearch (in parallel). SyncThreads.

The output is finally copied to main memory.This algorithm uses linear space, as opposed to quadratic spaceused by the referenced paper.

10 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 34: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 35: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 36: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 37: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 38: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 39: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Observations about the algorithm

Because of the sync instructions, the threads must belong to thesame thread block.

Thus, only one thread block is in use on the GPU. This isunder-utilising the GPU, but there seems to be no other way.

Each thread executes N/C iterations in each iteration of the mainloop, where N is the number of geometries in the tree, and C is thenumber of threads.

This means that as the number of threads in a thread blockincreases, the algorithm does better.

The output is returned in the form of a bitmap, where a set bitcorresponds to an intersecting geometry. Transferring this to mainmemory can be slow.

We implemented this algorithm using a standalone R-Tree libraryand tested the CUDA part separately. We do not have aperformance comparison now.

11 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 40: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 41: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 42: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 43: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 44: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 45: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Spatial index for joins

Nested loop compares all the pairs of geometries.

R-Tree index provides a cheaper way.

MBRs of the geometries are checked for overlap using index first.

temp=#explain select * from land, hydrology where ST_Intersects(land.the_geom, hydrology.the_geom);

QUERY PLAN

-------------------------------------------------------------------------------------------

Nested Loop (cost=0.00..30.17 rows=1 width=1559)

Join Filter: _st_intersects(land.the_geom, hydrology.the_geom)

-> Seq Scan on hydrology (cost=0.00..1.04 rows=4 width=672)

-> Index Scan using assets_land_idx_the_geom on land (cost=0.00..7.27 rows=1 width=887)

Index Cond: (land.the_geom && hydrology.the_geom)

(5 rows)

How about visualizing the working of this query?

12 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 46: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Flow diagram

13 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 47: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 48: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 49: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 50: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 51: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 52: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Easy part

The input relations are read from files generated by simplyprojecting the geometry column from the database table.

The input files are parsed and the geometries are stored in thestructures. (Only polygons are considered)

The polygons are rendered by doing tessellation first.

The log file is read line-by-line. (in fact two lines at a time)

First line tells whether we are dealing with geometries or MBRs ofinternal node or leaf node of the index.Second line gives the location of geometries/MBRs and the result ofintersection

e.g. 0 257643.73 896902.56 257843.34 897113.25 252280 898880 254100 899740 0

<Sr. No.> <MBR of first geometry(x1 y1 x2 y2)> <MBR of second geometry(x1 y1 x2 y2)> <result

of intersection (0:no intersection and 1:intersection)>

Accordingly geometries/MBRs are highlighted.

14 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 53: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 54: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 55: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 56: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 57: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 58: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation: Tough part

Where is the log file coming from?

We are running the queries on PostgreSQL database engine.

The PostGISextension provides the support for the spatialoperations.

The index processing has about 1,500 lines of code from where weget the debug information to put into log.

For actual geometry intersections, PostGIS uses functions providedby GEOSlibrary.

This part has about 10,000 lines of PostGIS code and 1,000 lines ofGEOS code to get the information from.

15 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 59: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Geometry intersection in PostGIS

16 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 60: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Intersection test using graphics2

Set gray color and enable blending.

Draw the given two polygons on screen.

Read the framebuffer and check formaximum color value.

If white color is found as maximum value,the polygons intersect.

2[Sun, Agrawal, Abbadi], Hardware Acceleration for Spatial Selection andJoin, In Proceedings of the 2003 ACM SIGMOD Intl. Conf. on Management ofData.

17 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 61: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Intersection test using graphics2

Set gray color and enable blending.

Draw the given two polygons on screen.

Read the framebuffer and check formaximum color value.

If white color is found as maximum value,the polygons intersect.

2[Sun, Agrawal, Abbadi], Hardware Acceleration for Spatial Selection andJoin, In Proceedings of the 2003 ACM SIGMOD Intl. Conf. on Management ofData.

17 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 62: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Intersection test using graphics2

Set gray color and enable blending.

Draw the given two polygons on screen.

Read the framebuffer and check formaximum color value.

If white color is found as maximum value,the polygons intersect.

2[Sun, Agrawal, Abbadi], Hardware Acceleration for Spatial Selection andJoin, In Proceedings of the 2003 ACM SIGMOD Intl. Conf. on Management ofData.

17 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 63: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Intersection test using graphics2

Set gray color and enable blending.

Draw the given two polygons on screen.

Read the framebuffer and check formaximum color value.

If white color is found as maximum value,the polygons intersect.

2[Sun, Agrawal, Abbadi], Hardware Acceleration for Spatial Selection andJoin, In Proceedings of the 2003 ACM SIGMOD Intl. Conf. on Management ofData.

17 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 64: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Intersection test using graphics2

Set gray color and enable blending.

Draw the given two polygons on screen.

Read the framebuffer and check formaximum color value.

If white color is found as maximum value,the polygons intersect.

2[Sun, Agrawal, Abbadi], Hardware Acceleration for Spatial Selection andJoin, In Proceedings of the 2003 ACM SIGMOD Intl. Conf. on Management ofData.

17 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 65: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An improvement

We may not identify some intersections if intersecting region is verysmall compared to the total region occupied by the polygons.

But we don’t need to render the polygons completely.

Intersection can only happen in the region where MBRs overlap, sowe only render the overlapping region of the MBRs.

Still we can’t guarantee finding every intersection. Therecan be some situations like one shown in figure.

18 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 66: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An improvement

We may not identify some intersections if intersecting region is verysmall compared to the total region occupied by the polygons.

But we don’t need to render the polygons completely.

Intersection can only happen in the region where MBRs overlap, sowe only render the overlapping region of the MBRs.

Still we can’t guarantee finding every intersection. Therecan be some situations like one shown in figure.

18 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 67: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An improvement

We may not identify some intersections if intersecting region is verysmall compared to the total region occupied by the polygons.

But we don’t need to render the polygons completely.

Intersection can only happen in the region where MBRs overlap, sowe only render the overlapping region of the MBRs.

Still we can’t guarantee finding every intersection. Therecan be some situations like one shown in figure.

18 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 68: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An improvement

We may not identify some intersections if intersecting region is verysmall compared to the total region occupied by the polygons.

But we don’t need to render the polygons completely.

Intersection can only happen in the region where MBRs overlap, sowe only render the overlapping region of the MBRs.

Still we can’t guarantee finding every intersection. Therecan be some situations like one shown in figure.

18 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 69: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

An improvement

We may not identify some intersections if intersecting region is verysmall compared to the total region occupied by the polygons.

But we don’t need to render the polygons completely.

Intersection can only happen in the region where MBRs overlap, sowe only render the overlapping region of the MBRs.

Still we can’t guarantee finding every intersection. Therecan be some situations like one shown in figure.

18 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 70: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation

We do off-screen rendering of the polygons using pbuffers.

The window context with X server is set using GLX window systeminterface.

The code to set context is put in PostmasterMain()routine andresource freeing is done in ExitPostmaster()3

The intersection test is implemented in PostGIS, in intersects()routine of file lwgeom geos.c.

The overlapping region of MBRs is mapped to the window.After drawing the geometries, we read the pixel buffer and check formaximum value using glGetMinmax()function.

3PostmasterMain() is the main entry point of PostgreSQL whileExitPostmaster() is called when server exits.

19 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 71: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation

We do off-screen rendering of the polygons using pbuffers.

The window context with X server is set using GLX window systeminterface.

The code to set context is put in PostmasterMain()routine andresource freeing is done in ExitPostmaster()3

The intersection test is implemented in PostGIS, in intersects()routine of file lwgeom geos.c.

The overlapping region of MBRs is mapped to the window.After drawing the geometries, we read the pixel buffer and check formaximum value using glGetMinmax()function.

3PostmasterMain() is the main entry point of PostgreSQL whileExitPostmaster() is called when server exits.

19 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 72: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation

We do off-screen rendering of the polygons using pbuffers.

The window context with X server is set using GLX window systeminterface.

The code to set context is put in PostmasterMain()routine andresource freeing is done in ExitPostmaster()3

The intersection test is implemented in PostGIS, in intersects()routine of file lwgeom geos.c.

The overlapping region of MBRs is mapped to the window.After drawing the geometries, we read the pixel buffer and check formaximum value using glGetMinmax()function.

3PostmasterMain() is the main entry point of PostgreSQL whileExitPostmaster() is called when server exits.

19 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 73: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation

We do off-screen rendering of the polygons using pbuffers.

The window context with X server is set using GLX window systeminterface.

The code to set context is put in PostmasterMain()routine andresource freeing is done in ExitPostmaster()3

The intersection test is implemented in PostGIS, in intersects()routine of file lwgeom geos.c.

The overlapping region of MBRs is mapped to the window.After drawing the geometries, we read the pixel buffer and check formaximum value using glGetMinmax()function.

3PostmasterMain() is the main entry point of PostgreSQL whileExitPostmaster() is called when server exits.

19 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 74: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Implementation

We do off-screen rendering of the polygons using pbuffers.

The window context with X server is set using GLX window systeminterface.

The code to set context is put in PostmasterMain()routine andresource freeing is done in ExitPostmaster()3

The intersection test is implemented in PostGIS, in intersects()routine of file lwgeom geos.c.

The overlapping region of MBRs is mapped to the window.After drawing the geometries, we read the pixel buffer and check formaximum value using glGetMinmax()function.

3PostmasterMain() is the main entry point of PostgreSQL whileExitPostmaster() is called when server exits.

19 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 75: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

ResultsWe didn’t get any improvement in performance by adding thisintersection test.4

Q1(time in ms) Q2(time in ms) Q3(time in ms)without graphics test 31 44 668with graphics test 1261 189 3824

The bottleneck is in reading the pixel buffer which involves transferof data from GPU memory to main memory.

4The experiments were carried out on the data taken from “National Atlasof the United States”

20 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 76: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 77: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 78: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 79: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 80: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 81: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 82: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Conclusion and future work

A linear space parallelized R-Tree search algorithm is implementedusing CUDA.

A visualization tool is developed to show the working of R-Tree injoin processing.

A hardware intersection test in implemented in PostgreSQLdatabase but we didn’t get any improvements in performance.

The hardware intersection test can be easily extended to handleother spatial queries like containment in future.

We would like to use CUDA to write method to find maximum colorvalue from pixel buffer without having to transfer the whole buffer.

The R-Tree search algorithm using CUDA could be implemented inPostgreSQL and its performance analysed.

21 / 22

Using Graphics Processing in Spatial Indexing Algorithms

Page 83: Using Graphics Processing in Spatial Indexing …dsl.cds.iisc.ac.in/~mayuresh/graphics_presentation.pdfUsing Graphics Processing in Spatial Indexing Algorithms ... execution of a Join

R-Tree basics Search using CUDA Visualization tool Geometry Intersection Summary

Thank you!

22 / 22

Using Graphics Processing in Spatial Indexing Algorithms