Introduction
Image processing pipelines, essential for applications ranging from mobile photography to medical imaging, are typically structured as Directed Acyclic Graphs (DAGs) of mathematical operations. To optimize these pipelines for GPUs, compilers often employ overlapped tiling. This technique partitions the image into tiles and computes redundant "halo" pixels at boundaries to enable parallel processing without frequent inter-tile communication.
However, existing state-of-the-art tools like Halide and Forma face significant performance bottlenecks. First, mapping tiles to "thread blocks" incurs a high synchronization cost due to the need for __syncthreads between stages. Second, large tiles intended to minimize redundant work often consume excessive shared memory, leading to low occupancy—a situation where the GPU cannot run enough concurrent tasks to hide latency. Finally, many automatic schedulers rely on simplified models that fail to capture the nuances of modern GPU memory hierarchies and transaction costs.
The PolyMage-GPU Framework
To address these challenges, the authors introduce PolyMage-GPU, a compiler framework that shifts the fundamental unit of work from the thread block to the warp. The system follows a structured pipeline to transform high-level domain-specific language (DSL) specifications into optimized CUDA code.
The framework integrates three primary innovations:
- Overlap Tile per Warp (OTPW): By assigning tiles to warps (groups of 32 threads) rather than larger thread blocks, PolyMage-GPU leverages hardware-level synchronization. This allows the use of
__syncwarp, a significantly lighter primitive than block-level synchronization, reducing instruction issue stalls. - Hybrid Tiling: This strategy optimizes memory usage by partitioning intermediate data between shared memory and registers.
- Model-Based Auto-scheduling: A sophisticated cost model guides the selection of tile sizes and fusion strategies, accounting for global memory bandwidth, occupancy, and the overhead of redundant computations.
Hybrid Tiling and Warp-Level Execution
A core contribution of PolyMage-GPU is the "hybrid" storage approach. Traditionally, registers are private to individual threads. PolyMage-GPU utilizes warp shuffle instructions (__shfl_sync) to enable threads within a warp to access each other's registers directly.
As illustrated in the figure above, this hybrid approach allows a portion of the intermediate data (e.g., for the blurx and blury stages) to be stored in registers rather than shared memory. This reduction in shared memory pressure is critical; it allows more warps to reside on the GPU simultaneously, thereby increasing occupancy and improving the hardware's ability to hide memory latency.
Evaluation and Results
The framework was evaluated using six canonical benchmarks: Unsharp Mask (UM), Harris Corner (HC), Bilateral Grid (BG), Multiscale Interpolation (MI), Camera Pipeline (CP), and Pyramid Blend (PB). These benchmarks vary in complexity from 4 to 49 stages and were tested on NVIDIA GTX 1080Ti (Pascal) and Tesla V100 (Volta) architectures.
Key findings include:
- Performance Gains: PolyMage-GPU achieved up to a 1.65x speedup over hand-tuned Halide schedules on the GTX 1080Ti and 1.33x on the Tesla V100.
- Efficiency: The OTPW model effectively eliminated stalls associated with thread-block synchronization. In benchmarks like Harris Corner, hybrid tiling significantly improved occupancy by optimizing resource allocation.
- Search Efficiency: Unlike traditional autotuners that may require up to 20 hours of search time, the model-based approach in PolyMage-GPU identifies optimal schedules within seconds to minutes.
Conclusion
PolyMage-GPU demonstrates that the warp is the "sweet spot" for image processing tiling on GPUs. By treating the register file as an ultra-fast scratchpad through shuffle instructions and employing a robust cost model, the framework overcomes the occupancy-redundancy trade-off that limits prior tools. While some specialized optimizations in Halide (such as specific inlining for the Bilateral Grid) remain competitive, PolyMage-GPU provides a highly efficient, automated path to high-performance GPU code for complex image processing pipelines. Future work may extend these techniques to non-stencil patterns and newer hardware features like Tensor Cores.
Summary updated