Abstract
Algorithms for processing large-scale spatial datasets are of significant interest in both scientific research and industrial applications. The efficient implementation of such algorithms is crucial for modern data-intensive systems, and GPU-based parallel processing has emerged as a particularly effective approach for accelerating spatial queries. Among these, computing the k closest pairs (k-CP) between large spatial datasets is a fundamental problem with applications in spatial data analysis, geographic information systems, and data mining. This paper presents an exact GPU-based framework for processing k-CP queries in both two- and three-dimensional spaces, including variants capable of processing datasets that exceed the available GPU memory capacity. Starting from a baseline brute-force CUDA implementation, we develop memory-aware partitioning strategies and adapt DSPP-based spatial pruning to reduce unnecessary distance computations in the global k-CP problem. Furthermore, we incorporate several performance optimizations, including pinned memory and concurrent kernel execution, to overlap data transfers with computation and improve scalability. Experimental evaluation using both synthetic and real-world datasets demonstrates that the proposed methods substantially outperform baseline approaches. In particular, the DSPP + PEA variant employing a max-heap buffer generally achieves the best overall performance, especially for large datasets and higher values of k, highlighting its effectiveness and scalability for large-scale spatial query processing.
1. Introduction
Spatial proximity queries constitute one of the fundamental operations in Geographic Information Systems (GISs), spatial databases, scientific computing, and numerous data-intensive applications. They enable the discovery of relationships among spatial objects and support a wide range of analytical tasks, including nearest-neighbor search, clustering, similarity analysis, route planning, spatial joins, environmental monitoring, and spatial data mining. As the availability of spatial information continues to grow through satellite imagery, sensor networks, mobile devices, autonomous vehicles, and Internet of Things (IoT) infrastructures, efficient processing of large-scale spatial datasets has become increasingly important. The volume of modern spatial data often reaches hundreds of millions or even billions of objects, making traditional sequential algorithms computationally impractical.
Among spatial proximity operations, the k-Closest Pairs (k-CP) query represents a fundamental problem that consists of identifying the k pairs of objects with the smallest distances between two datasets. Unlike classical nearest-neighbor queries, which determine the nearest objects for each individual query point, the k-CP problem seeks the globally closest pairs across two entire datasets. The problem was studied for spatial database systems by Corral et al. [1,2] through efficient algorithms for processing k-Closest-Pairs queries using spatial access methods and branch-and-bound techniques. Since then, the k-CP query has become an important building block for numerous higher-level spatial algorithms and applications requiring the discovery of the strongest spatial relationships between spatial objects.
The importance of efficient k-CP processing extends across numerous scientific and industrial domains. In Geographic Information Systems (GISs), proximity queries support spatial analysis, map matching, land-use planning, and environmental monitoring, forming a fundamental component of modern spatial analysis workflows [3,4]. Modern location-based services continuously process large volumes of geographic data to identify nearby users, vehicles, facilities, and other points of interest in dynamic environments [5]. Transportation and mobility applications similarly rely on proximity computations to associate users, vehicles, and nearby services while supporting time-sensitive decision making.
Beyond traditional GIS applications, large-scale proximity and similarity computations are also relevant to scientific data analysis. Astronomical surveys generate enormous collections of celestial objects whose spatial relationships and temporal observations must be analyzed at increasingly large scales, creating substantial computational challenges for scientific data processing [6]. In genomics and bioinformatics, increasingly large collections of genetic data require scalable computational infrastructures for large-scale genomic analysis [7]. Machine learning and data mining also employ proximity and similarity computations in tasks such as clustering, similarity search, and exploratory analysis of high-dimensional datasets. Similarity-based methods have also been applied to the analysis and prediction of social attributes and user-related information [8].
As these applications continue to generate increasingly large datasets, the computational cost of exact proximity search rapidly becomes a limiting factor. Given two datasets containing m and n objects, a straightforward brute-force solution requires the evaluation of pairwise distances, resulting in quadratic time complexity. Although spatial indexing structures and approximation techniques can reduce the computational cost in many cases, their effectiveness depends on the characteristics of the underlying data and the requirements of the application. In numerous scientific and engineering domains, exact results remain essential, making scalable algorithms for exact proximity search increasingly important as dataset sizes continue to grow.
Graphics Processing Units (GPUs) have emerged as one of the most effective hardware platforms for accelerating computationally intensive spatial algorithms. Modern GPUs contain thousands of processing cores capable of executing millions of arithmetic operations concurrently, making them particularly suitable for data-parallel computations such as pairwise distance evaluation. Furthermore, their high memory bandwidth allows significantly higher throughput than conventional multicore CPUs when memory access patterns are carefully optimized.
Despite these advantages, efficiently exploiting GPU architectures for exact k-CP processing remains a challenging task. Unlike CPU implementations, GPU applications must explicitly manage data movement between host and device memory while simultaneously maximizing computational throughput. Modern spatial datasets frequently exceed the available GPU memory capacity, requiring repeated partitioning and host–device transfers during execution. Unless these transfers are carefully coordinated, communication overhead may dominate the overall execution time and negate the computational advantages offered by GPU parallelism.
Another important challenge arises from the irregular nature of spatial data. Efficient GPU execution depends heavily on regular memory-access patterns, balanced workloads, and the minimization of unnecessary computations. However, spatial datasets often exhibit highly non-uniform point distributions, leading to load imbalance and inefficient memory utilization. Consequently, high-performance GPU algorithms must combine scalable memory management strategies with algorithmic techniques capable of eliminating redundant distance computations while maintaining exact query results.
For these reasons, scalable GPU implementations of the k-CP problem require considerably more than simply parallelizing a brute-force algorithm. Efficient solutions must carefully integrate algorithmic optimizations, memory-aware partitioning strategies, and GPU-specific programming techniques in order to fully exploit the available computational resources while remaining applicable to datasets that are substantially larger than the available device memory.
1.1. Related Work
The efficient processing of proximity queries has received considerable attention in computational geometry, spatial databases, machine learning, and high-performance computing. As the size of spatial and multidimensional datasets has increased, Graphics Processing Units (GPUs) have become an attractive platform for accelerating proximity search because of their massive parallelism and high memory bandwidth. Existing GPU-based approaches can be broadly divided into exact and approximate methods. Although most published work addresses the k-Nearest Neighbors (kNN) problem, many of the underlying algorithmic principles are equally relevant to the exact k-CP query considered in this paper.
1.1.1. Exact GPU Algorithms for Closest-Pair and Nearest-Neighbor Search
One of the earliest GPU approaches closely related to the present work is the closest-pair algorithm presented in [9]. The proposed method combines CPU and GPU computation and employs spatial subdivision to eliminate unnecessary distance calculations. Although it focuses on identifying a single closest pair rather than the global k-CP query, it demonstrates that exploiting spatial locality can significantly reduce computational cost while preserving exactness.
Among the existing literature, the work most closely related to the present study is that of Velentzas et al. [10], which investigates exact GPU implementations of the k-nearest-neighbor problem for low-dimensional spatial datasets. Starting from a brute-force implementation, the authors progressively introduce partitioning strategies for datasets exceeding GPU memory capacity, spatial subdivision techniques that reduce unnecessary distance calculations, and CUDA-specific optimizations based on pinned memory and concurrent kernel execution. They further compare two alternative data structures for maintaining the nearest neighbors during execution, namely a distance-list buffer and a max-heap implementation. Since the kNN and k-CP problems share several computational characteristics, the partitioning and GPU-execution principles investigated in [10] provide an important foundation for the present work. However, the two queries have fundamentally different objectives: kNN determines a set of nearest neighbours for each query point, whereas k-CP requires the identification of the globally closest cross-dataset pairs. Consequently, the candidate maintenance and result aggregation procedures must be reformulated, and the applicability and effectiveness of DSPP-based pruning must be established for the global k-CP problem. The present study therefore adapts and extends these principles to exact GPU-based k-CP processing and systematically evaluates their performance under the different computational characteristics of the k-CP query.
Another closely related study is presented in [11], where the exact kNN Join Query (kNNJQ) is processed using a hybrid CPU–GPU implementation. That work demonstrates that, particularly for low-dimensional data, GPU acceleration alone is insufficient to outperform highly optimized multicore CPU implementations. Instead, performance depends on the careful combination of algorithmic optimizations, workload balancing, and efficient memory management.
Beyond these studies, numerous exact GPU algorithms have been proposed for nearest-neighbor search. Matrix-based formulations have proven particularly effective by expressing distance computation as dense linear algebra operations executed on the GPU, followed by efficient parallel selection of the nearest neighbors [12,13,14]. Alternative implementations employ OpenCL and other parallel programming frameworks while maintaining the same exhaustive-search philosophy [15]. Other work has focused on improving scalability through partitioning strategies that enable datasets larger than GPU memory to be processed efficiently [16,17]. Additional improvements have been achieved through pruning techniques based on the triangle inequality [18], spatial grid structures [19], efficient GPU top-k selection algorithms [20,21], and optimized similarity-search libraries such as FAISS [22,23]. Collectively, these studies demonstrate that substantial performance gains can be obtained through a combination of algorithmic improvements, efficient memory management, and careful exploitation of GPU hardware.
Although efficient CPU algorithms for k-Closest-Pairs query processing have been available for many years [1,2], comparatively little research has addressed exact GPU implementations of the problem. Most existing GPU algorithms focus instead on nearest-neighbor search or approximate similarity queries. Consequently, scalable GPU algorithms specifically designed for exact k-Closest-Pairs processing remain largely unexplored.
Although nearest-neighbor search and k-CP queries have received considerably more attention than GPU spatial joins, both classes of problems share common optimization principles based on spatial partitioning and candidate pruning. Consequently, advances in GPU spatial join processing provide valuable insights for the development of scalable exact k-CP algorithms.
1.1.2. GPU Algorithms for Spatial Join Processing
Spatial join processing constitutes another important class of spatial queries that is closely related to the k-CP problem. Whereas the k-CP query identifies the globally closest object pairs between two datasets, spatial joins retrieve all pairs satisfying a specified spatial relationship, such as intersection, containment, overlap, or proximity. Although the objectives differ, both problems share important computational challenges, including efficient candidate-pair generation, spatial partitioning, pruning of unnecessary comparisons, and scalable processing of large spatial datasets.
GPU-based spatial join processing has attracted increasing attention during the last decade. Early work by You et al. proposed GPU implementations based on R-tree indexes for accelerating spatial query processing on large datasets [24]. Subsequently, point-in-polygon spatial joins were accelerated through data-parallel GPU algorithms that exploited spatial partitioning and massive thread-level parallelism [25]. These ideas were later extended to support more general spatial joins on complex polygon datasets through parallel quadtree indexing and efficient filtering strategies [26]. Additional studies investigated GPU-based spatial joins for polylines [27] and proposed GPU-oriented selectivity estimation techniques that optimize multidimensional spatial join processing by selecting appropriate partitioning granularities before query execution [28].
The common characteristic of these approaches is the use of spatial partitioning to reduce the number of candidate object pairs requiring geometric evaluation. This principle is closely related to the Disk Symmetric Progression Partitioning (DSPP) strategy adopted and adapted for the exact k-CP problem in the present work. However, the algorithmic objectives differ substantially. Spatial join algorithms evaluate all object pairs satisfying a spatial predicate, whereas the exact k-CP query continuously maintains the globally closest pairs while dynamically updating the current distance threshold during execution. Consequently, the candidate-list maintenance, pruning strategy, and memory management requirements differ significantly from those encountered in spatial join processing.
The relationship between these two classes of spatial queries nevertheless demonstrates that spatial subdivision and workload partitioning constitute effective optimization strategies for large-scale GPU spatial processing. The algorithms proposed in this paper build upon these general principles while introducing specialized techniques for the exact k-CP query on datasets that may substantially exceed the available GPU memory.
1.1.3. Approximate GPU Algorithms for Nearest-Neighbor Search
Approximate nearest-neighbor (ANN) algorithms reduce computational complexity by trading a small loss in accuracy for substantially improved scalability. These methods have become particularly attractive for applications involving very large datasets where response time is more critical than exactness.
Graph-based techniques constitute one of the most successful families of ANN algorithms. Instead of exhaustively evaluating all candidate pairs, these methods construct proximity graphs that guide the search toward promising candidates while examining only a small fraction of the dataset. Recent GPU implementations exploit warp-level primitives, efficient graph traversal, and compressed graph representations, achieving excellent performance even for billion-scale datasets [29,30,31].
Hybrid CPU–GPU approaches have also been proposed for billion-scale similarity search. These methods combine compressed vector representations on the GPU with refinement stages executed on the CPU, thereby reducing GPU memory requirements while maintaining high retrieval accuracy [32,33]. Other approaches employ Locality Sensitive Hashing (LSH) to partition the search space and rapidly identify candidate neighbors without exhaustive distance evaluation [34,35]. More recently, GPU ray-tracing hardware has been exploited to accelerate nearest-neighbor search under different distance metrics [36,37].
Although approximate methods achieve excellent performance, they are unsuitable for applications requiring guaranteed exact results. Scientific computing, engineering applications, and many GIS workflows require exact proximity relationships, making exact GPU algorithms indispensable despite their higher computational cost.
1.1.4. Research Gap
The existing literature clearly demonstrates the effectiveness of GPUs for accelerating proximity search. Nevertheless, two important limitations remain. First, the overwhelming majority of published work addresses the classical k-nearest-neighbor problem rather than the exact k-CP query considered here. Although many optimization techniques developed for kNN can be adapted to related problems, identifying the globally closest pairs between two datasets introduces different computational characteristics and optimization opportunities. The distinction is not merely terminological. Conventional kNN methods typically determine neighbours for individual query points, whereas the k-CP problem requires identifying the globally closest cross-dataset pairs. Furthermore, approximate nearest-neighbour methods deliberately trade exactness for efficiency. Exactness is not assumed to be necessary for every application; when an application can tolerate approximation, approximate methods may provide an appropriate alternative. In the present study, however, exact global k-CP processing is deliberately adopted as the problem requirement. This ensures that the reported result is the true set of the globally closest cross-dataset pairs and allows the proposed pruning mechanism to be evaluated without introducing an additional approximation error. Consequently, approximate nearest-neighbour methods do not constitute directly equivalent baselines for evaluating the exact k-CP problem. A comparison based solely on execution time would therefore not account for the fundamental difference in result accuracy between exact and approximate approaches. This distinction is also important with respect to existing DSPP-based GPU processing. Although DSPP has previously been investigated for kNN queries [10], its application to k-CP is not straightforward because the objective changes from maintaining independent nearest-neighbour lists for individual query points to identifying a globally ranked set of closest cross-dataset pairs.
Second, scalability remains a significant challenge. Numerous GPU implementations assume that one or both datasets fit entirely in device memory or incur substantial communication overhead when processing large datasets through repeated partitioning. As modern spatial datasets continue to increase in size, host–device communication increasingly becomes a dominant performance bottleneck.
Motivated by these observations, this work develops GPU algorithms specifically designed for exact k-CP processing on very large spatial datasets. The proposed approach combines scalable partitioning strategies with a spatial subdivision technique based on Disk Symmetric Progression Partitioning (DSPP), while further exploiting pinned memory and concurrent kernel execution to reduce communication overhead. Unlike approximate methods, the proposed algorithms preserve exact query results while remaining applicable to datasets that substantially exceed the available GPU memory capacity. Spatial subdivision itself is not the novelty claimed in this work. The contribution of DSPP lies in its use as a lightweight, partition-local pruning mechanism for exact GPU-based k-CP processing. Points within a reference-data partition are ordered along the x-axis and grouped into ordered sub-partitions represented by compact boundary information. A GPU thread progressively examines the relevant regions and terminates traversal when the coordinate-based lower bound exceeds the current candidate threshold. This mechanism differs from a general-purpose spatial index because it is specifically designed to integrate pruning with partitioned, massively parallel exact k-CP processing.
1.2. Contributions of This Study
This study addresses the exact processing of the k-CP query on spatial datasets whose size may exceed the available GPU memory. The central challenge is to reduce the large number of pairwise distance evaluations while preserving exact results and maintaining efficient execution on GPU architectures.
The main contribution is the development and evaluation of an exact GPU-based framework for the global k-CP query. The framework adapts DSPP-based spatial pruning principles previously investigated for kNN processing to the different requirements of global closest-pair computation and combines them with mechanisms required for scalable processing of datasets that may exceed GPU memory. DSPP spatially orders each reference-data partition, divides it into ordered sub-partitions, and progressively examines only those regions that may improve the current candidate list. The traversal is terminated using a coordinate-based lower bound and the current candidate threshold, thereby avoiding unnecessary distance computations without introducing approximation.
Building on this mechanism, the study investigates how exact k-CP processing can be scaled to datasets exceeding GPU memory through partitioning of the input data and how GPU-oriented communication and execution optimizations can further improve performance.
The main contributions are:
- An exact GPU-based framework for processing k-CP queries on datasets that may exceed the available GPU memory.
- An adaptation of DSPP-based spatial pruning to global k-CP processing, exploiting ordered sub-partitions and coordinate-based lower bounds to avoid distance computations that cannot affect the final result.
- A formal correctness argument for the DSPP pruning condition, showing that the coordinate-based lower bound is valid for the Minkowski distance family.
- A scalable partitioning strategy that enables exact processing when the input datasets cannot simultaneously reside in GPU memory.
- An experimental analysis of GPU-oriented optimizations, including communication overlap, enhanced thread assignment, and candidate-list organization, identifying the combinations that provide the best performance for different dataset sizes and values of k.
- An extensive evaluation on synthetic and real-world spatial datasets, demonstrating scalability and quantifying the performance benefits of the proposed algorithmic components.
1.3. Organization of the Paper
The remainder of this paper is organized as follows. Section 2 formally defines the k-CP problem, discusses the GPU execution considerations relevant to the proposed methods, and presents the algorithmic variants. Section 3 presents the experimental methodology together with the performance evaluation on both synthetic and real datasets. The obtained results are discussed in Section 4, where the behaviour of the different algorithmic variants is analysed and compared. Finally, Section 5 summarizes the main conclusions of the study and outlines directions for future research.
2. Materials and Methods
This section presents the methodology developed for the exact processing of the k-CP (k-CP) query on Graphics Processing Units (GPUs). It begins by formally defining the problem addressed in this study and briefly reviewing the GPU concepts that influence the design of the proposed algorithms. The baseline implementations are then presented, followed by the progressively optimized algorithmic variants. Finally, the implementation details, experimental setup, and software environment used in the experimental evaluation are described.
2.1. Problem Definition
The objective of this work is to solve the exact k-Closest Pairs (k-CP) problem, which consists of identifying the k pairs of points with the smallest distances between two input datasets. Let and denote two point sets containing m and n points, respectively. The points may be represented in an arbitrary number of dimensions.
The Euclidean distance is used as the similarity measure in the current implementation and experimental evaluation. For two d-dimensional points p and q, it is defined as
More generally, the Euclidean distance is a member of the Minkowski distance family. The Minkowski distance of order t, where , is defined as
For , this definition yields the Manhattan distance, whereas for it yields the Euclidean distance. The limiting case corresponds to the Chebyshev distance,
The current implementation and experiments use the Euclidean distance. However, the coordinate-based lower-bound property exploited by DSPP is valid for the Minkowski distance family, as discussed in Section 2.4.1.
When we have two different spatial datasets ( and ) in the , the formal definition of the k-Closest Pairs (k-CP) query is as follows:
Definition 1
(k-Closest Pairs query, k-CP). Let and be two sets of points in , and let k be a positive integer with . The k-Closest Pairs query returns any set
containing k distinct cross-dataset pairs whose distances belong to the k smallest distances in , with ties resolved arbitrarily. Formally, for every and every ,
Different result pairs may share a point from either dataset; only the pairs themselves must be distinct.
Figure 1 illustrates an example of a k-CP query for . The numbered segments represent the three cross-dataset pairs with the smallest distances. Although the proposed algorithms are independent of the dimensionality of the data, the experimental evaluation presented in this paper focuses on two- and three-dimensional datasets using the Euclidean distance as the similarity measure.
Figure 1.
Example of a k-Closest Pairs (k-CP) query between two spatial datasets. The numbered segments represent the three pairs with the smallest distances.
2.2. GPU Execution Considerations
The dominant computational component of the k-CP query is the evaluation of cross-dataset point pairs. This operation is naturally data-parallel: the distance computations associated with different points of are independent and can therefore be assigned to different GPU threads. Each thread evaluates the distances between its assigned query point and candidate points from while maintaining a private list of promising candidate pairs. The thread-local results are subsequently merged to obtain the globally closest k pairs. Thus, the computationally dominant distance-evaluation and local candidate-maintenance stages are parallelized, whereas the final aggregation combines the independently generated local results. DSPP reduces the number of candidate distance evaluations by allowing each thread to prune sub-partitions that cannot improve its current candidate threshold.
The proposed methods exploit the data-parallel execution capabilities of GPUs through CUDA kernels. A central constraint for processing large spatial datasets is the separation between host and device memory and the limited capacity of GPU memory. Consequently, datasets that cannot reside entirely on the device must be processed through partitions, requiring explicit host–device data transfers and the subsequent combination of partial results.
These constraints directly influence the design of the proposed algorithms. The baseline methods assume that the required data partitions can be transferred to the GPU for kernel execution, whereas the scalable variants partition the input datasets to support processing beyond the available device-memory capacity. For variants that process multiple partitions of the query dataset, host–device communication can become a significant source of overhead. The DSPP + P and DSPP + PEA variants therefore employ pinned host memory, asynchronous transfers, and concurrent CUDA streams to overlap communication with computation. The algorithmic details of these mechanisms are described in Section 2.4.
Figure 2 summarizes the execution workflow adopted by all algorithmic variants. The host is responsible for reading the datasets, partitioning them when necessary, and managing memory transfers. Depending on the selected algorithm, pinned memory and multiple CUDA streams are employed to overlap communication with GPU computation. Each kernel computes local candidate pairs that are subsequently merged on the host to produce the final k-CP result. The following subsections describe the algorithmic variants in detail.
Figure 2.
Overview of the implementation workflow adopted by the proposed GPU algorithms.
2.3. Baseline Algorithms
This subsection introduces the reference implementations used to establish the performance of the proposed exact k-CP processing framework. The first implementation, Disk Brute Force (DBFS), assumes that both input datasets fit entirely into GPU memory and provides the simplest exhaustive GPU implementation of the exact k-CP query. The second implementation, Disk Brute Force with Partitioning (DBF), removes this limitation by processing the reference dataset incrementally while preserving the same exhaustive search and exact query semantics.
Both algorithms maintain, for each GPU thread, a private collection containing the current candidate pairs. Since the efficiency of this data structure directly affects the overall execution time, two alternative implementations are also investigated: a linear distance-list buffer and a max-heap-based distance-list buffer.
2.3.1. Disk Brute Force (DBFS)
The DBFS algorithm represents the baseline implementation of the exact k-CP query. It assumes that the two input datasets, and , together with all auxiliary data structures, fit entirely into GPU memory. Under this assumption, all pairwise distances can be evaluated within a single kernel execution.
The host reads the two three-dimensional point sets together with the parameter k and transfers the datasets to the GPU. One-dimensional thread blocks containing N threads are employed throughout the computation. Each thread is assigned to a single point of and computes its distances to all points of . During this process, every thread maintains a private candidate list containing the current k closest pairs associated with its query point. The first k distances are inserted directly into the list, whereas each subsequent distance replaces the current maximum only when a closer pair is identified.
After kernel execution, the thread-local candidate lists are copied back to the host, where the global k-CP are obtained by merging the individual results. Two alternative implementations of the candidate list are considered throughout this work:
- Distance List Buffer;
- Max-Heap Distance List Buffer.
The corresponding host and device pseudocodes are presented in Algorithms 1 and 2. Note that, for clarity, the pseudocodes presented in the whole of this section focus on the main execution flow and omit implementation-specific boundary handling, such as checks for partially filled CUDA thread blocks and special treatment of the final or partition, which may contain fewer points than the nominal partition size. These boundary cases are handled in the actual implementation.
| Algorithm 1 DBFS host algorithm |
|
| Algorithm 2 DBFS device kernel algorithm (runKCP) |
|
2.3.2. Disk Brute Force with Partitioning (DBF)
The DBFS algorithm assumes that both datasets reside entirely in GPU memory, an assumption that is often unrealistic for large spatial datasets. The DBF algorithm addresses this limitation by partitioning the reference () dataset while preserving the same exhaustive-search strategy.
The query dataset is transferred to the GPU once and remains resident in device memory throughout the computation. In contrast, the reference dataset is divided into partitions, each small enough to fit into the available GPU memory. The number of partitions, , is calculated as (D1_size-1)/D1_partition_size+1. If D1_size is evenly divisible by D1_partition_size, all partitions contain exactly D1_partition_size points. Otherwise, the last partition contains a number of points equal to the remainder of the division of D1_size by D1_partition_size. These partitions are read sequentially by the host and transferred individually to the device.
As in DBFS, one GPU thread is assigned to each point of . Instead of processing the complete reference dataset, however, each thread evaluates distances only to the points contained in the currently loaded partition. The thread-local candidate list is preserved across all partition iterations, allowing candidate pairs discovered in previous partitions to participate in subsequent comparisons. After all partitions have been processed, the candidate lists are transferred back to the host and merged to obtain the final exact set of k-CP.
The corresponding host-side pseudocode is presented in Algorithm 3. The device-side computation follows the same brute-force procedure as Algorithm 2. Each GPU thread is assigned to a point of and computes its distances to all points of the currently loaded partition of , updating its candidate list accordingly. The main difference from DBFS lies in the host-side execution, where is processed incrementally through successive partitions and the candidate lists are preserved across kernel executions.
| Algorithm 3 DBF host algorithm |
|
2.3.3. k-CP Distance List Buffer and k-CP Max-Heap Distance List Buffer
The first data structure used for maintaining the candidate pairs is the k-CP Distance List Buffer (KCP-DLB). It is implemented as a simple linear array that stores the current candidate pairs associated with each GPU thread. This implementation requires a linear scan whenever an update is performed. Consequently, both identifying the maximum element and inserting a new candidate require time.
The second candidate-list implementation is the k-CP Max-Heap Distance List Buffer (KCP-MHDLB). The structure organizes the candidate pairs as a binary max heap implemented using an array of size . The first array position is reserved for a sentinel element. In this case determining whether a newly computed pair should be inserted requires only a comparison with the root element. As a result, locating the current maximum and updating the candidate structure requires time, making the heap-based implementation particularly attractive for larger values of k.
The algorithmic variants presented in the following should not be interpreted as independent solutions proposed with equal scientific significance. Instead, they represent implementations of a common exact k-CP processing framework. DSPP-based spatial pruning provides the principal mechanism for reducing unnecessary distance evaluations, while the remaining variants address scalability and GPU-execution issues, including processing datasets that exceed device memory, communication overhead, and thread assignment.
2.4. Proposed Algorithms
The baseline algorithms presented in the previous subsection evaluate every candidate pair and therefore perform a considerable amount of unnecessary computation. Although this exhaustive strategy guarantees exact results, its computational cost increases rapidly with the size of the input datasets. The algorithms introduced in this subsection address this limitation by exploiting the spatial organization of the reference dataset while preserving the exactness of the k-CP query.
The proposed methodology consists of three layers. First, DSPP-based spatial pruning is adapted to reduce unnecessary distance computations in the global k-CP problem. Second, scalable partitioning extends the method to datasets that cannot reside entirely in GPU memory. Third, GPU-oriented execution optimizations reduce communication and scheduling overhead. The variants described below implement different combinations of these layers.
2.4.1. Disk Symmetric Progression Partitioning (DSPP)
Disk Symmetric Progression Partitioning (DSPP) was previously investigated for GPU-based k-nearest-neighbor processing [10]. In the present work, its spatial subdivision and progressive traversal principles are adapted to the different requirements of the global k-CP query. Although brute-force algorithms are straightforward to parallelize, they evaluate many point pairs that cannot contribute to the final result. DSPP addresses this limitation through a spatial subdivision strategy that exploits the low dimensionality of the input data to eliminate unnecessary distance computations while preserving exactness.
For each partition of , the points are first sorted according to their x-coordinate and subsequently divided into sub-partitions containing the same number of points. A sub-partition index is then created, storing the minimum and maximum x-coordinate values of each sub-partition.
For each point of , the algorithm begins by examining the sub-partition containing the point or, if the point lies outside the x-range of the current partition, the nearest sub-partition along the x-axis. Subsequent sub-partitions are examined progressively by selecting the next closest neighbouring sub-partition, either to the left or to the right. In this way, the algorithm progressively expands a contiguous region of examined sub-partitions.
The sub-partition index provides the leftmost and rightmost x-coordinate values of the examined region. These boundaries are used to compute a lower bound on the x-coordinate distance between the current point of and points belonging to the remaining unexamined sub-partitions of . If this lower bound exceeds the current candidate threshold, no additional sub-partitions need to be examined. Consequently, the remaining sub-partitions cannot contain points capable of improving the current candidate list.
A property of the Minkowski family is particularly relevant to the proposed pruning mechanism. For any coordinate j,
In particular,
Therefore, separation along the x-coordinate provides a lower bound on the Minkowski distance. DSPP exploits this property to determine when unexamined spatial sub-partitions cannot contain points capable of improving the current candidate list.
The overall DSPP workflow is presented in Algorithms 4 and 5. On the host side, is processed partition by partition. Each partition is loaded, transferred to the GPU, sorted according to the x-coordinate, and divided into ordered sub-partitions. An auxiliary index storing the minimum and maximum x-coordinate values of each sub-partition is then constructed and transferred to the GPU.
On the device side, each GPU thread processes one point of and progressively traverses the relevant sub-partitions of the current partition. For every visited sub-partition, the distances between the query point and its points are evaluated, and the thread-local candidate list is updated. The current candidate threshold is then used together with the sub-partition boundaries to determine whether another neighbouring sub-partition can still contain points capable of improving the candidate list. If not, the remaining sub-partitions are discarded without additional distance computations. After all partitions have been processed, the thread-local candidate lists are merged to obtain the final global k-CP result.
| Algorithm 4 DSPP host algorithm |
|
| Algorithm 5 DSPP device kernel algorithm (runKCP) |
|
Proposition 1
(Correctness of DSPP pruning). Let p be a query point processed by DSPP, and let denote the current candidate threshold, i.e., the maximum distance stored in its candidate list. Let S be an unexamined sub-partition, and let denote a lower bound on the x-coordinate separation between p and every point contained in S. If
then no point contained in S can improve the current candidate list.
Proof.
For every point , the coordinate separation provides a lower bound on the Minkowski distance. Therefore,
Consequently, if
then
for every . Hence, no point contained in S can improve the current candidate list, and the sub-partition can be safely pruned. □
Since the sub-partitions are ordered according to their x-coordinate, the pruning condition can be applied progressively during the traversal. Once the lower bound for the next relevant sub-partition exceeds the current candidate threshold, further distance computations cannot improve the candidate list.
The actual amount of pruning depends on the spatial distribution of the points and on the current candidate threshold. Consequently, DSPP does not assume a fixed reduction in the number of distance computations; instead, the number of pruned sub-partitions is determined dynamically during execution.
Figure 3 illustrates the proposed strategy using a two-dimensional example. The figure shows the query point from , the points examined during the progressive traversal, and the sub-partitions that are eliminated without distance computation. The radius of the circle corresponds to the current candidate threshold stored in the thread’s candidate list. Although the illustration is two-dimensional for clarity, the same x-based pruning principle applies to three-dimensional datasets. In practical applications, sub-partitions contain considerably more points, and their spatial widths depend on the distribution of the reference dataset, which helps explain the performance differences observed in Section 3.
Figure 3.
Example of DSPP traversal using ordered sub-partitions and x-coordinate-based pruning.
The complete host-side and device-side pseudocodes are presented in Algorithms 4 and 5, respectively.
2.4.2. Improved Disk Symmetric Progression Partitioning (DSPP+)
The DSPP algorithm assumes that the complete query dataset remains resident in GPU memory throughout the computation. While this assumption is appropriate for moderately sized datasets, it becomes restrictive when both input datasets exceed the available GPU memory.
DSPP+ overcomes this limitation by partitioning both datasets while preserving the spatial subdivision strategy introduced in DSPP. The overall host-side workflow is presented in Algorithm 6. The algorithm follows the same procedure as DSPP, with the main difference being that is divided into partitions. Consequently, instead of being executed times, the kernel is executed times.
By partitioning both datasets, the algorithm removes the requirement that the complete query dataset must reside in GPU memory, thereby enabling exact processing of arbitrarily large spatial datasets while preserving the same pruning strategy and computational correctness as DSPP. Although this design increases host–device communication because every partition of must be processed for each partition of , it substantially extends the applicability of the proposed approach to datasets that exceed the available GPU memory.
| Algorithm 6 DSPP+ host algorithm |
|
2.4.3. Improved Disk Symmetric Progression Partitioning with Pinned Memory (DSPP + P)
Although DSPP+ considerably improves scalability, repeatedly transferring partitions of between the host and the GPU introduces a significant communication overhead. DSPP + P addresses this limitation by overlapping communication with computation through the combined use of pinned (page-locked) host memory, asynchronous memory transfers, and multiple CUDA streams.
Partitions of are first loaded into pinned host buffers and then transferred asynchronously to the GPU. Kernel executions are launched in batches of S CUDA streams, allowing communication associated with subsequent partitions to proceed while previous kernels are still executing. Synchronization is performed after each batch using cudaDeviceSynchronize(), while the final batch may contain fewer than S kernels.
Apart from these communication optimizations, the computational procedure remains identical to that of DSPP+, including the thread assignment and the spatial pruning strategy.
2.4.4. Improved DSPP with Pinned Memory and Enhanced Assignment (DSPP + PEA)
The final optimization modifies the assignment of query points to GPU threads. Instead of processing a single query point, each thread processes a small group of l points sequentially.
This strategy allows larger effective partitions of without increasing either the number of GPU threads or the number of maintained candidate lists. Consequently, fewer file reads, GPU transfers, kernel launches, and synchronization operations are required. Each thread repeatedly applies exactly the same sub-partition traversal and candidate-list maintenance procedure developed for the previous variants.
The larger partition size, however, introduces a trade-off. During the final iterations of the host-side computation, the overlap between communication and computation may decrease because fewer partitions remain available for concurrent execution. The magnitude of this effect depends on the quotient and remainder obtained when the size of is divided by the selected partition size.
Furthermore, if the final partition contains considerably fewer query points than the preceding partitions, the last kernel execution will operate with fewer active threads than the optimum configuration, resulting in lower GPU occupancy and a modest reduction in overall performance.
For clarity, Table 1 summarizes the evolution of the proposed algorithmic variants and the main optimization introduced by each method. The candidate-list structures are alternative components that can be combined with the corresponding algorithmic variants. The variants therefore represent complementary extensions, addressing computational pruning, GPU memory capacity, communication overhead, and execution efficiency, respectively.
Table 1.
Summary of the proposed GPU-based algorithmic variants.
2.5. Implementation Details
Two data structures are used throughout the implementation. The first represents spatial points and stores a unique point identifier as an unsigned long long int together with the point coordinates in double precision. The second represents candidate pairs by storing the identifiers of the two points along with their Euclidean distance, also in double precision.
To minimize file I/O overhead, all datasets are stored in binary format. This representation enables efficient loading and direct transfer of the data to GPU memory without additional preprocessing.
2.6. Experimental Setup
The experiments were conducted using Google Colab (Google LLC, Mountain View, CA, USA), which provides free access to NVIDIA GPU hardware. The experimental platform consisted of Ubuntu 20.04 LTS, an Intel Xeon processor operating at 2.00 GHz with one core (two hardware threads), approximately 13 GB of main memory, and 121 GB of storage. All GPU experiments were performed on an NVIDIA Tesla T4 accelerator (NVIDIA Corporation, Santa Clara, CA, USA) using CUDA version 13.0.
Synthetic datasets were generated using the SpiderWeb generator, which produces normalized two-dimensional point sets within the interval [0, 1] according to several selectable spatial distributions. Three-dimensional datasets were obtained by assigning the x-coordinate from an additional generated dataset as the z-coordinate.
No pre-existing spatial index is used in the generation of the synthetic datasets. The proposed algorithms operate directly on the point sets. For DSPP-based variants, the required lightweight spatial indexing structure is constructed dynamically during processing by sorting each reference-data partition according to the x-coordinate and dividing it into ordered sub-partitions.
The synthetic benchmark consists of two input datasets. The reference dataset contains between one and five million three-dimensional points, corresponding to file sizes ranging from 32 MB to 160 MB. The query dataset contains between 100,000 and 500,000 points, with file sizes between 3.2 MB and 16 MB. Three spatial distributions are considered, namely Bit, Normal, and Uniform. The characteristics of the synthetic datasets are summarized in Table 2.
Table 2.
Synthetic Dataset Summary.
The synthetic experiments are organized into three groups. The first investigates the scalability of the algorithms with respect to the size of the reference dataset , the second examines the effect of increasing the size of the query dataset , and the third evaluates the influence of the parameter k.
In addition to the synthetic benchmarks, four real-world datasets were used to evaluate the proposed algorithms under realistic conditions. Two datasets consist of point coordinates, whereas the remaining two contain polygon geometries that were converted to point representations using their centroids. The coordinate datasets contain 2,091,602 and 1,438,677 points, respectively, while the centroid datasets contain 562,302 and 244,760 points. For all datasets, the x and y coordinates were normalized to the interval [0, 1], while the z coordinate was set to zero. A summary of the datasets and their sources is presented in Table 3. Unless otherwise stated, the experiments on these datasets were performed for values of k ranging from 20 to 140.
Table 3.
Real data.
To further assess scalability, three additional large real-world datasets from different geographic collections were employed. The first dataset contains approximately 5.8 million water-related line segments in North America (Water Dataset). The second consists of approximately 11.5 million polygons representing parks and green areas, while the third contains approximately 114.7 million building footprints.
Point representations were generated by computing the centres of the minimum bounding rectangles (MBRs) of the line segments in the Water Dataset and the centroids of the polygon datasets. All coordinates were normalized to the interval [0, 1].
Overall, ten algorithmic variants were evaluated in order to investigate the influence of partitioning strategies, candidate-list data structures, communication optimizations, and thread-assignment policies on both execution time and memory consumption.
A comprehensive set of experiments was conducted to evaluate performance and memory consumption across the ten algorithmic variants of Table 4.
Table 4.
Algorithmic variants implemented.
2.7. Software and Implementation
The algorithms were implemented in C++ using CUDA version 13.0. GPU data structures and parallel primitives were developed with the aid of the Thrust library [38], which provides a high-level interface for CUDA programming while maintaining efficient execution on modern NVIDIA GPUs. All experiments were performed on an NVIDIA Tesla T4 GPU.
3. Results
This section presents the experimental evaluation of the proposed algorithms. The comparison focuses on both execution performance and scalability using the DBF algorithm as the baseline GPU implementation. The experiments investigate the impact of increasing the sizes of the input datasets, the influence of the parameter k, and the behavior of the algorithms on large real-world datasets.
The DBF algorithm is used as a reference baseline because it provides a straightforward exhaustive GPU implementation of the same exact k-CP problem, without spatial pruning or the subsequent GPU-specific optimizations. It is therefore not intended to represent a competing state-of-the-art method, but to provide a controlled reference against which the effect of the proposed optimizations can be measured. In particular, comparing the proposed variants with DBF keeps the query definition, distance metric, candidate-list semantics, and exactness requirement unchanged, while progressively introducing spatial pruning, memory-aware partitioning, communication overlap, and execution optimizations. To the best of our knowledge, no directly comparable public GPU implementation for exact global k-CP processing is currently available.
The experiments are organized into two main groups. The first investigates the effect of dataset size, considering both synthetic and large real-world datasets, whereas the second examines the effect of the parameter k. For the synthetic datasets, the spatial distribution is treated as an experimental parameter.
3.1. Impact of Dataset Size
The first set of experiments investigates how the proposed algorithms behave as the sizes of the input datasets increase. Both synthetic datasets generated according to different statistical distributions and large real-world datasets are considered in order to evaluate scalability under a variety of operating conditions.
3.1.1. Scaling Synthetic Datasets
In the synthetic experiments, we evaluate the scalability of the proposed algorithms under three spatial distributions: Bit, Normal, and Uniform. The spatial distribution is treated as an experimental parameter rather than as a separate experimental group.
Two dataset-scaling configurations are considered. In the first configuration, the size of the reference dataset increases from 1 M to 5 M points, while the query dataset remains fixed at 100 K points. In the second configuration, the size of increases from 100 K to 500 K points, while remains fixed at 1 M points. In both configurations, .
The three spatial distributions affect the absolute execution times because the effectiveness of spatial pruning depends on the spatial arrangement of the points. However, the relative ranking of the algorithmic variants remains broadly consistent. Therefore, Figure 4 and Figure 5 present representative results for the Bit distribution, while the influence of spatial distribution is analysed separately in Section 4.
Figure 4.
scaling with Bit distribution.
Figure 5.
scaling with Bit distribution.
Among all evaluated variants, DSPP + PEA generally achieves the best overall performance. The results also demonstrate the effectiveness of the proposed spatial subdivision strategy, which substantially reduces the number of distance computations and consequently the overall execution time compared with the brute-force approaches.
The results also reveal differences in the effectiveness of the individual optimizations. For , the choice of candidate-list structure influences the benefit obtained from communication optimizations, whereas the differences between DSPP and DSPP+ remain relatively small for the evaluated dataset sizes. This indicates that, under these conditions, the additional partitioning and communication overhead does not dominate the overall execution time. The broader effects of these optimizations are discussed in Section 4.
Table 5 reports the speedups relative to the DBF baseline for the -scaling configuration under the Bit distribution. The highest speedups obtained for each size are highlighted in bold. The largest speedup is approximately , obtained by combining DSPP-based spatial pruning with the additional GPU-oriented optimizations.
Table 5.
Speedup relative to DBF for -scaling under the Bit distribution.
Table 6 reports the corresponding speedups for the -scaling configuration. The highest speedups obtained for each size are highlighted in bold. The results confirm that the proposed optimizations remain effective as the size of the query dataset increases.
Table 6.
Speedup relative to DBF for -scaling under the Bit distribution.
3.1.2. Parks 11.5 M, Water 5.8 M
This experiment evaluates the proposed algorithms using two large real-world datasets. The reference dataset consists of 11.5 million points representing parks, while the query dataset contains 5.8 million points representing water-related features. Based on the synthetic experiments, the three best-performing variants were selected for the evaluation on the Parks–Water datasets.
Figure 6 presents the corresponding execution times. Among the evaluated methods, DSPP + PEA achieves the best overall performance, followed by DSPP + P and DSPP+. The results indicate that combining pinned memory with concurrent kernel execution provides an additional reduction in execution time beyond that obtained by the DSPP+ algorithm alone.
Figure 6.
Parks 11.5 M, Water 5.8 M.
3.1.3. Buildings 114.7 M, Water 5.8 M
The second experiment further increases the size of the reference dataset by considering the Buildings dataset, which contains approximately 114.7 million points. The Water dataset, containing 5.8 million points, is again used as the query dataset. Based on the results of the previous experiments, only the two fastest implementations, DSPP + P and DSPP + PEA, are evaluated.
The execution times shown in Figure 7 confirm the trends observed in the previous experiment. DSPP + PEA consistently outperforms DSPP + P, demonstrating that the enhanced thread-assignment strategy continues to provide additional performance benefits even for datasets exceeding one hundred million spatial objects. These results further highlight the effectiveness of overlapping communication with computation when processing very large datasets.
Figure 7.
Buildings 114.7 M, Water 5.8 M.
3.1.4. Buildings 114.7 M, Parks 11.5 M
The final large-scale experiment considers the two largest datasets used in this study. The Buildings dataset, containing approximately 114.7 million points, serves as the reference dataset, while the Parks dataset, containing 11.5 million points, is used as the query dataset. As in the previous experiment, only the DSPP + P and DSPP + PEA variants are considered.
Figure 8 shows that DSPP + PEA again achieves the lowest execution time. The consistent superiority of this implementation across all large real-world experiments demonstrates that the combination of spatial subdivision, communication optimizations, and enhanced thread assignment remains effective even for extremely large datasets. These results confirm the scalability of the proposed methodology under realistic operating conditions.
Figure 8.
Buildings 114.7 M, Parks 11.5 M.
Overall, the large real-world experiments confirm the scalability of the proposed methodology and the effectiveness of the GPU-oriented optimizations under realistic conditions.
3.2. Impact of Parameter k
This group of experiments investigates the influence of the parameter k on the performance of the proposed algorithms. To isolate the effect of increasing the number of closest pairs to be maintained, the sizes of the input datasets remain fixed while k varies from 20 to 140. The evaluation considers both synthetic and real-world datasets. For the synthetic datasets, the influence of k is examined under the Bit, Normal, and Uniform spatial distributions.
3.2.1. Scaling k with Synthetic Datasets
In this experiment, the parameter k varies from 20 to 140, while the reference dataset and the query dataset remain fixed at 1 M and 100 K points, respectively. This configuration isolates the effect of the number of closest pairs maintained by each thread on the overall execution time.
The experiment is evaluated under the Bit, Normal, and Uniform spatial distributions. Although the absolute execution times depend on the spatial distribution, the relative behaviour of the algorithmic variants remains broadly similar. Figure 9 therefore presents representative results for the Bit distribution.
Figure 9.
k scaling with Bit distribution.
Among all evaluated implementations, DSPP + PEA generally achieves the best overall performance. The results also demonstrate the effectiveness of the proposed spatial subdivision strategy, as all DSPP-based variants significantly outperform the corresponding brute-force implementations.
The communication optimizations introduced through pinned memory and concurrent kernel execution continue to provide additional performance improvements for both candidate-list implementations. As expected, the influence of the candidate-list organization becomes increasingly important as k grows. For larger values of k, the max-heap implementation generally outperforms the KCP-DLB structure because maintaining the current set of candidate pairs becomes progressively more computationally demanding. The only exceptions occur for the DSPP + P and DSPP+ variants, where the performance advantage of the heap implementation appears only for the largest values of k.
Table 7 reports the speedups relative to the DBF baseline for the Bit distribution experiment. The highest speedups obtained for each value of k are highlighted in bold. The largest improvement is observed for , where DSPP + PEA combined with the max-heap candidate structure achieves a speedup of approximately .
Table 7.
Speedup relative to DBF for k-scaling under the Bit distribution.
Overall, the synthetic k scaling experiments demonstrate that the parameter k has a greater influence on the performance of the candidate-list data structures than on the effectiveness of the proposed spatial subdivision strategy. As the value of k increases, the advantages of the max-heap implementation become increasingly evident, while the DSPP + PEA algorithm generally provides the best overall performance across all three data distributions. These results indicate that the proposed optimizations remain effective over a broad range of query sizes and distributions.
3.2.2. Scaling k with Real Datasets
This group of experiments evaluates the influence of k using real-world datasets. The reference and query datasets are selected from the four datasets presented in Table 3 (four representative combinations of the coordinate and centroid datasets listed in this table were evaluated), allowing the algorithms to be evaluated under different combinations of point distributions and dataset sizes.
Figure 10 presents the results for Coordinates #1 and Centroids #1, which are representative of the observed behaviour across the evaluated real-data combinations. DSPP + PEA combined with the max-heap candidate structure provides the best overall performance, with its advantage becoming more pronounced as k increases. The results further indicate that the benefit of the max-heap candidate structure increases with larger values of k, as the more efficient organization reduces the cost of maintaining the candidate pairs.
Figure 10.
Coordinates #1 vs Centroids #1.
Table 8 summarizes the execution speedups relative to the DSPP+ implementation, which serves as the baseline. The highest speedups obtained for each value of k are highlighted in bold.
Table 8.
Speedup relative to DSPP+ for k-scaling using Coordinates #1 as and Centroids #1 as .
Overall, the experiments on the real-world datasets confirm the conclusions drawn from both the synthetic benchmarks and the large-scale scalability experiments. Across all dataset combinations, the proposed algorithms consistently outperform the DSPP+ baseline, while the incorporation of pinned memory, concurrent kernel execution, and enhanced thread assignment yields additional performance improvements. Moreover, the max-heap candidate-list implementation becomes increasingly advantageous as the value of k grows, enabling the DSPP + PEA Heap variant to achieve the highest execution speedups in nearly all experimental configurations.
4. Discussion
This section discusses the experimental findings presented in Section 3, focusing on the factors responsible for the observed performance improvements, the scalability of the proposed algorithms, the influence of the spatial distribution of the data, and the limitations of the current implementation.
4.1. Interpretation of Performance Improvements
The experimental evaluation demonstrates an overall progression in performance across the proposed algorithmic variants, although the benefit of individual optimizations depends on dataset characteristics and the value of k. Among all evaluated implementations, DSPP + PEA generally provides the best overall performance, particularly for large input datasets and larger values of the parameter k. These improvements result from the cumulative effect of the optimizations introduced throughout the paper rather than from a single modification.
The first major source of improvement is the DSPP pruning mechanism. Rather than evaluating every point of a reference-data partition, DSPP progressively traverses spatially ordered sub-partitions and uses the current candidate threshold together with a coordinate-based lower bound to terminate the search. Proposition 1 establishes that this pruning does not compromise exactness. Since distance evaluation dominates the computational cost of brute-force approaches, the performance improvements observed for DSPP relative to the brute-force baseline are consistent with the effect of the proposed pruning mechanism, which avoids distance evaluations for sub-partitions that cannot improve the current candidate list. The magnitude of this benefit depends on the spatial distribution of the input data and on the evolution of the candidate threshold during execution.
A second important contribution is the use of pinned memory together with concurrent kernel execution. As demonstrated by the experimental results, overlapping communication with computation generally reduces the overhead associated with transferring partitions between the host and the GPU. The benefits become increasingly pronounced as the sizes of and grow because communication represents a larger fraction of the total execution time for large datasets.
An interesting observation is that DSPP+ frequently outperforms DSPP, despite the additional host–device communication introduced by partitioning the query dataset . At first glance this behaviour appears counterintuitive because DSPP+ transfers every partition of once for each partition of . Nevertheless, partitioning also reduces the number of simultaneously active GPU threads and decreases the size of the associated candidate-list structures. Consequently, fewer candidate lists need to be initialized, maintained, and transferred back to the host. Moreover, the smaller working set improves cache utilisation and memory-access locality, increasing the effectiveness of memory coalescing when accessing the elements of . The combined effect of these implementation-level optimizations outweighs the additional communication cost for the datasets considered in this study.
4.1.1. Scalability for Large Spatial Datasets
One of the primary objectives of this work was to develop algorithms capable of processing spatial datasets that substantially exceed the available GPU memory. The experimental results demonstrate that the last four algorithmic variants successfully achieve this objective through dataset partitioning.
The scalability experiments indicate that the execution time increases approximately linearly with the sizes of both the reference dataset and the query dataset . This behaviour is consistent with the design of the proposed algorithms, in which each additional partition contributes approximately the same computational workload. The absence of superlinear growth demonstrates that the proposed partitioning strategy effectively controls memory usage without introducing excessive computational overhead.
These characteristics make the proposed methods suitable for contemporary GIS applications, where datasets frequently contain millions or even hundreds of millions of spatial objects and cannot be processed entirely in GPU memory.
4.1.2. Effect of Data Distribution on the Algorithms
The experimental evaluation also investigated the influence of different spatial data distributions on algorithm performance. As expected, the execution time varies across the Bit, Normal, and Uniform distributions because the effectiveness of the spatial subdivision strategy depends on the spatial arrangement of the points.
For the dataset-scaling experiments, the observed differences between the fastest and slowest distributions varied considerably among the evaluated algorithms. In several cases the increase in execution time remained below 10–20%, whereas in others it approached or exceeded 40%. In one configuration (DSPP+ Heap during the scaling experiments), the execution time for one distribution was more than twice that of another. In contrast, the experiments investigating the influence of the parameter k exhibited substantially smaller differences among the three distributions.
Although the data distribution clearly influences execution performance, the three synthetic distributions considered in this study represent markedly different spatial configurations. The Bit distribution concentrates most points near the origin, and the Normal distribution generates points around the centre of the domain, whereas the Uniform distribution distributes points approximately evenly throughout the entire space (Figure 11).
Figure 11.
Experiment distributions. (Top left): Bit; (top right): Normal; (bottom): Uniform.
Despite these differences, the relative ranking of the proposed algorithms remains remarkably consistent across all distributions. The experimental results therefore indicate that the proposed methods are robust with respect to variations in the spatial characteristics of the input data, even though the absolute execution time depends on the underlying point distribution.
4.1.3. Limitations of the Proposed Approach
Despite the encouraging results, the proposed methodology has certain limitations. The most important limitation concerns the partitioning strategy adopted for the reference dataset . In order to guarantee that each partition fits into the available GPU memory together with the auxiliary data structures, the partition size cannot exceed a hardware-dependent limit. Consequently, the available device memory cannot always be fully utilised, particularly for datasets with highly variable partition sizes.
A second limitation is associated with the repeated processing of the query dataset . Since every partition of must be processed for each partition of , host–device communication increases with the number of reference partitions. Although the use of pinned memory and concurrent kernel execution substantially reduces this overhead, communication remains an important factor affecting overall performance for extremely large datasets.
A further limitation concerns the use of GPU shared memory. The partitions of considered in the current implementation are substantially larger than the available shared-memory capacity and therefore cannot be stored entirely in shared memory. Reducing the partition size would increase the number of accesses to partitions of , whereas a tiled implementation would require additional indexing and more complex data structures. Moreover, the effective use of shared memory would likely require larger thread blocks, while experiments conducted during the implementation indicate that the current algorithms achieve better performance with relatively small blocks of 64 threads. Consequently, an efficient shared-memory implementation is possible but would require a substantially different execution strategy and is left for future work.
Finally, the current implementation targets a single GPU. Although the proposed algorithms scale well on a single accelerator, further improvements could be achieved by distributing partitions across multiple GPUs, thereby increasing both computational throughput and aggregate memory capacity.
4.2. Overall Results
The experimental evaluation demonstrates the complementary performance benefits obtained by progressively extending the brute-force baseline with spatial pruning, scalable partitioning, communication optimizations, and enhanced execution assignment. DSPP reduces the computational workload by dynamically pruning spatial sub-partitions that cannot improve the current candidate list, thereby avoiding distance evaluations for their contained points. The effectiveness of this pruning is data-dependent, as it depends on the spatial distribution of the points and on the candidate thresholds obtained during the progressive traversal. DSPP+ further extends the approach by partitioning , enabling the processing of cases in which both datasets cannot simultaneously reside in GPU memory. DSPP + P reduces host–device communication overhead by using pinned memory and overlapping data transfers with kernel execution, whereas DSPP + PEA further reduces transfer, kernel-launch, and synchronization overhead through enhanced work assignment.
The results indicate that these optimizations are complementary. Spatial pruning becomes particularly beneficial as the size of the input datasets increases, whereas communication and execution-management techniques become increasingly important when host–device data movement represents a larger component of the total execution time. Consequently, the combined optimizations provide the strongest overall performance for the largest datasets.
Across both synthetic and real-world experiments, DSPP + PEA generally achieves the lowest execution times among the evaluated implementations. For larger values of k, its combination with the max-heap candidate-list structure provides the strongest overall performance. For small values of k, however, DSPP + P with the KCP-DLB structure can occasionally achieve slightly lower execution times because of its lower candidate-list maintenance overhead.
Finally, the experiments involving the Bit, Normal, and Uniform distributions show that absolute execution time depends on the spatial distribution of the input points. Nevertheless, the relative ranking of the proposed algorithms remains largely consistent across the three distributions, indicating that the proposed methodology remains effective under substantial variations in spatial data characteristics.
5. Conclusions
This paper presented an exact GPU-based framework for processing the global k-CP query on large spatial datasets. Building upon DSPP-based spatial pruning principles previously investigated for kNN processing, the proposed methodology adapts these principles to global closest-pair computation and combines them with memory-aware partitioning, communication optimizations, and an enhanced thread-assignment strategy.
The experimental evaluation demonstrates that the combined optimizations improve performance, although their individual benefits depend on dataset characteristics and the value of k. Among the evaluated implementations, DSPP + PEA combined with the max-heap candidate list generally provides the best overall performance, particularly for large datasets and larger values of the parameter k. For small values of k, however, DSPP + P using the KCP-DLB candidate list occasionally achieves slightly lower execution times because of its lower candidate-list maintenance overhead.
The proposed spatial subdivision strategy reduces unnecessary distance computations by dynamically pruning sub-partitions that cannot improve the current candidate list, while the communication optimizations further decrease the overhead associated with transferring large datasets between the host and the GPU. Together, these techniques enable the exact processing of datasets that substantially exceed the available GPU memory while maintaining good scalability with respect to both dataset size and query parameter.
Beyond the specific k-CP problem considered in this study, the proposed techniques demonstrate how scalable partitioning strategies and GPU-oriented optimizations can be effectively combined to process exact spatial proximity queries on datasets that exceed the available device memory. Consequently, the ideas developed in this work may also be applicable to other classes of large-scale spatial queries requiring exact distance computations, providing a practical foundation for future GPU-based spatial query processing algorithms.
Future work will investigate several directions. First, shared memory could be exploited more extensively to reduce global-memory accesses and further improve kernel performance. Second, adaptive techniques could be developed to estimate the optimal number of sub-partitions dynamically according to the spatial characteristics of the input data. Finally, extending the proposed methodology to multi-GPU systems would enable the processing of even larger spatial datasets while further reducing execution time through concurrent processing of multiple dataset partitions.
Author Contributions
Conceptualization, Michael Vassilakopoulos, Antonio Corral, Polychronis Velentzas and Ioannis Pateras;
methodology, Michael Vassilakopoulos, Antonio Corral, Polychronis Velentzas and Ioannis Pateras;
software, Ioannis Pateras;
validation, Ioannis Pateras, Michael Vassilakopoulos, Antonio Corral, and Polychronis Velentzas;
formal analysis, Michael Vassilakopoulos, Antonio Corral, Polychronis Velentzas and Ioannis Pateras;
investigation, Michael Vassilakopoulos, Antonio Corral, Polychronis Velentzas and Ioannis Pateras;
resources, Michael Vassilakopoulos and Antonio Corral;
data curation, Ioannis Pateras and Polychronis Velentzas;
writing—original draft preparation, Polychronis Velentzas, Michael Vassilakopoulos and Antonio Corral;
writing—review and editing, Michael Vassilakopoulos, Antonio Corral, Polychronis Velentzas and Ioannis Pateras;
visualization, Ioannis Pateras and Polychronis Velentzas;
supervision, Michael Vassilakopoulos and Antonio Corral;
project administration, Michael Vassilakopoulos;
funding acquisition, Michael Vassilakopoulos and Antonio Corral.
All authors have read and agreed to the published version of the manuscript.
Funding
The research of Antonio Corral was funded by the Spanish Government MCIN/AEI/10.13039/501100011033 and the “ERDF A way of making Europe” through grant number PID2021-124124OB-I00.
Data Availability Statement
The synthetic datasets generated with the SpiderWeb generator, the processed datasets used in the experiments, and the source code implementing the proposed algorithms are available from the corresponding author upon reasonable request. The real-world datasets analysed during this study were derived from publicly available OpenStreetMap data (https://www.openstreetmap.org) and the OpenStreetMap historical data archives. The preprocessing steps used to generate the experimental datasets, including normalization, centroid computation, and minimum bounding rectangle (MBR) centre extraction, are described in Section 2. The complete experimental results supporting the findings of this study, including additional measurements not reported in the manuscript, are publicly available in the KCPQ Experiments repository: https://github.com/cvelentzas/KCPQ (accessed on 19 September 2026).
Conflicts of Interest
The authors declare no conflicts of interest.
Abbreviations
The following abbreviations are used in this manuscript:
| ANN | Approximate Nearest Neighbor |
| CPU | Central Processing Unit |
| CUDA | Compute Unified Device Architecture |
| DBF | Disk Brute Force with Partitioning |
| DBFS | Disk Brute Force |
| DLB | Distance List Buffer |
| DSPP | Disk Symmetric Progression Partitioning |
| DSPP+ | Improved DSPP |
| DSPP + P | Improved DSPP with Pinned Memory |
| DSPP + PEA | Improved DSPP with Pinned Memory and Enhanced Assignment |
| GIS | Geographic Information System |
| GPU | Graphics Processing Unit |
| k-CP | k-Closest Pairs |
| KCP-DLB | k-CP Distance List Buffer |
| KCP-MHDLB | k-CP Max-Heap Distance List Buffer |
| kNN | k-Nearest Neighbor |
| MBR | Minimum Bounding Rectangle |
References
- Corral, A.; Manolopoulos, Y.; Theodoridis, Y.; Vassilakopoulos, M. Closest Pair Queries in Spatial Databases. In Proceedings of the 2000 ACM SIGMOD International Conference on Management of Data; ACM: New York, NY, USA, 2000; pp. 189–200. [Google Scholar] [CrossRef] [Scilit]
- Corral, A.; Manolopoulos, Y.; Theodoridis, Y.; Vassilakopoulos, M. Algorithms for Processing K-Closest-Pair Queries in Spatial Databases. Data Knowl. Eng. 2004, 49, 67–104. [Google Scholar] [CrossRef] [Scilit]
- Huang, H.; Gao, S. Location-Based Services. In The Geographic Information Science & Technology Body of Knowledge, 1st Quarter 2018 ed.; Wilson, J.P., Ed.; University Consortium for Geographic Information Science (UCGIS): Ithaca, NY, USA, 2018. [Google Scholar] [CrossRef] [Scilit]
- Raper, J.; Gartner, G.; Karimi, H.; Rizos, C. Applications of location-based services: A selected review. J. Locat. Based Serv. 2007, 1, 89–111. [Google Scholar] [CrossRef] [Scilit]
- Huang, H.; Yao, X.A.; Krisp, J.M.; Jiang, B. Analytics of location-based big data for smart cities: Opportunities, challenges, and future directions. Comput. Environ. Urban Syst. 2021, 90, 101712. [Google Scholar] [CrossRef] [Scilit]
- Poudel, M.; Sarode, R.P.; Watanobe, Y.; Mozgovoy, M.; Bhalla, S. A Survey of Big Data Archives in Time-Domain Astronomy. Appl. Sci. 2022, 12, 6202. [Google Scholar] [CrossRef] [Scilit]
- Rayner, N.W.; Park, Y.C.; Fuchsberger, C.; Barysenka, A.; Zeggini, E. Toward GDPR compliance with the Helmholtz Munich genotype imputation server. Nat. Genet. 2024, 56, 2580–2581. [Google Scholar] [CrossRef] [Scilit]
- Krishanmoorthy, S.; Han, B.; Zhang, H.; Chai, Y.; Cheng, N. Classification and prediction of social attributes by K-Nearest Neighbor Algorithm with socially-aware wireless networking: A study. IOP Conf. Ser. Mater. Sci. Eng. 2020, 937, 012051. [Google Scholar] [CrossRef] [Scilit]
- Auradkar, P.; Gagan, G.R.; Deva, S.; Eedula, N.; Natarajan, M.; Kalambur, S.; Sitaram, D. Optimized Closest Pair Computation with CPU-GPU Combined Model. In Proceedings of the ICT Analysis and Applications Conference; Lecture Notes in Networks and Systems; Springer: Singapore, 2023; Volume 517, pp. 743–755. [Google Scholar] [CrossRef] [Scilit]
- Velentzas, P.; Vassilakopoulos, M.; Corral, A.; Antonopoulos, C.D. GPU-Based Algorithms for Processing the k Nearest-Neighbor Query on Spatial Data Using Partitioning and Concurrent Kernel Execution. Int. J. Parallel Program. 2023, 51, 275–308. [Google Scholar] [CrossRef] [Scilit]
- Gowanlock, M. Hybrid KNN-join: Parallel nearest neighbor searches exploiting CPU and GPU architectural features. J. Parallel Distrib. Comput. 2021, 149, 119–137. [Google Scholar] [CrossRef] [Scilit]
- Kuang, Q.; Zhao, L. A practical GPU based kNN algorithm. In Proceedings of the 2009 International Symposium on Computer Science and Computational Technology (ISCSCI 2009); Academy Publisher: Qingdao, China, 2009; pp. 151–155. Available online: https://readingxtra.github.io/docs/ml-gpu/practical-knn-gpu.pdf (accessed on 19 September 2026).
- Garcia, V.; Debreuve, E.; Barlaud, M. Fast k Nearest Neighbor Search using GPU. arXiv 2008. [Google Scholar] [CrossRef] [Scilit]
- Garcia, V.; Debreuve, E.; Nielsen, F.; Barlaud, M. K-nearest neighbor search: Fast GPU-based implementations and application to high-dimensional feature matching. In Proceedings of the 2010 International Conference on Image Processing (ICIP 2010); IEEE: New York, NY, USA, 2010; pp. 3757–3760. [Google Scholar] [CrossRef] [Scilit]
- Nikam, V.B.; Meshram, B.B. Parallel kNN on GPU Architecture using OpenCL. Int. J. Res. Eng. Technol. 2014, 3, 367–372. [Google Scholar] [CrossRef] [Scilit]
- Gutiérrez Pérez, P.D. Identificación y Clasificación Biométrica a Gran Escala Basada en Huellas Dactilares y GPU. Ph.D. Thesis, Universidad de Granada, Granada, Spain, 2017. Available online: https://produccioncientifica.ugr.es/documentos/618f4faa9ff8c939aaca5509 (accessed on 19 September 2026).
- Chen, G.; Ding, Y.; Shen, X. KNN: An Efficient KNN on GPU through Reconciliation between Redundancy Removal and Regularity. In Proceedings of the 33rd IEEE International Conference on Data Engineering (ICDE 2017); IEEE Computer Society: Los Alamitos, CA, USA, 2017; pp. 621–632. [Google Scholar] [CrossRef] [Scilit]
- Arefin, A.S.; Riveros, C.; Berretta, R.; Moscato, P. GPU-FS-kNN: A Software Tool for Fast and Scalable kNN Computation Using GPUs. PLoS ONE 2012, 7, e44000. [Google Scholar] [CrossRef] [Scilit]
- Mei, G.; Xu, N.; Xu, L. Improving GPU-accelerated Adaptive IDW Interpolation Algorithm Using Fast kNN Search. SpringerPlus 2016, 5, 1389. [Google Scholar] [CrossRef] [Scilit]
- Li, S.; Amenta, N. Brute-Force k-Nearest Neighbors Search on the GPU. In Proceedings of the 8th International Conference on Similarity Search and Applications (SISAP 2015); Lecture Notes in Computer Science; Springer: Cham, Switzerland, 2015; Volume 9371, pp. 259–270. [Google Scholar] [CrossRef] [Scilit]
- Komarov, I.; Dashti, A.; D’Souza, R.M. Fast k-NNG Construction with GPU-Based Quick Multi-Select. PLoS ONE 2014, 9, e92409. [Google Scholar] [CrossRef] [Scilit]
- Johnson, J.; Douze, M.; Jégou, H. Billion-Scale Similarity Search with GPUs. IEEE Trans. Big Data 2021, 7, 535–547. [Google Scholar] [CrossRef] [Scilit]
- Douze, M.; Guzhva, A.; Deng, C.; Johnson, J.; Szilvasy, G.; Mazaré, P.; Lomeli, M.; Hosseini, L.; Jégou, H. The Faiss Library. IEEE Trans. Big Data 2026, 12, 346–361. [Google Scholar] [CrossRef] [Scilit]
- You, S.; Zhang, J.; Gruenwald, L. Parallel Spatial Query Processing on GPUs Using R-Trees. In Proceedings of the 2nd ACM SIGSPATIAL International Workshop on Analytics for Big Geospatial Data (BigSpatial@SIGSPATIAL 2013); ACM: New York, NY, USA, 2013; pp. 23–31. [Google Scholar] [CrossRef] [Scilit]
- Zhang, J.; You, S. Speeding up Large-Scale Point-in-Polygon Test Based Spatial Join on GPUs. In Proceedings of the 1st ACM SIGSPATIAL International Workshop on Analytics for Big Geospatial Data (BigSpatial@SIGSPATIAL 2012); ACM: New York, NY, USA, 2012; pp. 23–32. [Google Scholar] [CrossRef] [Scilit]
- Zhang, J.; You, S.; Gruenwald, L. Data Parallel Quadtree Indexing and Spatial Query Processing of Complex Polygon Data on GPUs. In Proceedings of the VLDB International Workshop on Accelerating Data Management Systems Using Modern Processor and Storage Architectures (ADMS 2014), Hangzhou, China, 1–5 September 2014; pp. 13–24. Available online: http://www.adms-conf.org/2014/adms14_zhang.pdf (accessed on 19 September 2026).
- You, S.; Zhang, J.; Gruenwald, L. High-Performance Polyline Intersection Based Spatial Join on GPU-Accelerated Clusters. In Proceedings of the 5th ACM SIGSPATIAL International Workshop on Analytics for Big Geospatial Data (BigSpatial@SIGSPATIAL 2016); ACM: New York, NY, USA, 2016; pp. 42–49. [Google Scholar] [CrossRef] [Scilit]
- Zhang, J.; You, S.; Gruenwald, L. Parallel Selectivity Estimation for Optimizing Multidimensional Spatial Join Processing on GPUs. In Proceedings of the 33rd IEEE International Conference on Data Engineering (ICDE 2017); IEEE Computer Society: Los Alamitos, CA, USA, 2017; pp. 1591–1598. [Google Scholar] [CrossRef] [Scilit]
- Groh, F.; Ruppert, L.; Wieschollek, P.; Lensch, H.P.A. GGNN: Graph-Based GPU Nearest Neighbor Search. IEEE Trans. Big Data 2023, 9, 267–279. [Google Scholar] [CrossRef] [Scilit]
- Zhao, W.; Tan, S.; Li, P. SONG: Approximate Nearest Neighbor Search on GPU. In Proceedings of the 36th IEEE International Conference on Data Engineering (ICDE 2020); IEEE Computer Society: Los Alamitos, CA, USA, 2020; pp. 1033–1044. [Google Scholar] [CrossRef] [Scilit]
- Ootomo, H.; Naruse, A.; Nolet, C.; Wang, R.; Feher, T.; Wang, Y. CAGRA: Highly Parallel Graph Construction and Approximate Nearest Neighbor Search for GPUs. In Proceedings of the 40th IEEE International Conference on Data Engineering (ICDE 2024); IEEE Computer Society: Los Alamitos, CA, USA, 2024; pp. 4236–4247. [Google Scholar] [CrossRef] [Scilit]
- V., K.; Khan, S.; Singh, S.; Simhadri, H.V.; Vedurada, J. BANG: Billion-Scale Approximate Nearest Neighbor Search using a Single GPU. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Gui, Y.; Yin, P.; Yan, X.; Zhang, C.; Zhang, W.; Cheng, J. PilotANN: Memory-Bounded GPU Acceleration for Vector Search. In Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining V.1 (KDD 2026); ACM: New York, NY, USA, 2026; pp. 348–358. [Google Scholar] [CrossRef] [Scilit]
- Pan, J.; Manocha, D. Fast GPU-based locality sensitive hashing for k-nearest neighbor computation. In Proceedings of the 19th ACM SIGSPATIAL International Symposium on Advances in Geographic Information Systems (ACM-GIS 2011); ACM: New York, NY, USA, 2011; pp. 211–220. [Google Scholar] [CrossRef] [Scilit]
- Shi, X.; Xu, S.; Knight, K. Fast Locality Sensitive Hashing for Beam Search on GPU. arXiv 2018. [Google Scholar] [CrossRef] [Scilit]
- Mandarapu, D.K.; Nagarajan, V.; Pelenitsyn, A.; Kulkarni, M. Arkade: k-Nearest Neighbor Search With Non-Euclidean Distances using GPU Ray Tracing. In Proceedings of the 38th ACM International Conference on Supercomputing (ICS 2024); ACM: New York, NY, USA, 2024; pp. 14–25. [Google Scholar] [CrossRef] [Scilit]
- Leite, P.J.S.; Teixeira, J.M.X.N.; de Farias, T.S.M.C.; Teichrieb, V.; Kelner, J. Massively Parallel Nearest Neighbor Queries for Dynamic Point Clouds on the GPU. In Proceedings of the 21st International Symposium on Computer Architecture and High Performance Computing (SBAC-PAD 2009); IEEE Computer Society: Los Alamitos, CA, USA, 2009; pp. 19–25. [Google Scholar] [CrossRef] [Scilit]
- Thrust: Parallel Algorithms Library. Available online: https://developer.nvidia.com/thrust (accessed on 30 August 2026).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Published by MDPI on behalf of the International Society for Photogrammetry and Remote Sensing. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.










