Mapple: A Domain-Specific Language for Mapping Distributed Heterogeneous Parallel Programs

Anjiang Wei, Rohan Yadav, Hang Song, Wonchan Lee, Ke Wang, Alex AikenarXiv 2025 · DOI

Optimizing parallel programs for distributed systems usually requires wrestling with complex, low-level APIs to map tasks to hardware. This paper introduces Mapple, a high-level Domain-Specific Language (DSL) that simplifies this process. Mapple notably features a decompose primitive that automatically minimizes communication overhead when task and hardware dimensions do not match. Evaluation shows that Mapple reduces mapping code size by 14x and can outperform expert-written C++ mappers by up to 1.34x by facilitating the exploration of better optimization strategies.

The Challenge of Dimensionality Mismatch

In task-based distributed programming, developers ideally separate core application logic from "mapping" logic—the rules dictating which task runs on which processor (e.g., GPU) and where its data is stored. However, writing these mappers is notoriously difficult due to dimensionality mismatch.

An algorithm might define a 2D task space (such as a grid of matrix tiles), while the physical hardware resides in a 3D processor space (e.g., a cluster of $N$ nodes, each with $M$ GPUs). Existing systems often force developers to write hundreds of lines of complex C++ callbacks to manually translate between these spaces or rely on naive, greedy heuristics. These default heuristics frequently ignore the shape of the task space, leading to suboptimal data partitioning and excessive data movement across the network.

The Mapple DSL and Transformation Primitives

Mapple is a declarative DSL implemented on top of the Legion task-based runtime system. It allows developers to specify processor selection, memory placement, and data layout in just a few lines of code. The Mapple compiler then translates these high-level specifications into Legion's low-level C++ pipeline.

To address dimensionality mismatch, Mapple introduces a set of transformation primitives—split, merge, swap, and slice—that reshape the processor space to align with the task space.

Figure 5: Mapple maps a 2D task space to a 2D processor space using high-level primitives like block2D.

Beyond basic reshaping, Mapple provides primitives like merge to linearize multi-dimensional processor grids, enabling more flexible mapping strategies such as cyclic distributions.

Figure 6: The merge primitive allows developers to reshape the processor space, facilitating complex mappings like linear cyclic distributions.

The most significant contribution is the decompose primitive. Instead of manually guessing how to map a 2D task onto a 3D processor grid, decompose frames the mapping as a mathematical optimization problem. It searches for a configuration that minimizes the "surface area" of the partitioned task blocks. Because data communication occurs at the boundaries of these blocks, minimizing surface area directly minimizes inter-processor communication volume.

Evaluation and Key Results

The authors evaluated Mapple using nine benchmark applications, including scientific simulations (Circuit, Stencil, Pennant) and six distributed matrix multiplication algorithms (e.g., SUMMA, COSMA). To stress-test the decompose primitive, they also evaluated 180 configurations of 2D stencil applications across varying aspect ratios and GPU counts (4 to 128).

Key Insights

  • Abstraction Unlocks Performance: Higher-level languages often sacrifice performance for ease of use, but Mapple proves the opposite. By reducing hundreds of lines of C++ to a few declarative statements, developers can rapidly prototype and discover highly optimized mapping strategies that were previously too tedious to implement.
  • Heuristics Fail on Skewed Data: Standard runtime heuristics (like those in Chapel) attempt to divide processors evenly. However, for rectangular task spaces (e.g., 1:8 aspect ratio), these "even" splits cause massive spikes in network communication.
  • Mathematical Optimization: By leveraging the Arithmetic-Geometric Mean (AM-GM) inequality, the decompose primitive can exhaustively search a small parameter space to guarantee an optimal, communication-minimizing hardware split.

Performance Metrics

  • Code Reduction: Mapple reduced the lines of code (LoC) required for mappers by an average of 14x, dropping from over 400 lines of C++ to fewer than 30 lines of Mapple code.
  • Execution Speed: Mapple-tuned mappers outperformed expert-written C++ mappers by up to 1.34x.
  • Dimensionality Resolution: In stencil workloads, the decompose primitive outperformed greedy heuristics by up to 1.83x, with the most significant benefits seen in highly skewed task spaces.

Limitations and Future Work

Mapple is currently stateless, meaning it does not retain historical information across mapping decisions. While not a bottleneck for the studied applications, this may limit its suitability for highly dynamic workloads requiring adaptive mapping based on execution history. Additionally, the mathematical model for decompose assumes spatial locality (e.g., nearest-neighbor exchanges); it may be less effective for algorithms lacking such locality. Finally, while Mapple is tailored to the Legion runtime, its underlying abstractions offer a blueprint for future API designs in other distributed execution ecosystems.

Summary updated

BibTeX
@misc{wei2025mapple,
  author = {Anjiang Wei and Rohan Yadav and Hang Song and Wonchan Lee and Ke Wang and Alex Aiken},
  title = {{Mapple: A Domain-Specific Language for Mapping Distributed Heterogeneous Parallel Programs}},
  year = {2025},
  eprint = {2507.17087},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.17087},
}
Figure