This repository consists of code created for constructing quadtrees and performing inference on them using CUDA.
In order to generate random points, do the following -
Run python generate_points.py point_count boundary_size where point_count is the maximum number of points and boundary_size is the boundary size for the grid.
This will assume that the points will be randomly generated between (0, 0) and (boundary_size, boundary_size). The points will be output into a file points.txt
In order to construct a Quadtree with the most optimal GPU code -
- Run 
cd cuda/ - Run 
make grid_opt. This step assumes that you have a GPU connected to your system and havenvccinstalled - Run 
./grid_opt points_file_path boundary_size. For example run./grid_opt ../points.txt 1000000 - In order to run verbose mode, edit line 13 in 
kernels.cutotrueand rerun steps 2 and 3. This will show the subgrid counts at every layer (please note that this will add to the time taken for quadtree construction) 
The cuda/ directory consists of a number of different implementations of quadtree construction code and inferencing. They can be compiled using the makefile. Here are some relevant files -
create_grid_opt_v2.cu- Consists of the fastest quadtree construction algorithm with a single kernel using 2 array strategy for recursive calls. Compile usingmake grid_optcreate_grid.cu- Simpler implementation of quadtree construction using 2 kernels for categorizing and organizing. Compile usingmake gridinference.cu- Implementation of running search, insert and delete queries on the Grid structure with kernel for searching boundaries. Compile usingmake grid_inference.- To generate queries, run 
python generate_queries num_queries boundary_size, which will generate aqueries.txtfile - To run the inference, run the following - 
./grid_inference points_file boundary_size queries_file 
- To generate queries, run 
 - The code for streams and OpenMP have been implemented as 
streams_host_alloc.cu(compile withmake stream_alloc) andstreams_omp.cu(compile withmake stream_omp) files within the streams_omp branch. This work is still under development. 
The sequential/ directory consists of the code for sequential quadtree construction on CPU (without GPU). This was created mainly for benchmarking purposes and testing performance of the GPU code.
- Build scalable OpenMP based Quadtree construction
 - Quadtree construction using Dynamic Parallelism for recursive grid construction
 - Optimizing Queries by grouping based on operation and boundaries for faster performance