Polynomial-time Construction of Optimal Tree-structured Communication Data Layout Descriptions

Robert Ganian, Martin Kalany, Stefan Szeider, Jesper Larsson TräffarXiv 2015

In high-performance computing (HPC), the efficiency of data movement often dictates overall application performance. When programs need to transfer non-contiguous memory segments—such as a specific column from a large row-major matrix—they must describe these layouts to communication hardware or libraries. A recent breakthrough by researchers at the Vienna University of Technology provides a polynomial-time solution to a fundamental problem in this domain: generating the most efficient description for any arbitrary sequence of memory displacements.

The Type Reconstruction Problem

The Message-Passing Interface (MPI) allows developers to define "derived datatypes" to represent complex memory patterns. These datatypes are structured as trees where internal nodes are constructors (e.g., repeating a block at fixed intervals) and leaves represent primitive data types.

An example of a tree-structured data layout description using MPI-like constructors such as strc, vec, and idx.

The Type Reconstruction Problem asks: Given a raw list of $n$ memory addresses, what is the most concise tree of constructors that represents them? A concise description is critical; it minimizes memory overhead and enables hardware to leverage specialized features like strided memory access. Historically, the MPI community suspected that finding the absolute optimal tree was NP-hard, leading to a reliance on sub-optimal heuristics in major libraries like OpenMPI and MPICH.

Methodology: Taming Complexity with Dynamic Programming

The authors refute the NP-hardness conjecture by introducing an $O(n^4)$ algorithm based on dynamic programming (DP). The algorithm decomposes the problem by finding optimal representations for every possible sub-segment of the displacement sequence.

The core challenge lies in the variety of MPI constructors:

  1. Contiguous and Strided (vec): Identified through linear scans for regular patterns.
  2. Indexed (idx): Used for irregular repetitions of a single sub-pattern.
  3. Struct (strc): The most flexible and complex constructor, which concatenates different sub-patterns at arbitrary offsets.

To optimize the strc constructor, the authors construct an auxiliary Directed Acyclic Graph (DAG) for each sub-problem. In this DAG, nodes represent positions in the displacement sequence, and edges represent the cost of the optimal sub-tree for the corresponding segment. Finding the optimal strc node is then reduced to a shortest-path problem on this DAG. This approach ensures the "Principle of Optimality," where a global optimal tree is composed of optimal sub-trees.

Key Insights and Theoretical Contributions

  • Refuting NP-Hardness: By framing the search for the variable-arity strc constructor as a shortest-path problem, the authors demonstrate that the search space is manageable in polynomial time.
  • Normalization and "Nice" Trees: The paper proves that any optimal tree can be converted into a "normal form" starting at zero displacement. Furthermore, they identify "nice" trees—structures with limited "shifted" nodes—that simplify the search space without sacrificing optimality.
  • Unbounded Compression: The inclusion of the strc constructor allows for significantly more concise descriptions than simpler indexed types, justifying the $O(n^4)$ computational investment for complex, repetitive data.

Results and Future Directions

The proposed algorithm guarantees an optimal tree representation with a time complexity of $O(n^4)$ and space complexity of $O(n^2)$. While $O(n^4)$ is efficient for many practical cases, the authors note that extremely large sequences (e.g., $n > 10,000$) might require further optimization, perhaps toward an $O(n^3)$ variant using more aggressive pruning.

Future research may explore the transition from tree-structured descriptions to DAG-structured descriptions. While DAGs allow for even greater compression by reusing nodes, they break the independence of sub-problems required for standard dynamic programming, making the optimization problem significantly more difficult. Additionally, tuning the abstract cost models to reflect specific hardware and MPI implementation characteristics remains a key step for real-world deployment.

Summary updated

Abstract

We show that the problem of constructing tree-structured descriptions of data layouts that are optimal with respect to space or other criteria from given sequences of displacements, can be solved in polynomial time. The problem is relevant for efficient compiler and library support for communication of noncontiguous data, where tree-structured descriptions with low-degree nodes and small index arrays are beneficial for the communication soft- and hardware. An important example is the Message-Passing Interface (MPI) which has a mechanism for describing arbitrary data layouts as trees using a set of increasingly general constructors. Our algorithm shows that the so-called MPI datatype reconstruction problem by trees with the full set of MPI constructors can be solved optimally in polynomial time, refuting previous conjectures that the problem is NP-hard. Our algorithm can handle further, natural constructors, currently not found in MPI. Our algorithm is based on dynamic programming, and requires the solution of a series of shortest path problems on an incrementally built, directed, acyclic graph. The algorithm runs in $O(n^4)$ time steps and requires $O(n^2)$ space for input displacement sequences of length $n$.
BibTeX
@misc{ganian2015polynomial,
  author = {Robert Ganian and Martin Kalany and Stefan Szeider and Jesper Larsson Träff},
  title = {{Polynomial-time Construction of Optimal Tree-structured Communication Data Layout Descriptions}},
  year = {2015},
  eprint = {1506.09100},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1506.09100},
}
Figure