Fix nvptx Kernel return type lowering#771
Conversation
|
Thank you for your pull request. We require contributors to agree to our Contributor License Agreement (https://exaloop.io/legal/cla), and we don't have @BI71317 on file. In order for us to review and merge your code, please email info@exaloop.io to get yourself added. |
|
I’ve already signed the CLA and just sent a quick note to info@exaloop.io with my GitHub username and PR link 🙂 |
|
@cla-bot recheck |
|
Thanks for the PR! I think the better way to do this would be at the LLVM level during NVPTX codegen (see Currently the Codon IR |
|
Got it, thanks for the guidance. I’ve reworked the change so that instead of converting kernel return types to void at the high-level Codon IR stage, the IR is now rewritten in gpu.cpp during applyGPUTransformations before being passed to NVPTX codegen. Minimal ReproducerObserved IR |
|
Hi! I left an update on this PR a little while ago, but it may have slipped through the cracks. I reworked the implementation based on the earlier feedback. Would appreciate another look whenever someone has time. Thanks! |
arshajii
left a comment
There was a problem hiding this comment.
Just left a few minor review comments. LGTM overall!
codon/cir/llvm/gpu.cpp
Outdated
| return std::vector<llvm::GlobalValue *>(keep.begin(), keep.end()); | ||
| } | ||
|
|
||
| static bool isEmptyStructType(llvm::Type *ty) { |
There was a problem hiding this comment.
Don't need static if these are in namespace {}.
codon/cir/llvm/gpu.cpp
Outdated
|
|
||
| static bool isEmptyStructType(llvm::Type *ty) { | ||
| auto *st = llvm::dyn_cast<llvm::StructType>(ty); | ||
| return st && st->getNumElements() == 0; |
There was a problem hiding this comment.
I believe we should also check !st->hasName().
codon/cir/llvm/gpu.cpp
Outdated
| } | ||
|
|
||
| static llvm::Function *normalizeKernelReturnToVoid(llvm::Function *F) { | ||
| if (!F || F->isDeclaration()) |
There was a problem hiding this comment.
Can we merge these conditions via || into a single if statement?
codon/cir/llvm/gpu.cpp
Outdated
| std::vector<llvm::Function *> kernelCandidates; | ||
| std::vector<llvm::GlobalValue *> kernels; | ||
|
|
||
There was a problem hiding this comment.
Please format with clang-format --style=file -i codon/cir/llvm/gpu.cpp, which should remove trailing whitespace.
codon/cir/llvm/gpu.cpp
Outdated
| return st && st->getNumElements() == 0; | ||
| } | ||
|
|
||
| static llvm::Function *normalizeKernelReturnToVoid(llvm::Function *F) { |
There was a problem hiding this comment.
Similarly, don't need static here.
|
Thanks for the review and suggestions. I’ve addressed the requested changes and pushed a new commit. |
Fixes #770
Changes
voidreturn type for final kernel entry functionsValidation
voidreturn typesObserved IR