[Paper Review] Automatic Horizontal Fusion for GPU Kernels
This paper introduces automatic horizontal fusion, a novel CUDA compiler optimization that increases thread-level parallelism to hide instruction latencies by co-locating threads from different kernels in a single fused kernel. HFuse, the proposed source-to-source compiler, automatically partitions thread IDs and inserts branch conditions to route execution, achieving up to 60.8% speedup over native kernels, especially for mixed-resource kernels like memory- and compute-intensive ones.
We present automatic horizontal fusion, a novel optimization technique that complements the standard kernel fusion techniques for GPU programs. Unlike the standard fusion, whose goal is to eliminate intermediate data round trips, our horizontal fusion technique aims to increase the thread-level parallelism to hide instruction latencies. We also present HFuse, a new source to source CUDA compiler that implements automatic horizontal fusion. Our experimental results show that horizontal fusion can speed up the running time by 2.5%-60.8%. Our results reveal that the horizontal fusion is especially beneficial for fusing kernels with instructions that require different kinds of GPU resources (e.g., a memory-intensive kernel and a compute-intensive kernel).
Motivation & Objective
- Address the performance bottleneck in GPU kernels caused by instruction-level latencies, especially when standard vertical fusion is ineffective.
- Overcome the limitations of vertical kernel fusion, which focuses on eliminating memory round trips but does not improve thread-level parallelism.
- Enable automatic fusion of kernels with heterogeneous resource requirements (e.g., memory-intensive and compute-intensive) to better utilize GPU hardware.
- Develop a source-to-source compiler (HFuse) that automatically handles thread space partitioning and synchronization barriers for horizontal fusion.
- Improve overall kernel throughput by exploiting warp scheduler interleave capabilities through co-located, heterogeneous kernel threads.
Proposed method
- Partition the thread block of the fused kernel into two intervals based on thread ID, assigning each interval to one of the original kernels.
- Insert conditional branches in the fused kernel that route each thread to the corresponding kernel’s instruction sequence based on its thread ID.
- Use inline PTX assembly and instrumented branch conditions to implement kernel-specific synchronization barriers that do not stall unrelated threads.
- Apply an automatic profiling technique to explore and identify the optimal thread space partitioning scheme for performance.
- Integrate the horizontal fusion technique into a source-to-source CUDA compiler (HFuse) that generates functionally equivalent, optimized kernels.
- Balance thread-level and block-level parallelism by analyzing register and shared memory usage during fusion.
Experimental results
Research questions
- RQ1Can horizontal fusion improve performance beyond vertical fusion by increasing thread-level parallelism and hiding instruction latencies?
- RQ2How can synchronization barriers from one original kernel be safely handled in a horizontally fused kernel without stalling unrelated threads?
- RQ3What is the optimal thread space partitioning strategy for horizontally fused kernels to maximize performance?
- RQ4Does horizontal fusion provide measurable speedups for kernels with mixed hardware resource requirements (e.g., memory vs. compute)?
- RQ5Can automatic horizontal fusion outperform both native and vertically fused kernels in real-world workloads like deep learning and cryptocurrency mining?
Key findings
- HFuse achieved up to 60.8% speedup over native kernels on 1080Ti and V100 GPUs, with 7 out of 16 pairs on 1080Ti and 6 on V100 outperforming both native and vertically fused kernels.
- Horizontal fusion was especially effective for fusing kernels with different resource intensities—e.g., memory-intensive and compute-intensive kernels—due to better utilization of GPU execution units.
- The performance gain primarily stems from the warp scheduler’s ability to interleave instructions from different kernels, effectively hiding instruction-level latencies.
- The automatic thread partitioning via profiling significantly improved performance, as suboptimal partitioning could degrade performance due to increased register and shared memory pressure.
- Horizontal fusion outperformed vertical fusion in scenarios where vertical fusion offered no benefit (e.g., when memory traffic was not the bottleneck), demonstrating its complementary nature.
- The study revealed a trade-off between thread-level and block-level parallelism: while horizontal fusion increases thread-level parallelism, it increases register and shared memory usage, requiring careful optimization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.