arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1506.08620cs.DS
收藏

一种适用于大范围浮点数排序数组的O(1)快速向量化二进制搜索算法

Fast and Vectorizable Alternative to Binary Search in O(1) Applicable to a Wide Domain of Sorted Arrays of Floating Point Numbers

Fabio Cannizzo

摘要:

给定$N+1$的严格有序浮点数的阵列$X$和区间$[X_0,X_N)$中的浮点数$z$,常见的问题是找到包含$z$的区间$[X_{i},X_{i+1})$的索引$i$。例如,在样条插值或从经验数据计算经验概率分布的情况下会出现这个问题。通常,需要针对大量不同的值$z$和相同的数组$X$来求解该问题,这使得值得预先在预处理数组$X$时投入资源,以加速后续的搜索操作。在某些情况下,要处理的值$z$在大小为$M$的块中同时已知,这提供了利用现代CPU的并行能力以矢量方式解决问题的机会。常见的解决方案是顺序地调用$M$乘以公知的二进制搜索算法,该二进制搜索算法在每个单独的搜索中具有$O(log_2 N)$的复杂度,并且在其经典公式中是不可向量化的,即不是SIMD友好的。本文描述了对二分查找算法的技术改进,使其更快和可向量化。接下来,它提出了一个新的矢量化算法,索引技术的基础上,适用于广泛的家庭的$X$分区,解决了问题的复杂性$O(1)$每个单独的搜索的成本引入初始开销计算索引,并需要额外的内存存储。使用流SIMD扩展的测试结果比较了算法与各种基准的性能,并证明了其有效性。根据测试用例,该算法可以产生比经典二分搜索大两个数量级的吞吐量。适用性的限制和高速缓存友好性相关的方面进行了讨论。

英文摘要:

Given an array $X$ of $N+1$ strictly ordered floating point numbers and a floating point number $z$ in the interval $[X_0,X_N)$, a common problem is to find the index $i$ of the interval $[X_{i},X_{i+1})$ containing $z$. This problem arises for instance in the context of spline interpolation or the computation of empirical probability distribution from empirical data. Often it needs to be solved for a large number of different values $z$ and the same array $X$, which makes it worth investing resources upfront in pre-processing the array $X$ with the goal of speeding up subsequent search operations. In some cases the values $z$ to be processed are known simultaneously in blocks of size $M$, which offers the opportunity to solve the problem vectorially, exploiting the parallel capabilities of modern CPUs. The common solution is to sequentially invoke $M$ times the well known binary search algorithm, which has complexity $O(log_2 N)$ per individual search and, in its classic formulation, is not vectorizable, i.e. is not SIMD friendly. This paper describes technical improvements to the binary search algorithm, which make it faster and vectorizable. Next it proposes a new vectorizable algorithm, based on an indexing technique, applicable to a wide family of $X$ partitions, which solves the problem with complexity $O(1)$ per individual search at the cost of introducing an initial overhead to compute the index and requiring extra memory for its storage. Test results using streaming SIMD extensions compare the performance of the algorithm versus various benchmarks and demonstrate its effectiveness. Depending on the test case, the algorithm can produce a throughput up to two orders of magnitude larger than the classic binary search. Applicability limitations and cache-friendliness related aspects are also discussed.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑