Objective When utilizing a kd-tree for large-scale random particle nearest neighbor search, particles with closely aligned index values within the computational domain can become spatially distant, resulting in significant variations in the kd-tree search path over a short time frame. Therefore, this divergence reduces the efficiency of accessing node data and ultimately impedes the effectiveness of kd-tree nearest neighbor searches. This inefficiency becomes particularly evident in non-uniform or randomized particle distributions, where traditional cache optimization strategies show limited effectiveness. Maximum dispersion dimensionality reduction in principal component analysis (PCA) is introduced to address this issue. It employs the mean absolute difference (MAD) as the dispersion measure and proposes a novel cache optimization strategy named MAD-index-sort. MAD-index-sort improves cache utilization and enhances the overall performance of kd-tree-based nearest neighbor searches by dynamically reordering particle index values based on spatial distribution. Methods The MAD-index-sort strategy introduced in this study utilized the dimensionality reduction principles found in PCA to achieve optimal data reordering. Specifically, the method employed MAD as a dispersion measure, which served as the key metric for determining the most appropriate dimension along which the particle data should be reordered. By calculating the dimension with the highest MAD value, identifying the axis along which particle distribution exhibited the greatest variance, the algorithm ensured that particles with closer spatial proximity were assigned similar index values, thus optimizing data access during kd-tree searches. This reordering process, in turn, enabled more efficient cache usage because it minimized cache misses and increased the likelihood of retrieving relevant data from faster memory. The proposed approach was then integrated with the automatic termination criterion for the kd-tree framework, which further streamlined the nearest neighbor search process by automatically halting the search once optimal criteria were met, reducing unnecessary computations. A series of rigorous experimental trials was conducted using various particle distribution models, including uniform, random, and clustered configurations to comprehensively evaluate the effectiveness of this approach. Key performance metrics, such as cache miss rates, search path divergence, and total computational time, were carefully monitored and compared against baseline methods, including Z-index-sort, which was traditionally employed for uniform grid methods, and the standard unsorted kd-tree approach. Results and Discussions The experimental results revealed that the MAD-index-sort strategy consistently surpassed both traditional unsorted kd-tree methods and alternative sorting strategies such as Z-index-sort across various particle distribution scenarios. Specifically, MAD-index-sort improved search efficiency by dynamically adjusting to particle dispersion characteristics, which led to a marked reduction in cache misses and overall computational time. When applied to randomized particle distributions with high spatial divergence, MAD-index-sort significantly decreased the cache miss rate. Compared to the unsorted kd-tree, the cache miss rate was reduced by 24.2%, while compared to Z-index-sort, the reduction was 18.6%. In addition, the improved performance was particularly evident in computational fluid dynamics (CFD) simulations, where particle positions frequently shifted irregularly due to external forces. In this context, MAD-index-sort dynamically adapted to the shifting particle arrangement, reduced cache miss rates by 20%, and simultaneously cut the total computational time by 15% compared to the unsorted kd-tree method. The algorithm was versatile enough to handle both static and dynamic conditions, making it highly reliable for real-time applications where particle distributions tended to change unpredictably. In addition, the results indicated that MAD-index-sort performed exceptionally well in scenarios involving highly dispersed particle clusters. In these cases, the search time was shortened by 28.5% compared to the unsorted kd-tree and by 22% compared to Z-index-sort. This efficiency was attributed to MAD-index-sort's ability to reorder particles based on the dimension with the greatest variance, ensuring that spatially close particles were assigned similar index values. Therefore, the cache access pattern was optimized, which led to fewer cache misses and improved search times. In addition, MAD-index-sort demonstrated a significant performance boost, achieving search times 32.8% faster than unsorted kd-tree methods, with a 30% reduction in cache miss rates. These findings indicated that MAD-index-sort was effective in handling irregular particle distributions and further demonstrated its versatility and adaptability. Further analysis revealed that MAD-index-sort consistently improved the cache hit rates across all tested particle distribution models. For example, in scenarios characterized by extreme spatial variance, the strategy attained an average 27.3% reduction in computational time, coupled with a 17% improvement in cache hit rates, compared to traditional methods. This broad applicability of the MAD-index-sort strategy highlighted its effectiveness in a wide range of computational tasks that required efficient data access, particularly in systems where memory hierarchy played a crucial role in performance. Accordingly, the experimental results validated the efficiency and flexibility of the MAD-index-sort strategy, showing that it significantly reduced cache misses and improved search performance across a wide variety of particle distribution scenarios. MAD-index-sort optimized cache utilization and minimized computational overhead by dynamically adjusting the index sorting process based on particle dispersion, making it a practical tool for kd-tree-based nearest neighbor searches in different environments. Conclusions The introduction of the MAD-index-sort strategy represents a meaningful enhancement in kd-tree-based nearest neighbor search optimization, particularly for scenarios involving random or highly dispersed particle distributions. The strategy improves cache efficiency, reduces computational overhead, and enhances overall search performance by incorporating PCA-inspired dimensionality reduction and using the MAD metric to dynamically reorder particle indices. The experimental results indicate that MAD-index-sort can improve search efficiency by up to 30.3% compared to unsorted kd-tree searches, making it a highly adaptable and versatile tool for a wide range of computational applications. The implications of this research extend beyond kd-tree nearest neighbor searches, as the underlying principles of dynamic index reordering and cache optimization can be applied to other computational problems where data access efficiency is critical. Future work can investigate integrating MAD-index-sort with advanced cache management techniques, such as predictive caching algorithms or hybrid data structures, to enhance performance. In addition, further research on reducing the computational complexity of distance calculations, particularly in high-dimensional spaces, can yield greater efficiency gains and make kd-tree-based methods more suitable for large-scale, real-time applications.
为解决该问题,本文提出了基于平均绝对差粒子索引值排序(mean absolute deviation index sort,MAD-index-sort)的缓存优化策略,引入了主成分分析(PCA)中最大离散度降维[27]的思想,采用平均绝对差(MAD)[28‒31]作为离散度衡量指标,通过计算粒子集群平均绝对差最大的维度来实现数据降维,进而完成粒子的索引值重排序。在此基础上,构建kd-tree树形结构,应用kd-tree自动终止准则(ATC-kd-tree)[12],求解近邻搜索问题,进而优化近邻搜索过程中的缓存命中情况。选取流体力学中常见布点形状进行系列实验,分析粒子均匀布点与随机布点下kd-tree近邻搜索效率存在差异的原因,并且设置两种近邻搜索对比方案,验证其性能。
PlazaE, Di G SigalottiL, PérezL,et al.Efficiency of particle search methods in smoothed particle hydrodynamics:A comparative study (partⅠ)[J].Progress in Computational Fluid Dynamics,an International Journal,2021,21(1):1. doi:10.1504/pcfd.2021.112625
[3]
GuoZhongzhou, HeZhiqiang, ZhaoWenwen,et al.Efficient mesh deformation and flowfield interpolation method for unstructured mesh[J].Acta Aeronautica et Astronautica Sinica,2018,39(12):122411.
ZhaoWeiming.Application of automatic analysis of image data based on kd-tree in ray tracing technology[J].MATEC Web of Conferences,2022,365:01028. doi:10.1051/matecconf/202236501028
[10]
HuLinjia, NooshabadiS.High-dimensional image descriptor matching using highly parallel kd-tree construction and approximate nearest neighbor search[J].Journal of Parallel and Distributed Computing,2019,132:127‒140. doi:10.1016/j.jpdc.2019.06.003
[11]
MaoChengying, ZhanXuzheng, TseT H,et al.KDFC-ART:A KD-tree approach to enhancing fixed-size-candidate-set Adaptive Random Testing[J].IEEE Transactions on Reliability,2019,68(4):1444‒1469. doi:10.1109/tr.2019.2892230
[12]
XiangFeng, LiZhongzhi, XiongXi,et al.Inverse distance weight interpolation algorithm based on particle swarm local optimization[J].Journal of Computer Applications,2023,43(2):385‒390.
GidaspovV Y, MorozovA Y, ReviznikovD L.Adaptive interpolation algorithm using TT-decomposition for modeling dynamical systems with interval parameters[J].Computational Mathematics and Mathematical Physics,2021,61(9):1387‒1400. doi:10.1134/s0965542521090098
[15]
MaJing, LiLi.Optimization of distributed K-means algorithm with RDD-based extended index layer[J].Computer Engineering and Applications,2019,55(1):161‒167.
GuoZhongzhou, HeZhiqiang, XiaChenchao,et al.KD tree method for efficient wall distance computation of mesh[J].Journal of National University of Defense Technology,2017,39(4):21‒25.
NieFeiping, XueJingjing, WuDanyang,et al.Coordinate descent method for k-means[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2022,44(5):2371‒2385.
[22]
MahmudM P, WiedenhoeftJ, SchliepA.Indel-tolerant read mapping with trinucleotide frequencies using cache-oblivious kd-trees[J].Bioinformatics,2012,28(18):i325‒i332. doi:10.1093/bioinformatics/bts380
[23]
NiYufei, DengYangdong, LiZonghui.Agglomerative memory and thread scheduling for high-performance ray-tracing on GPUs[J].IEEE Transactions on Computer‒Aided Design of Integrated Circuits and Systems,2022,41(2):334‒345. doi:10.1109/tcad.2021.3058910
[24]
ShiZhiyuan, XuWeiming, MengHao.A point cloud simplification algorithm based on weighted feature indexes for 3D scanning sensors[J].Sensors,2022,22(19):7491. doi:10.3390/s22197491
[25]
LiangXiao, YangHongyu, ZhangYanci,et al.Efficient kd-tree construction for ray tracing using ray distribution sampling[J].Multimedia Tools and Applications,2016,75(23):15881‒15899. doi:10.1007/s11042-015-2896-7
[26]
ShiXiaojing, LiuTao, HanXie.Improved Iterative Closest Point (ICP) 3D point cloud registration algorithm based on point cloud filtering and adaptive fireworks for coarse registration[J].International Journal of Remote Sensing,2020,41(8):3197‒3220. doi:10.1080/01431161.2019.1701211
[27]
ChoiW S, OhS Y.Fast nearest neighbor search using approximate cached k-d tree[C]//Proceedings of the 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems.Vilamoura:IEEE,2012:4524‒4529. doi:10.1109/iros.2012.6385837
[28]
NuchterA, LingemannK, HertzbergJ.Cached k-d tree search for ICP algorithms[C]//Proceedings of the Sixth International Conference on 3-D Digital Imaging and Modeling (3DIM 2007).Montreal:IEEE,2007:419‒426. doi:10.1109/3dim.2007.15
TsuzukiS, AokiT.Effective dynamic load balance using space-filling curves for large-scale SPH simulations on GPU-rich supercomputers[C]//Proceedings of the 2016 7th Workshop on Latest Advances in Scalable Algorithms for Large-Scale Systems (ScalA).Salt Lake City:IEEE,2016:1‒8. doi:10.1109/scala.2016.005
JinKaizhong, ZhangXiaojian, PengHuili.KD-TSS:Accurate method for private spatial decomposition[J].Journal of Frontiers of Computer Science and Technology,2017,11(10):1579‒1590.
YoshidaR, ZhangL, ZhangXu.Tropical principal component analysis and its application to phylogenetics[J].Bulletin of Mathematical Biology,2019,81(2):568‒597. doi:10.1007/s11538-018-0493-4
[36]
VerdeS, MilaniS, CalvagnoG.Phylogenetic analysis of software using cache miss statistics[C]//Proceedings of the ICASSP 2019-2019 IEEE International Conference on Acoustics,Speech and Signal Processing (ICASSP).Brighton:IEEE,2019:2552‒2556. doi:10.1109/icassp.2019.8683834
[37]
PalA K, MondalP K, GhoshA K.High dimensional nearest neighbor classification based on mean absolute differences of inter-point distances[J].Pattern Recognition Letters,2016,74:1‒8. doi:10.1016/j.patrec.2016.01.018
[38]
KogaS, KomikadoA, MurayamaY,et al.OL07-1 Time-dependent sensor performance is sustained during 4 years:Accuracy measurement with mean absolute difference (MAD) in continuous glucose monitoring (CGM)[J].Diabetes Research and Clinical Practice,2016,120:S55. doi:10.1016/s0168-8227(16)31035-x
[39]
KlongdeeW, PongkitwitoonM.Forecasting techniques based on absolute difference for small dataset to predict the SET index in Thailand[J].Engineering and Applied Science Research,2018,45(4):308‒311.
[40]
ZhangTing, RenYufei, YangZhiqiang,et al.Generalized finite difference method for non-linear free-surface problems of liquid sloshing[J].Journal of Sichuan University (Engineering Science Edition),2016,48(1):8‒14.
ZhangTing, ZhangSiqian, YangDingying,et al.Numerical investigation on competitive mechanism between internal and external effects of submarine pipeline undergoing vortex-induced vibration[J].Ocean Engineering,2022,266:112744. doi:10.1016/j.oceaneng.2022.112744
[43]
LiJianfeng, TanYaohua, LiaoShenghui.Highly parallel SAH-KD-tree construction for raytracing[J].Journal of Hunan University (Natural Sciences),2018,45(10):148‒154.