This is an archive of the discontinued LLVM Phabricator instance.

[mlir][gpu] Add `gpu.binary` op and `#gpu.object` attribute.
ClosedPublic

Authored by fmorac on Jun 29 2023, 12:03 PM.

Details

Summary

For an explanation of these patches see D154153.

Commit message:
Adds the #gpu.object attribute for holding a binary object and the target
attribute used to create it. Also adds the gpu.binary operation used to
store GPU objects.

Depends on D154108

Diff Detail

Event Timeline

fmorac created this revision.Jun 29 2023, 12:03 PM
fmorac updated this revision to Diff 535949.Jun 29 2023, 12:06 PM

Adds D154098 to the commit message as a dependency.

fmorac edited the summary of this revision. (Show Details)Jun 29 2023, 12:07 PM
fmorac updated this revision to Diff 536073.Jun 29 2023, 5:45 PM

Rebasing.

fmorac edited the summary of this revision. (Show Details)Jun 29 2023, 6:19 PM
fmorac added a reviewer: mehdi_amini.
fmorac published this revision for review.Jun 30 2023, 6:29 AM
fmorac updated this revision to Diff 543184.Jul 22 2023, 7:07 AM

Rebasing.

mehdi_amini added inline comments.Jul 24 2023, 12:48 AM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1062

What kind of "information of how the object was generated" are stored and how? From the rest of the patches seems like it is "the binary string", period.

1070

Can the target be defined as GPUTargetAttr?

I'm also not sure it is a good idea to use a StringAttr here, it can be large storage that we could store differently than in the MLIRContext. Maybe it's good enough to start with and we can update later (I'm just worried it means we'll never get to it...)

1089

We should document what is the objectManager role here.

1094

the example syntax does not show the objectManager?

1102

Shall we move the attr-dict-with-keyword after the objects?

Also is the keyword needed?

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
1551

Why do you need this custom print/parse here?

Edit: maybe it'll only be needed in a subsequent revision, in which case that's fine...

fmorac added inline comments.Jul 24 2023, 5:26 AM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1062

It also stores GPUTargetAttr, which has the information on how the object was generated encoded in the method. Also the SelectObjectManager can use the attribute to select the appropriate target.

1070

I think there's an 'egg-chicken' dependency with ObjectManagerAttrInterface if we have it use BinaryOp, but I'll come back with a better answer.

I used StringAttr because the old pipeline uses StringAttr, however we can create a new parameter type that stores strings as smart ptrs?

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
1551

Yes, this is changed in D154147 with the introduction of the SelectObjectManager as the default one.

fmorac added inline comments.Jul 24 2023, 5:30 AM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1089

I'll add it.

1094

In change that in D154147, I didn't want to introduce a name of something that is not there (SelectObjectManager).

1102

With keywords is not needed.

I put it before $objects, because $objects can be thousands of characters long so if they are before, it's easier to edit them by hand.

mehdi_amini added inline comments.Jul 24 2023, 11:03 PM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1062

oh I see the "information of how the object was generated" applies to the whole pair and not the binary string. I think I misread this...

1070

We should have a "StringAttrInterface" ;)
(same for all blob-like attributes I guess)

1070

(this is far out of scope to create such interface of course)

1102

makes sense!

This all seems reasonable to me

fmorac updated this revision to Diff 546563.Aug 2 2023, 11:36 AM
fmorac marked 10 inline comments as done.

Switched ObjectManager to BinaryHandler.
Switched the types of the parameters from generic Attributes to the respective interface in gpu.object & gpu.binary.

fmorac edited the summary of this revision. (Show Details)
mehdi_amini added inline comments.Aug 2 2023, 6:53 PM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1089

It's not documented yet?

fmorac added inline comments.Aug 2 2023, 7:03 PM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1089

I was thinking on add it on D154147. Because on that patch I expand on the docs because there I have the select_object handler, but I can add it here.

fmorac updated this revision to Diff 547736.Aug 7 2023, 5:22 AM

Improved the docs & moved ObjectAttr to CompilationAttrs.td.

mehdi_amini accepted this revision.Aug 8 2023, 9:57 PM
This revision is now accepted and ready to land.Aug 8 2023, 9:57 PM
fmorac updated this revision to Diff 549329.Aug 11 2023, 4:05 AM

Update the gpu.binary attributes to use OffloadingTranslationAttrTrait
instead of OffloadingLLVMTranslationAttrInterface.