Abstract
Modern processor performance is increasingly limited by the "memory wall." Array Unification is a compiler optimization that addresses inter-variable conflict misses by merging independent arrays into a single interleaved data space. This technique improves spatial locality and cache performance, particularly in irregular codes where traditional loop transformations are often ineffective.
Introduction
As CPU speeds continue to outpace main memory latency, efficient cache utilization becomes paramount. Caches frequently suffer from conflict misses, which occur when multiple data items compete for the same cache location. While traditional optimizations focus on loop reordering (control-centric) or single-array layout changes (data-centric), they often fail to address conflicts between different arrays accessed concurrently.
Array Unification tackles these inter-variable conflicts by fundamentally altering how multiple arrays are organized in physical memory. By placing elements from different arrays that are accessed together into the same cache lines, the technique significantly reduces misses and enhances performance across both regular and irregular applications.
Methodology
The core of the Array Unification framework involves two main components: a mapping mechanism and a selection policy.
Interleaving Mechanism
The primary mechanism is the interleaving of multiple $m$-dimensional arrays into a single, unified array space. For instance, two 1D arrays, $U_1$ and $U_2$, can be mapped to a single array $X$ such that elements $U_1[i]$ and $U_2[i]$ are stored adjacently (e.g., $X[2i-1]$ and $X[2i]$). This ensures that fetching an element from one array automatically brings the corresponding element of the other array into the cache.
Array Transition Graph (ATG)
To determine which arrays should be unified, the authors utilize an Array Transition Graph (ATG). In this graph, nodes represent array variables, and edges represent transitions—instances where one array is accessed immediately after another. Edge weights reflect the frequency of these transitions.
The optimization problem is then framed as finding a Maximum Weighted Path Cover in the ATG. This identifies sequences of arrays frequently accessed together. Since this is NP-hard, a Kruskal-like greedy heuristic is employed to select high-weight edges while ensuring that no array is unified with more than two neighbors in the interleaved space.
Evaluation
The technique was evaluated using two benchmarks: bmcm (regular, array-dominated) and charmm (irregular, molecular dynamics kernel). Tests were conducted on an SGI/Cray Origin 2000 machine with an R10K processor.
Key Results
- Performance Gains: For the
bmcmbenchmark, array unification reduced execution time by 67% compared to standard layouts. - Cache Efficiency: In the irregular
charmmbenchmark, the L1 hit rate improved from 70% to 90%, demonstrating the technique's robustness against non-linear access patterns. - Synergy with Tiling: Combining unification with traditional loop tiling yielded the best results; for
bmcm, the unified version with tiling achieved 186.77 MFLOPS, significantly higher than either technique could achieve alone.
Conclusion
Array Unification provides a powerful global perspective on data layout, moving beyond single-loop or single-array optimizations. By focusing on inter-variable conflicts, it offers a solution for irregular codes that are often resistant to traditional transformations. Future work includes extending the analysis across function boundaries and exploring dynamic unification strategies to adapt to different program phases.
Reference: Wilhelm, R. (Ed.): CC 2001, LNCS 2027, pp. 259–273, 2001. © Springer-Verlag Berlin Heidelberg 2001.
Summary updated