This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 708fd43ec8 [Fix][NVPTX] Cast thread index to the loop variable dtype
(#20476)
708fd43ec8 is described below
commit 708fd43ec8f90d88c7492a55979c2b56cb750d92
Author: Saiyam Bharara <[email protected]>
AuthorDate: Mon Sep 28 07:52:52 2026 +0530
[Fix][NVPTX] Cast thread index to the loop variable dtype (#20476)
NVPTX GetThreadIndex returned the raw i32 from the tid/ctaid intrinsics
even when the bound loop var is int64. Kernels with symbolic int64
extents then emitted mixed-width LLVM IR and failed module verification.
This casts the result to the loop var dtype, matching the AMDGPU
backend.
---
src/backend/cuda/codegen/llvm/codegen_nvptx.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/backend/cuda/codegen/llvm/codegen_nvptx.cc
b/src/backend/cuda/codegen/llvm/codegen_nvptx.cc
index 573731bcfa..0de7967b49 100644
--- a/src/backend/cuda/codegen/llvm/codegen_nvptx.cc
+++ b/src/backend/cuda/codegen/llvm/codegen_nvptx.cc
@@ -169,7 +169,8 @@ class CodeGenNVPTX : public CodeGenLLVM {
#else
llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(),
intrin_id);
#endif
- return builder_->CreateCall(f, {});
+ llvm::Value* result = builder_->CreateCall(f, {});
+ return this->CreateCast(PrimType::Int(32), iv->var.ty(), result);
}
llvm::Value* CreateStorageSync(const CallNode* op) final {