arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2405.14642cs.DCcs.MScs.PL
收藏

中等规模整数加法与乘法的GPU实现

GPU Implementations for Midsize Integer Addition and Multiplication

Cosmin E. Oancea, Stephen M. Watt

AI总结:

本文提出在GPU上使用高级函数式语言实现中等规模整数加法和乘法的简洁方案,利用扫描和简单工作划分,FFT乘法在较大尺寸上优于经典方法,原型在超过32K比特时胜过CGBN库。

摘要:

本文探讨了使用高级函数式语言在GPU上进行“中等规模”整数算术运算的实际方面。这里的中等规模指的是最多约25万比特的整数,这足以满足大多数实际用途。目标是理解是否有可能以一个小而灵活的代码库支持高效的嵌套并行程序。我们报告了适合单个CUDA块的整数加法和乘法的GPU实现,从而利用便签式存储器的时间复用。我们的关键贡献在于所提出方案的简洁性:我们认识到加法是扫描(scan)的直接应用,而扫描已知允许高效的GPU实现。对于二次乘法,我们采用了一种简单的工作划分策略,该策略提供了良好的时间局部性。对于FFT乘法,我们通过寻找“好的”素数,使得机器字几乎完全被利用,从而在整数字段域内高效地映射计算。相比之下,相关工作使用了复杂的平铺策略——这感觉像是用大锤打蚊子——或者使用实数计算域,这可能会降低计算所基于的基数的大小。我们将性能与NvidiaLab编写的先进CGBN库进行了比较,并报告我们的CUDA原型在整数大小超过32K比特时优于CGBN,而在较小尺寸时提供可比的性能。此外,据我们所知,我们是第一个报告在仍适合单个CUDA块的较大尺寸上,FFT乘法优于经典乘法的结果。最后,我们考察了Futhark在高效支持此类计算方面的优缺点,并发现一个旨在高效串行化多余并行的编译器遍将显著提高性能。

英文摘要:

This paper explores practical aspects of using a high-level functional language for GPU-based arithmetic on ``midsize'' integers. By this we mean integers of up to about a quarter million bits, which is sufficient for most practical purposes. The goal is to understand whether it is possible to support efficient nested-parallel programs with a small, flexible code base. We report on GPU implementations for addition and multiplication of integers that fit in one CUDA block, thus leveraging temporal reuse from scratchpad memories. Our key contribution resides in the simplicity of the proposed solutions: We recognize that addition is a straightforward application of scan, which is known to allow efficient GPU implementation. For quadratic multiplication we employ a simple work-partitioning strategy that offers good temporal locality. For FFT multiplication, we efficiently map the computation in the domain of integral fields by finding ``good'' primes that enable almost-full utilization of machine words. In comparison, related work uses complex tiling strategies -- which feel too big a hammer for the job -- or uses the computational domain of reals, which may degrade the magnitude of the base in which the computation is carried. We evaluate the performance in comparison to the state-of-the-art CGBN library, authored by NvidiaLab, and report that our CUDA prototype outperforms CGBN for integer sizes higher than 32K bits, while offering comparable performance for smaller sizes. Moreover, we are, to our knowledge, the first to report that FFT multiplication outperforms the classical one on the larger sizes that still fit in a CUDA block. Finally, we examine Futhark's strengths and weaknesses for efficiently supporting such computations and find out that a compiler pass aimed at efficient sequentialization of excess parallelism would significantly improve performance.

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

↑