This is an archive of the discontinued LLVM Phabricator instance.

[mlir][gpu] Add GPU target attribute interface.
ClosedPublic

Authored by fmorac on Jun 29 2023, 9:06 AM.

Details

Summary

For an explanation of these patches see D154153.

Commit message:
This patch adds the GPUTargetAttrInterface attribute interface, this interface
is meant to be used as an opaque interface for serializing GPU modules into
binary strings.

Diff Detail

Event Timeline

fmorac created this revision.Jun 29 2023, 9:06 AM
fmorac updated this revision to Diff 536063.Jun 29 2023, 5:27 PM

Rebasing.

fmorac edited the summary of this revision. (Show Details)Jun 29 2023, 6:17 PM
fmorac added a reviewer: mehdi_amini.
fmorac published this revision for review.Jun 30 2023, 6:28 AM
krzysz00 requested changes to this revision.Jul 13 2023, 12:03 PM
krzysz00 added a subscriber: krzysz00.

This has memory safety issues.

mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h
210

StringRef doesn't own its contents, the toolkit path could disappear out from under you at an arbitrary time.

Let's make this either a std::string or a SmallString.

213

Same ownership notes. This should be something like a SmallVector<SmallVector<char>> or SmallVector<std::string> or so on.

This revision now requires changes to proceed.Jul 13 2023, 12:03 PM
fmorac updated this revision to Diff 543116.Jul 21 2023, 4:31 PM

Changed StringRef -> std::string & ArrayRef -> SmallVector.

mehdi_amini accepted this revision.Jul 24 2023, 12:31 AM

Seems fine to me, assuming @krzysz00 comments are addressed

mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
36

Seems implied by the fact that there is no default implementation?

fmorac added inline comments.Jul 24 2023, 4:30 AM
mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
36

I'll remove it.

krzysz00 accepted this revision.Jul 24 2023, 7:07 AM

Hold removed since my concerns are addressed

This revision is now accepted and ready to land.Jul 24 2023, 7:07 AM
fmorac updated this revision to Diff 544501.Jul 26 2023, 1:46 PM

Moved the compilation attributes from GPUDialect.h to CompilationInterfaces.h so they can be used by any dialect without including GPUDialect.h.

fmorac marked 3 inline comments as done.Jul 26 2023, 1:47 PM
fmorac updated this revision to Diff 544742.Jul 27 2023, 6:32 AM

Added a defualt implementation to the interface.

fmorac updated this revision to Diff 544766.Jul 27 2023, 7:22 AM

Changed the error in the default implementation. There's a bug on tablegen, it crashes with:

code ... = [{
#ifdef ...
#endif
}];

because of a lexing error when included from another file.

fmorac updated this revision to Diff 544801.Jul 27 2023, 8:56 AM

Moved the interface method body to DefaultImplementation.

fmorac updated this revision to Diff 544805.Jul 27 2023, 8:57 AM

Added new line.

fmorac updated this revision to Diff 545488.Jul 30 2023, 5:15 PM

Change constraint to isa.

fmorac updated this revision to Diff 545489.Jul 30 2023, 5:15 PM

Sync correct diff.

fmorac updated this revision to Diff 546283.Aug 1 2023, 6:07 PM

Added cmdOptions to TargetOptions for passing raw command line options.

Added a CompilationTarget option for specifying the final represation of the process (LLVM, Assembly, Binary).

fmorac updated this revision to Diff 547728.Aug 7 2023, 5:11 AM

Removed unnecessary tablegen code.

This revision was automatically updated to reflect the committed changes.