This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][ArmSME] Initial SME Dialect Implementation
AbandonedPublic

Authored by WanderAway on Jun 3 2023, 11:23 AM.

Details

Summary

This patch is the initial implementation of the ArmSME dialect, and contains the dialect itself, along with the following ops:

  • zero
  • load.tile
  • store.tile
  • mopa
  • mops

Along with their corresponding LLVM intrinsics.

The next step would be to implement the legalization transformation pass so that it may be lowered to LLVM.

PATCH [1/?] for RFC: https://discourse.llvm.org/t/rfc-creating-a-armsme-dialect/67208

Diff Detail

Event Timeline

WanderAway created this revision.Jun 3 2023, 11:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2023, 11:23 AM
WanderAway requested review of this revision.Jun 3 2023, 11:23 AM

Update copy-paste description of the mopa op.

Matt added a subscriber: Matt.Jun 3 2023, 8:09 PM
tschuett added inline comments.Jun 4 2023, 8:05 AM
mlir/include/mlir/Dialect/ArmSME/IR/ArmSME.h
26

Nit: you could use nested namespaces:
namespace mlir::arm_sme {
}

mlir/include/mlir/Dialect/ArmSME/IR/ArmSME.td
137

Nit: there

171

Nit: a or the?

tblah added a subscriber: tblah.Jun 5 2023, 2:05 AM

Thanks, Frank!

Along with their corresponding LLVM intrinsics.

Where are these intrinsics defined? I can't find them.

Thanks, Frank!

Along with their corresponding LLVM intrinsics.

Where are these intrinsics defined? I can't find them.

They're in the tablegen file, with names being *IntrOp, inheriting from LLVM_IntrOpBase.

Hi Frank, thanks for posting. As mentioned on the RFC there's a few of us working in this area now and there's a discussion scheduled for an upcoming MLIR ODM meeting but according to the agenda Public MLIR Open Meeting Agenda - Google Docs currently it's not until June 29th. As you've probably seen from upstream activity I've been focusing on Streaming SVE support in MLIR / IREE but more recently I've started looking at SME proper. To begin with focusing on a path from linalg.fill to SME as a simple example. In the spirit of openness I've shared a patch D152508 that adds a lowering to the SME zero instruction in the simplest case.

There's a lot going on in this patch, personally I'd find a few smaller patches that demonstrate the approach end-to-end for a simple example more useful, particularly in the context of the tile resource and how that could work.

c-rhodes added inline comments.Jun 9 2023, 3:56 AM
mlir/include/mlir/Dialect/ArmSME/IR/ArmSME.td
17–18

this has been mentioned a couple of times now but it would be good to clarify what it really means. The attribute exists in two places:

  1. The EnableArmStreaming.cpp pass as a static constexpr char that adds it to func.func ops.
  2. llvm.func ops which propagate it to the backend, this must stay as is.

I guess the idea here is 1. could be moved to a function as part of extraClassDeclaration under dialect def (example in GPU dialect), e.g.

def ArmSME_Dialect : Dialect {
  ...
  let extraClassDeclaration = [{
    /// Get the name of the attribute used to annotate functions to enable Arm
    /// streaming mode.
    static StringRef getArmStreamingAttrName() { return "arm_streaming"; }
    /// Get the name of the attribute used to annotate functions to enable Arm
    /// streaming mode locally.
    static StringRef getArmLocallyStreamingAttrName() {
      return "arm_locally_streaming";
    }
  }];
}
46–47

I don't think so, AFAIK there's no lowerings (from vector or linalg) to the custom ops in the SVE dialect anyway so there's no practical reason for this (yet).

Where are these intrinsics defined? I can't find them.

They're in the tablegen file, with names being *IntrOp, inheriting from LLVM_IntrOpBase.

Do you think you could create a separate patch only with the LLVM intrinsics? I think we could land that already!

Where are these intrinsics defined? I can't find them.

They're in the tablegen file, with names being *IntrOp, inheriting from LLVM_IntrOpBase.

Do you think you could create a separate patch only with the LLVM intrinsics? I think we could land that already!

Sure, I'll raise a separate patch when I get the time.

Where are these intrinsics defined? I can't find them.

They're in the tablegen file, with names being *IntrOp, inheriting from LLVM_IntrOpBase.

Do you think you could create a separate patch only with the LLVM intrinsics? I think we could land that already!

Sure, I'll raise a separate patch when I get the time.

+1

Thinking of the upcoming MLIR ODM, you could prepare some slides on this dialect and the approach that you are taking. Only if you are interested - I have no intention to delegate extra work to anyone :) I will prepare an introduction into SME and the work done so far (i.e. "status update").

Looking forward to discussing this :)

you could prepare some slides on this dialect and the approach that you are taking.

Yup that's the plan. Looking forward to it.

Here's the separate patch for just the intrinsic ops: https://reviews.llvm.org/D152878 @dcaballe @awarzynski

WanderAway abandoned this revision.Jul 5 2023, 7:35 AM

Dialect on hold until use case becomes clearer.