Exo 2: Growing a Scheduling Language

Yuka Ikarashi, Kevin Qian, Samir Droubi, Alex Reinking, Gilbert Bernstein, Jonathan Ragan-KelleyASPLOS 2024

TL;DR

This paper introduces Exo 2, a novel scheduling language that empowers users to define new scheduling operations externally, enabling the creation of reusable libraries for optimizing high-performance code. By composing fine-grained, safe primitives, Exo 2 allows for flexible automation of complex optimizations, significantly reducing manual effort and improving performance across various hardware platforms.

What Problem Does This Paper Address?

Optimizing high-performance computing (HPC) kernels is a complex and time-consuming task. User-schedulable languages (USLs) like Halide, TVM, and TACO aim to simplify this by allowing programmers to express optimization strategies as separate "schedules." However, existing USLs often have fixed sets of scheduling operations, making it difficult to:

  • Extend functionality: When a desired optimization isn't supported, users are forced to drop down to lower-level code or modify the compiler.
  • Share and reuse optimizations: It's challenging to encapsulate common optimization patterns into reusable libraries that can be applied across different kernels and hardware.
  • Manage complexity: HPC kernels often have a vast configuration space (data types, parameters, architectures), leading to tedious manual scheduling for each variant.

This paper addresses the need for a USL that can "grow" by allowing users to build their own scheduling operations and libraries, thereby increasing productivity and maintainability.

Methods

Exo 2 builds upon the previous Exo language by introducing a new framework for user-extensible scheduling. The core innovations include:

  • External Scheduling Operations: Users can define new scheduling operations as Python meta-programs, external to the compiler. These operations are built by composing a set of trusted, fine-grained primitives.
  • Composable Primitives: Exo 2 provides a rich set of 46 low-level primitives (e.g., divide_loop, lift_scope, fission) that offer precise control over code transformations. These primitives are guaranteed to preserve functional equivalence, ensuring safety.
  • Cursors: A new mechanism called "Cursors" acts as a unified way to refer to and navigate parts of the object code. Cursors support relative referencing and can be stable across transformations, unlike previous nominal or one-time references. This enables more robust and flexible scheduling.
  • Action, Inspection, and Reference Framework: The paper conceptualizes scheduling languages through these three pillars. Exo 2's Cursors embody this by enabling actions (transformations), inspection (querying code properties), and flexible referencing.
  • Branching Time Model: Exo 2 adopts a branching time model for scheduling, allowing for multiple, stable, relative references to coexist, which encompasses linear and fixed-time models used in other USLs.

Datasets

The paper does not introduce new datasets. Instead, it evaluates Exo 2's performance on a suite of existing HPC kernels, including:

  • BLAS levels 1, 2, and GEMM: Standard linear algebra routines.
  • Image processing kernels: Such as blur and unsharp mask.
  • Gemmini accelerator kernels: Specifically matrix multiplication.

The performance is compared against state-of-the-art libraries like MKL, OpenBLAS, BLIS, and schedules generated by Halide.

Key Insights and Ideas

  • The Power of External Libraries: The most significant insight is that by providing safe, composable primitives and a robust referencing mechanism, users can effectively build powerful, reusable scheduling libraries outside the compiler. This dramatically shifts the paradigm from compiler-centric optimization to user-driven library development.
  • Cursors as a Unifying Abstraction: The introduction of Cursors as a unified mechanism for referencing, navigating, and forwarding across code transformations is a key enabler. It simplifies complex scheduling tasks and allows for more robust library development.
  • "Growing" Languages: The paper champions the idea of "growing" languages, where users can extend the language's capabilities by defining new abstractions (scheduling operations) rather than relying solely on built-in features. This is crucial for adapting to evolving hardware and application domains.
  • Safety as a Foundation: The emphasis on safety through equivalence-preserving primitives is critical. It allows users to experiment with complex transformations without sacrificing correctness, fostering trust and adoption.

Key Results

  • Order-of-Magnitude Reduction in Scheduling Code: Libraries built with Exo 2 amortize scheduling effort across over 80 high-performance kernels, reducing total scheduling code by an order of magnitude compared to manual implementations.
  • Competitive Performance: Exo 2 achieves performance competitive with or better than state-of-the-art implementations (MKL, OpenBLAS, BLIS, Halide) on various platforms (AVX2, AVX512, Gemmini).
  • Reproducibility of Existing USLs: Exo 2 successfully reproduces the behavior of Halide's compute_at and store_at operations and ELEVATE-style traversal functions, demonstrating its flexibility and expressiveness.
  • Efficient Micro-kernel Generation: For Gemmini, Exo 2 generates micro-kernels for matrix multiplication that are highly optimized and competitive with hand-tuned assembly.

Limitations and Future Work

  • Expressibility Limits: While Exo 2 is designed for growth, the finest level of control is still dictated by the set of scheduling primitives. If a desired transformation cannot be achieved by composing primitives, modifying the compiler might still be necessary.
  • Compilation Time: Composing many fine-grained primitives can increase compilation time, especially for complex schedules. The authors plan to improve this through caching and more efficient analysis algorithms.
  • Python Implementation: Exo 2 is implemented in Python, which can introduce overhead. Future work may involve optimizing this implementation.
  • Future Directions: The authors suggest exploring more sophisticated analysis algorithms, improving compilation time, and further expanding the set of primitives to cover a wider range of transformations. They also highlight the potential for Exo 2 to serve as a foundation for building new DSLs and optimizing for novel hardware architectures.

Summary updated

BibTeX
@inproceedings{ikarashi2024exo,
  author = {Yuka Ikarashi and Kevin Qian and Samir Droubi and Alex Reinking and Gilbert Bernstein and Jonathan Ragan-Kelley},
  title = {{Exo 2: Growing a Scheduling Language}},
  booktitle = {ASPLOS},
  year = {2024},
  url = {https://openreview.net/forum?id=7w2U3Vejqv},
}
Figure