[all-commits] [llvm/llvm-project] 041baf: [mlir][ArmSME] Use liveness information in the til...

Benjamin Maxwell via All-commits all-commits at lists.llvm.org
Tue May 14 06:59:23 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 041baf2f60ac3e107399641aea04c77019e7eab8
      https://github.com/llvm/llvm-project/commit/041baf2f60ac3e107399641aea04c77019e7eab8
  Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
  Date:   2024-05-14 (Tue, 14 May 2024)

  Changed paths:
    M mlir/include/mlir/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.h
    M mlir/include/mlir/Conversion/Passes.td
    M mlir/include/mlir/Dialect/ArmSME/IR/ArmSME.h
    A mlir/include/mlir/Dialect/ArmSME/IR/ArmSMEOpInterfaces.h
    M mlir/include/mlir/Dialect/ArmSME/IR/ArmSMEOps.td
    M mlir/include/mlir/Dialect/ArmSME/Transforms/Passes.h
    M mlir/include/mlir/Dialect/ArmSME/Transforms/Passes.td
    M mlir/include/mlir/Dialect/ArmSME/Transforms/Transforms.h
    M mlir/include/mlir/Dialect/ArmSME/Utils/Utils.h
    M mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
    M mlir/lib/Conversion/ArmSMEToSCF/ArmSMEToSCF.cpp
    M mlir/lib/Dialect/ArmSME/IR/ArmSME.cpp
    M mlir/lib/Dialect/ArmSME/IR/Utils.cpp
    M mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
    M mlir/test/Conversion/ArmSMEToLLVM/arm-sme-to-llvm.mlir
    M mlir/test/Conversion/ArmSMEToLLVM/tile-spills-and-fills.mlir
    M mlir/test/Conversion/ArmSMEToLLVM/unsupported.mlir
    M mlir/test/Dialect/ArmSME/basic-tile-allocation.mlir
    M mlir/test/Dialect/ArmSME/canonicalize.mlir
    R mlir/test/Dialect/ArmSME/cse.mlir
    M mlir/test/Dialect/ArmSME/roundtrip.mlir
    A mlir/test/Dialect/ArmSME/tile-allocation-copies.mlir
    M mlir/test/Dialect/ArmSME/tile-allocation-invalid.mlir
    M mlir/test/Dialect/ArmSME/tile-allocation-liveness.mlir
    A mlir/test/Dialect/ArmSME/tile-allocation-spills-with-mixed-tile-types.mlir
    M mlir/test/Dialect/ArmSME/tile-zero-masks.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/use-too-many-tiles.mlir
    M mlir/test/Integration/Dialect/Vector/CPU/ArmSME/Emulated/test-setArmSVLBits.mlir
    M mlir/test/lib/Dialect/ArmSME/CMakeLists.txt
    M mlir/test/lib/Dialect/ArmSME/TestLowerToArmSME.cpp

  Log Message:
  -----------
  [mlir][ArmSME] Use liveness information in the tile allocator (#90448)

This patch rewrites the ArmSME tile allocator to use liveness
information to make better tile allocation decisions and improve the
correctness of the ArmSME dialect. This algorithm used here is a linear
scan over live ranges, where live ranges are assigned to tiles as they
appear in the program (chronologically). Live ranges release their
assigned tile ID when the current program point is passed their end.
This is a greedy algorithm (which is mainly to keep the implementation
relatively straightforward), and because it seems to be sufficient for
most kernels (e.g. matmuls) that use ArmSME. The general steps of this
are roughly from
https://link.springer.com/content/pdf/10.1007/3-540-45937-5_17.pdf,
though there have been a few simplifications and assumptions made for
our use case.

Hopefully, the only changes needed for a user of the ArmSME dialect is
that:

- `-allocate-arm-sme-tiles` will no longer be a standalone pass 
  - `-test-arm-sme-tile-allocation` is only for unit tests 
- `-convert-arm-sme-to-llvm` must happen after `-convert-scf-to-cf` 
   - SME tile allocation is now part of the LLVM conversion

By integrating this into the `ArmSME -> LLVM` conversion we can allow
high-level (value-based) ArmSME operations to be side-effect-free, as we
can guarantee nothing will rearrange ArmSME operations before we emit
intrinsics (which could invalidate the tile allocation).

The hope is for ArmSME operations to have no hidden state/side effects
and allow easily lowering dialects such as `vector` and `arith` to SME,
without making assumptions about how the input IR looks, as the
semantics of the operations will be the same. That is no (new) side
effects and the IR follows the rules of SSA (a value will never change).

The aim is correctness, so we have a base for working on optimizations.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list