[all-commits] [llvm/llvm-project] 2f743a: [MLIR] [AMX] Utilize x86_amx type for AMX dialect ...

Ilya Enkovich via All-commits all-commits at lists.llvm.org
Wed Nov 6 06:31:17 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2f743ac52e945e155ff3cb1f8ca5287b306b831e
      https://github.com/llvm/llvm-project/commit/2f743ac52e945e155ff3cb1f8ca5287b306b831e
  Author: Ilya Enkovich <ilya.enkovich at intel.com>
  Date:   2024-11-06 (Wed, 06 Nov 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/AMX/AMX.td
    M mlir/include/mlir/Dialect/AMX/AMXDialect.h
    M mlir/include/mlir/Dialect/AMX/Transforms.h
    M mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.td
    M mlir/include/mlir/InitAllExtensions.h
    M mlir/lib/Dialect/AMX/IR/AMXDialect.cpp
    M mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp
    M mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
    M mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
    M mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
    M mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
    M mlir/test/Dialect/AMX/invalid.mlir
    M mlir/test/Dialect/AMX/legalize-for-llvm.mlir
    M mlir/test/Dialect/AMX/roundtrip.mlir

  Log Message:
  -----------
  [MLIR] [AMX] Utilize x86_amx type for AMX dialect in MLIR. (#111197)

This patch is intended to resolve #109481 and improve the usability of
the AMX dialect.

In LLVM IR, AMX intrinsics use `x86_amx` which is one of the primitive
types. This type is supposed to be used for AMX intrinsic calls and no
other operations. AMX dialect of MLIR uses regular 2D vector types,
which are then lowered to arrays of vectors in the LLVMIR dialect. This
creates an inconsistency in the types used in the LLVMIR dialect and
LLVMIR. Translation of AMX intrinsic calls to LLVM IR doesn't require
result types to match and that is where tile loads and mul operation
results get `x86_amx` type. This works in very simple cases when mul and
tile store operations directly consume the result of another AMX
intrinsic call, but it doesn't work when an argument is a block argument
(phi node).

In addition to translation problems, this inconsistency between types
used in MLIR and LLVM IR makes MLIR verification and transformation
quite problematic. Both `amx.tileload` and `vector::transfer_read` can
load values of the same type, but only one of them can be used in AMX
operations. In general, by looking at a type of value, we cannot
determine if it can only be used for AMX operations or contrary can be
used in other operations but AMX ones.

To remove this inconsistency and make AMX operations more explicit in
their limitations, I propose to add `LLVMX86AMXType` type to the LLVMIR
dialect to match `x86_amx` type in LLVM IR, and introduce
`amx::TileType` to be used by AMX operations in MLIR. This resolves
translation problems for AMX usage with phi nodes and provides proper
type verification in MLIR for AMX operations.

P.S. This patch also adds missing FP16 support. It's trivial but
unrelated to type system changes, so let me know if I should submit it
separately.

---------

Signed-off-by: Ilya Enkovich <ilya.enkovich at intel.com>



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