-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][NVVM] Enable nvvm intrinsics import #68843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c9a1700
to
547937b
Compare
@gysit is more knowledgeable about this part of the code so I'll defer to him. One general note is that I would split out NVVM into separate files, the same as we do on the MLIR->LLVMIR conversion side, rather than shove everything together. |
I would second @ftynse here that we should separate the import of NVVM intrinsics. The import is very similar to the export in the sense that you can implement an interface for your target that implements the actual conversion. There are some difficulties to solve there since the intrinsics don't have a dialect associated in LLVM IR. The interface therefore needs to communicate which intrinsics it supports (https://discourse.llvm.org/t/rfc-extensible-llvm-ir-import/67256). In principle, you want to build a counterpart to LLVMDialectLLVMIRImportInterface inside the mlir/lib/Target/LLVMIR/Dialect/NVVM folder. It needs to overwrite the relevant methods (I guess you do not care about metadata import). The I think you are the first one that tries this mechanism for intrinsics (at least upstream). However, things should work analogous to the LLVMIR import. |
@gysit Thank you for the explanation! How does it look now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! The structure looks good to me.
We probably want to increase the test coverage a little bit though.
mlir/include/mlir/Target/LLVMIR/Dialect/NVVM/LLVMIRToNVVMTranslation.h
Outdated
Show resolved
Hide resolved
mlir/include/mlir/Target/LLVMIR/Dialect/NVVM/LLVMIRToNVVMTranslation.h
Outdated
Show resolved
Hide resolved
@@ -865,6 +865,14 @@ define float @ssa_copy(float %0) { | |||
ret float %2 | |||
} | |||
|
|||
; CHECK-LABEL: llvm.func @nvvm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the tests into an nvvmir.ll file in the same folder to follow the same structure as in the export?
Can you also add a test for every intrinsic? I know it seems like a lot of copy paste but it still seems helpful to exercise the import of all of them in case things get refactored in LLVM land for example.
Let me add @Dinistro as another reviewer since I will be leaving for a vacation tonight. |
Co-authored-by: Tobias Gysi <[email protected]>
a3dde17
to
91851d0
Compare
I added a test which includes all of the currently supported nvvm intrinsics for import. To be automatically imported the nvvm ops must inherit from NVVM_IntrOp, and most of them currently inherit from NVVM_Op. I will be looking into whether the remaining can be made to inherit from IntrOp but I think that is best left for a separate PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT modulo nit.
Yes I think it makes sense to separate the support for the remaining intrinsics into a followup PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % minor nits.
@@ -12,6 +12,7 @@ | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#include "mlir/Dialect/DLTI/DLTI.h" | |||
#include "mlir/Dialect/LLVMIR/NVVMDialect.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include doesn't seem necessary.
Co-authored-by: Tobias Gysi <[email protected]>
Co-authored-by: Christian Ulmann <[email protected]>
@ivanradanov do you need help with landing the pr? Also if you do not have commit access yet you may want ask for it soonish https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access. |
If you could do it for me that would be great. (Thank you for the link, I asked for commit access but do not have it yet) Edit: got it! |
Ah I see, the commit right process was faster then me :) |
No description provided.