TL;DR
The authors present a Python-based framework for synthesizing and optimizing high-performance assembly code for streaming numerical kernels. By applying advanced instruction scheduling and novel SIMD strategies to the IBM Blue Gene/P's PowerPC 450 processor, they achieved a 1.7x speedup on complex 27-point stencils compared to previous state-of-the-art results.
What Problem Does This Paper Address?
In scientific computing, solving partial differential equations (PDEs) often relies on "stencil kernels"—computations that update a point in a grid based on its neighbors. While these operations are ubiquitous, they are notoriously difficult to optimize on modern energy-efficient supercomputers like the IBM Blue Gene/P.
The challenge is twofold:
- Hardware Constraints: The PowerPC 450 processor uses "in-order" execution, meaning it doesn't automatically reorder instructions to avoid stalls. It also relies heavily on vectorization (SIMD) to reach peak performance.
- Compiler Limitations: Standard C and Fortran compilers often struggle to generate the precise, low-level instruction sequences needed to fully saturate these processors. As a result, many scientific applications achieve only a small fraction of the hardware's theoretical peak performance.
Methods
The researchers developed a high-level assembly synthesis and optimization framework written in Python. Instead of writing raw assembly by hand, they used Python to generate and schedule instruction sequences. Key components include:
- Novel Sub-Kernels: They introduced two strategies for handling the "odd cardinality" of stencils (where input and output alignments don't match perfectly):
- Mutate-Mutate (mm): Heavily utilizes the Load/Store Unit (LSU) to shift data within registers.
- Load-Copy (lc): Shifts the burden to the Floating Point Unit (FPU) by using register-to-register copies.
- Unroll-and-Jam: A technique that unrolls outer loops and "jams" them together to increase data reuse (arithmetic intensity) and reduce redundant memory loads.
- Automated Scheduling: They modeled instruction scheduling as an Integer Linear Programming (ILP) problem to find the optimal order of instructions that avoids pipeline hazards and maximizes throughput.
- Custom Simulator: A built-in PowerPC 450 simulator allowed the team to verify the correctness of the generated code and predict performance before running it on the actual supercomputer.
Datasets
The paper evaluates the framework using three standard numerical operators:
- 3-Point Stencil (1D): The simplest case, used as a building block.
- 7-Point Stencil (3D): Commonly used for Laplace kernels.
- 27-Point Stencil (3D): A more complex "boxier" operator used in benchmarks like the NASA Advanced Supercomputing (NAS) Multi-Grid (MG).
- Evaluation Range: Tests were conducted on cubic grid sizes ranging from $14^3$ to $362^3$ to observe performance across different cache levels (L1, L3, and main memory).
Key Insights and Ideas
- The Power of Python for Assembly: Using a high-level language to generate low-level code provides the "best of both worlds"—the productivity of Python with the performance of hand-tuned assembly.
- Balancing the Pipeline: By switching between "mutate-mutate" and "load-copy" kernels, developers can balance the pressure between the processor's memory unit and its math unit, depending on which is the current bottleneck.
- Predictability of In-Order Chips: While in-order processors are difficult for humans to program, their lack of "magic" reordering makes them highly predictable. This makes them ideal targets for automated optimization tools.
- Arithmetic Intensity is King: The 27-point stencil scales better than simpler stencils because it allows for much higher data reuse, making it "FPU-bound" rather than "memory-bound."
Key Results
- Significant Speedup: The 27-point stencil achieved a 1.7x speedup over the best previously published results for this architecture.
- Peak Performance: The optimized 27-point stencil reached 54 Mstencil/s, which represents roughly 85% of the theoretical arithmetic peak of the processor.
- Model Accuracy: The framework's simulator was incredibly accurate for data residing in the L1 cache, with a disparity between predicted and actual performance of less than 1%.
- Scaling: The "unroll-and-jam" approach showed nearly perfect scaling as the number of jammed iterations increased from 1 to 6.
Limitations and Future Work
- Memory Subsystem Modeling: The simulator’s accuracy degrades (up to 17.5% error) when data moves out of the L1 cache into the L3 or main memory. This is because the model doesn't fully account for shared bandwidth between cores or the complexities of the L2 prefetcher.
- Generalization: The current work focuses on constant-coefficient stencils with specific symmetries.
- Future Directions: The authors plan to extend the framework to handle:
- Higher-order stencils (wider neighborhoods).
- Irregular stencils and spatially varying coefficients.
- Chained iterative passes to further increase arithmetic intensity.
Summary updated