Code generation for accurate array redistribution on automatic distributed-memory parallelization

Bo Zhao, Rui Ding, Lin Han, Jinlong Xu2014

Abstract: Code generation belongs to the backend of parallelizing compiler, and is for generating efficient computation and communication code for the target parallel computing system. Traditional research resolve array redistribution mainly by generating communication code that each processor sends all data defined in its local memory to all processors, but this will bring large amount of communication redundancy, which increase with the growth of number of processors. Focusing on this problem, this paper presents an accurate code generation algorithm of array redistribution for distributed-memory architecture. The algorithm determines source processor and goals processor of each array element's migration in array redistribution by the transformation of data decompositions, then generate accurate communication code. The experimental results show that algorithm proposed by this paper can effectively reduce communication redundancy with the processor scale growth, and improve the parallel performance of applications.

Introduction

In the realm of high-performance computing, distributed-memory parallelization remains a cornerstone for scaling applications. However, a persistent bottleneck is the "communication tax"—the overhead incurred when moving data between processors during execution. This is particularly evident during array redistribution, where data must be re-partitioned across nodes to satisfy the requirements of different program phases (e.g., transitioning from a row-wise to a column-wise processing loop).

Traditional "naive" approaches often rely on a broadcast-style strategy where processors send all local data to all other nodes to ensure correctness. While simple, this creates massive communication redundancy that scales poorly as the number of processors increases. This paper introduces an "accurate" code generation algorithm designed to eliminate this redundancy by mathematically determining the precise source and destination for every array element.

The Accurate Mapping Model

The researchers propose a two-stage mapping model to generate precise communication code. This model moves away from brute-force data movement toward a geometric, mathematical representation of data ownership.

Affine Decomposition and Mapping

The core of the method involves representing data and computation as points in a multi-dimensional space. Using affine functions, the system maps these points through a hierarchy of spaces:

  1. Iteration Space (I) and Array Space (A): The original indices of the loops and data.
  2. Virtual Processor Space: An intermediate, unlimited scale representation.
  3. Physical Processor Space (P): The actual hardware nodes.
The two-stage mapping model using affine functions to link iteration, array, and processor spaces.

By defining these relationships as affine functions (e.g., $f(i) = Fi + k$), the compiler can calculate exactly which physical processor owns a specific data element at any point in the program.

Polyhedral Analysis and FME

The data owned by a processor is treated as a convex polyhedron defined by a system of symbol linear inequalities. To determine what needs to move during redistribution, the algorithm calculates the intersection between the "source" data space (the current distribution) and the "goal" data space (the required distribution).

Representation of array data access as a convex polyhedron defined by linear inequalities.

The system uses Fourier-Motzkin Elimination (FME) to solve these inequalities at compile-time. This allows the compiler to generate optimized "packing" and "unpacking" code, ensuring that only the necessary data is transmitted over the network.

Experimental Evaluation

The algorithm was evaluated using standard high-performance computing benchmarks, including the NAS Parallel Benchmarks (NPB) (specifically the BT and SP applications) and scientific kernels like the 2D-Heat equation and Jacobi iteration. Tests were conducted on an 8-node Sunway cluster and a 4-processor Supermicro server.

Key Results

  • Redundancy Reduction: In the BT benchmark, the "Accurate" algorithm reduced communication redundancy from a factor of $2 \times np$ (where $np$ is the number of processors) to approximately $np + 1$. Unlike traditional methods, the total communication volume remained nearly constant regardless of the processor count.
  • Scalability: In Jacobi iteration tests, traditional models (like the Redundancy Parallel Execution Model) actually saw performance decrease as more processors were added due to overwhelming communication overhead. In contrast, the "Accurate" version demonstrated consistent speedup.
  • Efficiency: By mathematically proving which element $(i, j, k)$ belongs to which processor $P$, the system avoids the "send-everything-to-everyone" trap, making it highly suitable for exascale systems.

Conclusion and Future Work

While the algorithm significantly improves performance for regular, affine data access, it faces challenges with "irregular" problems involving indirect indexing (e.g., A[B[i]]). Current workarounds involve "redundance replica" techniques, but future research will focus on handling these irregular loops more natively. Additionally, the authors plan to explore computation-communication overlap to further hide data movement latency by performing calculations while data is in transit.

Reference: Zhao, B., Ding, R., Han, L., & Xu, J. (2014). Code generation for accurate array redistribution on automatic distributed-memory parallelization. International Journal of Networked and Distributed Computing, 2(1), 11-25.

Summary updated

BibTeX
@inproceedings{zhao2014code,
  author = {Bo Zhao and Rui Ding and Lin Han and Jinlong Xu},
  title = {{Code generation for accurate array redistribution on automatic distributed-memory parallelization}},
  booktitle = {˜The},
  year = {2014},
  doi = {10.2991/ijndc.2014.2.1.2},
}
Figure