In the landscape of high-performance computing, the "memory wall" remains a primary bottleneck. While processor speeds have scaled exponentially, memory latency has lagged behind, making data movement the most expensive part of a computation. To mitigate this, compilers traditionally employ tiling (or loop blocking), a technique that partitions loop iterations into smaller chunks to ensure the working set fits within the fast cache.
However, in the paper "Data Space Oriented Tiling," Mahmut Kandemir argues that traditional tiling is fundamentally limited by its "iteration-space-oriented" nature. By flipping the script and focusing on the data space first, we can achieve superior locality, particularly in complex programs with multiple, interacting loop nests.
The Limitations of Traditional Tiling
Standard iteration space tiling focuses on the loops themselves. While effective for simple, perfectly nested loops, it suffers from three major drawbacks:
- Uncertainty in Data Mapping: It is often difficult to guarantee that the data accessed by a specific loop tile will actually fit in the cache, as loop bounds do not always map linearly to contiguous data regions.
- Isolation: Traditional methods typically optimize a single loop nest at a time. This ignores "inter-nest" locality, where different parts of a program might reuse the same data arrays.
- Structural Rigidity: It struggles with "imperfectly nested" loops—those containing code between the
forstatements—which are common in real-world applications.
Methodology: Data Space Oriented Tiling (DST)
Kandemir proposes a "data-first" workflow. Instead of asking "What data does this loop need?", DST asks "Which loops need this data?" This shift allows the compiler to exploit reuse across the entire program.
The DST process follows five key steps:
- Seed Array Selection: The compiler identifies a "seed array" that dominates the computation's memory footprint.
- Data Relation Vectors: The compiler analyzes how iterations across the program access this array, summarizing these patterns into mathematical vectors.
- Tile Shape Optimization: Using a hyperplane-based framework, DST determines the optimal tile shape (e.g., skewed parallelepipeds) to minimize "communication volume"—the frequency with which the program must access elements outside the current data tile.
- Iteration Interleaving: Once a data tile is defined, the compiler identifies every iteration from every loop nest that accesses that specific tile. It reorders the execution to process all these iterations together.
- Dependency Management: A formal algorithm ensures that this reordering respects the original program's logic and data dependencies.
Exploiting Inter-Nest Locality
The power of DST lies in its ability to interleave iterations from different spaces to keep the processor focused on a specific data region. As shown in the figure below, traditional execution (I) or simple reordering (II) might still jump between data elements. DST (III) groups all iterations that access element 'a' across different iteration spaces before moving on to element 'b'.
Key Insights and Results
- Geometry Matters: The paper demonstrates that the geometry of a tile is as critical as its size. For certain access patterns, a skewed tile can reduce "boundary crossings" significantly compared to a standard rectangle.
- Scratch Pad Memory (SPM) Optimization: While applicable to caches, DST is uniquely suited for SPMs. Since SPMs are managed by the compiler rather than hardware, DST provides a perfect blueprint for moving data tiles in and out of fast memory.
- Performance Gains: In illustrative examples, such as stencil patterns, the optimized DST approach reduced off-tile memory traffic by 32% compared to standard tiling techniques.
Limitations and Future Work
Despite its advantages, DST faces challenges in scaling. The current method for selecting a "seed array" involves exhaustive searching, which may be inefficient for large-scale applications with hundreds of arrays. Furthermore, the framework currently relies on "regular" data access patterns (affine subscripts). Extending DST to handle irregular patterns, such as those found in sparse matrix computations or pointer-heavy code, remains an open area for research.
Summary updated