Sorting is one of the most basic algorithms, and developing highly parallel sorting programs is becoming increasingly important in high-performance computing because the number of CPU cores per node in modern supercomputers tends to increase. In this study, we have implemented two multi-threaded sorting algorithms based on samplesort and compared their performance on the supercomputer Fugaku. The first algorithm divides an input sequence into multiple blocks, sorts each block, and then selects pivots by sampling from each block at regular intervals. Each block is then partitioned using the pivots, and partitions in different blocks are merged into a single sorted sequence. The second algorithm differs from the first one in only selecting pivots, where the binary search is used to select pivots such that the number of elements in each partition is equal. We compare the performance of the two algorithms with different sequential sorting and multiway merging algorithms. We demonstrate that the second algorithm with BlockQuicksort (a quicksort accelerated by reducing conditional branches) for sequential sorting and the selection tree for merging shows consistently high speed and high parallel efficiency for various input data types and data sizes.
翻译:排序是最基础的算法之一,随着现代超级计算机每节点CPU核心数量的增加,开发高度并行的排序程序在高性能计算中变得愈发重要。本研究基于样本排序法实现了两种多线程排序算法,并在超级计算机Fugaku上比较了它们的性能。第一种算法将输入序列划分为多个块,对每个块进行排序,然后从每个块中等间距采样选取枢轴,随后利用枢轴对块进行划分,并将不同块的划分结果合并为单一有序序列。第二种算法与第一种仅在枢轴选取方式上存在差异:它采用二分搜索选取枢轴,使得每个分区中的元素数量相等。我们比较了两种算法在不同顺序排序和多路归并算法组合下的性能。实验表明,使用BlockQuicksort(一种通过减少条件分支来加速的快速排序)进行顺序排序、并采用选择树进行归并的第二种算法,在各种输入数据类型和数据规模下均能保持高速与高并行效率。