Introduction
Nearest neighbor (NN) search is a fundamental operation in data science, underpinning critical tasks such as classification, outlier detection, and manifold learning. As datasets grow into the millions and billions of points, the computational demand for efficient NN search has escalated. While $k$-d trees have long been the standard for accelerating these searches on CPUs, their implementation on Graphics Processing Units (GPUs) has historically faced significant hurdles. This paper presents the "Bigger Buffer" $k$-d tree, an evolved architecture designed to overcome memory limitations and hardware inefficiencies, enabling high-performance NN search on massive datasets across multi-GPU systems.
The Challenge of GPU-based k-d Trees
The primary obstacle to efficient $k$-d tree traversal on GPUs is "branch divergence." In a standard tree search, different threads within the same GPU warp often follow different paths down the tree based on the spatial properties of their specific query points. Because GPUs are SIMD (Single Instruction, Multiple Data) architectures, this divergence forces the hardware to serialize execution paths, drastically reducing throughput.
To mitigate this, previous research introduced the buffer $k$-d tree. This approach delays the processing of queries by grouping them into buffers at the leaf level. Once a buffer is full, the GPU performs a "brute-force" batch search on that specific leaf's data. This ensures that all threads in a warp perform the same calculations on the same data chunk, maximizing hardware utilization. However, the original buffer $k$-d tree required the entire dataset (the leaf structure) to reside in the GPU's Video RAM (VRAM). Given that VRAM is often an order of magnitude smaller than system RAM, this created a "memory wall" that limited the size of datasets the GPU could process.
The Bigger Buffer k-d Tree Architecture
The "Bigger Buffer" $k$-d tree addresses the memory wall by decoupling the tree structure from the leaf data. The authors propose a hybrid storage and execution model that allows the system to process datasets far exceeding the capacity of a single GPU's memory.
Hybrid Storage and Chunking
The architecture recognizes that the "top" of a $k$-d tree—the internal nodes used for routing queries—is remarkably small. Even for a dataset of one billion points, a tree of height 20 requires less than 10MB of memory. Consequently, the decision-making portion of the tree can always reside on the GPU. The massive leaf structure, containing the actual data points, is stored in the much larger host (CPU) memory or potentially on disk. This leaf structure is then divided into $N$ manageable chunks.
Pipelining and Double Buffering
Moving data from host memory to the GPU over the PCIe bus is a notorious bottleneck. To prevent the GPU from sitting idle during these transfers, the authors implement a "compute-and-copy" pipelining strategy using double buffering. While the GPU is performing the brute-force NN search on Chunk A, the system simultaneously streams Chunk B from the host memory to a second device buffer. The intensive nature of the leaf-level computation is sufficient to completely mask the PCIe transfer latency, ensuring the GPU remains at near-100% utilization.
Multi-GPU Parallelism
The system is designed to scale across multiple many-core devices within a single workstation. By splitting the query set into large batches and distributing them across available GPUs, the architecture achieves independent processing. Each GPU maintains its own top-tree and manages its own double-buffering pipeline, allowing the system to leverage the aggregate compute power and memory bandwidth of the entire workstation.
Experimental Evaluation
Datasets
The researchers evaluated the system using high-dimensional astronomical data from the Sloan Digital Sky Survey (SDSS) and the Catalina Realtime Transient Survey (CRTS). These datasets are characterized by their scale and dimensionality:
- SDSS-based sets:
psf_mag,psd_model_mag, andall_mag, with dimensions ranging from $d=5$ to $d=15$. - CRTS: A dataset comprising 30 million light-curves. The authors extracted 10 statistical features from these curves to perform large-scale outlier detection.
Performance and Scaling
The experimental results demonstrated three key findings:
- Negligible Chunking Overhead: The performance ratio between the "chunked" approach (data on host) and the "original" approach (data on GPU) was nearly 1.0, proving that the pipelining strategy effectively hides data transfer costs.
- Linear Speedup: The system exhibited near-linear scaling with additional hardware. Utilizing four GPUs on an NVIDIA Titan Z provided a speedup of nearly 4x compared to a single-GPU execution.
- High Throughput: The system successfully executed "all nearest neighbor" queries for the 30-million-point CRTS dataset in a timeframe that would be unfeasible for standard CPU-based $k$-d trees or naive GPU implementations.
Conclusion and Future Work
The Bigger Buffer $k$-d tree provides a robust solution for large-scale nearest neighbor searches, effectively bypassing the VRAM limitations of modern GPUs. By combining leaf-level buffering with a sophisticated pipelining strategy, the authors have created a system that scales both with dataset size and the number of available many-core devices.
While highly effective for moderate dimensions ($d < 30$), the method still faces the "curse of dimensionality" inherent to all $k$-d tree structures. Future work may explore the impact of direct disk-to-GPU streaming for datasets that exceed host RAM, as well as optimizing the tree construction phase, which currently remains a CPU-bound process.
Summary updated