-
Notifications
You must be signed in to change notification settings - Fork 128
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
[CIR][CUDA] Skeleton of NVPTX target lowering info #1358
Conversation
Just noticed it should also emit the registration function when emitting LLVM IR. So it's probably not ready to be accepted, and I'll update it later. |
no problem @AdUhTkJm, let me know when it's ready! |
It seems generating that registration function is much harder than I had thought. So I plan to block LLVM IR generation for this PR, and gradually set up a few more PRs to do lowering -- otherwise this one might become really huge. For more details: I'm planning to generate the registration in LoweringPrepare. The first argument of Another problem is that we'll create a runtime function, and it can be hard without knowing which type is the // TODO: instead of fixed integer size, create alias for PtrDiffTy and unify
// with CIRGen stuff.
auto ptrDiffTy =
cir::IntType::get(builder.getContext(), 64, /*signed=*/false); Perhaps just create a unsigned 64 bit for |
Sounds great to me!
Sure! Since you are touching this, would you mind migrating the content of
Ideally we want to share the content of |
Yeah, I'll do that. By the way this PR is ready for review now. |
@@ -260,6 +260,11 @@ class CIRGenConsumer : public clang::ASTConsumer { | |||
} | |||
} | |||
|
|||
if (action != CIRGenAction::OutputType::EmitCIR) { | |||
if (C.getLangOpts().CUDA && !C.getLangOpts().CUDAIsDevice) |
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.
I'd rather not get target specific restrictions as part in this file. What is it that you are hitting that is asking for this? If it's because something cannot lower to LLVM that's fine, this is already the status quo for CUDA.
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.
I want to prevent CIR to lower into LLVM. Currently the lowering pass just go smoothly all the way to LLVM, but the result is wrong: lacking ptx_kernel
calling conv and the registration function.
I tried to put that in LoweringPrepare, but it prevents -emit-cir
to generate CIR. Where else should I put it?
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.
Because the CUDA support didn't had LLVM right at the beginning, it's fine we are in this intermediate state, which will be soon fixed with your incremental work (for future PRs, whenever you add something in CIR, you should also add LLVM support in the same PR, this will prevent these issues).
I'd say not put this anywhere, but add LLVM output to the tests that make sense and annotate them with the COM
directive. That will indicate the current status and give you a easy diff to patch once the callconv work land.
Added a skeleton of NVPTX target lowering info.
This enables lowering of
simple.cu
(as it hardly tests device side functionalities), so a test of LLVM IR is also added onto it.