融合内核库:用于开发高效GPU库的C++ API
The Fused Kernel Library: A C++ API to Develop Highly-Efficient GPU Libraries
AI总结:
针对现有GPU库多函数串联时资源利用率低、融合内核开发成本高的问题,提出基于C++17元编程的GPU库构建方法,可编译期自动生成定制融合内核,实现2至1000倍以上性能提升,同时保留高级可编程性。
摘要:
现有的GPU库在将多个GPU函数作为独立内核串联调用时,往往难以充分利用GPU的并行资源和片上存储器(SRAM)。尽管水平融合(HF)、垂直融合(VF)等内核融合(KF)技术能够缓解这一问题,但当前的库实现通常要求库开发者手动创建融合内核,因此库用户只能依赖数量有限的预编译或基于模板的融合内核。这限制了可从HF和VF中获益的应用场景,同时提升了开发成本。为解决这些问题,我们提出了一种构建GPU库的全新方法,可针对GPU库函数的任意组合实现按需自动的水平融合与垂直融合。该方法定义了可复用、可融合的组件,用户可通过高级编程接口对其进行组合。借助nvcc等编译器支持的C++17元编程特性,我们的方法可在编译期生成针对用户特定操作序列定制的单个优化融合内核,无需自定义编译器,也无需手动开发和预编译内核组合。该方法在抽象GPU底层复杂度的同时,最大化了GPU资源利用率,并将中间数据保留在SRAM中。我们提供了一个开源实现,在多项基准测试中相比传统库实现了显著的速度提升,验证了该方法在提升GPU性能方面的有效性——性能提升幅度可达2倍到1000倍以上,同时保留了高级可编程性。
英文摘要:
Existing GPU libraries often struggle to fully exploit the parallel resources and on-chip memory (SRAM) of GPUs when chaining multiple GPU functions as individual kernels. While Kernel Fusion (KF) techniques like Horizontal Fusion (HF) and Vertical Fusion (VF) can mitigate this, current library implementations often require library developers to manually create fused kernels. Hence, library users rely on limited sets of pre-compiled or template-based fused kernels. This limits the use cases that can benefit from HF and VF and increases development costs. In order to solve these issues, we present a novel methodology for building GPU libraries that enables automatic on-demand HF and VF for arbitrary combinations of GPU library functions. Our methodology defines reusable, fusionable components that users combine via high-level programming interfaces. Leveraging C++17 metaprogramming features available in compilers like nvcc, our methodology generates a single and optimized fused kernel tailored to the user's specific sequence of operations at compile time, without needing a custom compiler or manual development and pre-compilation of kernel combinations. This approach abstracts low-level GPU complexities while maximizing GPU resource utilization and keeping intermediate data in SRAM. We provide an open-source implementation demonstrating significant speedups compared to traditional libraries in various benchmarks, validating the effectiveness of this methodology for improving GPU performance in the range of 2x to more than 1000x, while preserving high-level programmability.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。