[llvm] [NVPTX] Annotate CUDA kernel pointer arguments with .ptr .space .align attributes. (PR #79646)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 16:02:15 PST 2024
================
@@ -1589,11 +1589,17 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
if (isKernelFunc) {
if (PTy) {
// Special handling for pointer arguments to kernel
+ // CUDA kernels assume that pointers are in global address space
+ // See:
+ // https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parameter-state-space
O << "\t.param .u" << PTySizeInBits << " ";
- if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() !=
+ int addrSpace = PTy->getAddressSpace();
+ if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() ==
NVPTX::CUDA) {
- int addrSpace = PTy->getAddressSpace();
+ assert(addrSpace == 0 && "Invalid address space");
----------------
Artem-B wrote:
I'd move the comment down into the CUDA branch as it's only relevant there.
Also, considering that we're comparing with *generic* AS, while the comment talks about `global` (we do have `ADDRESS_SPACE_GENERIC` constant for that, too), I'd rephrase it along the lines of "pointers are expected to be passed in generic AS, but are assumed to be pointing to objects in global AS."
https://github.com/llvm/llvm-project/pull/79646
More information about the llvm-commits
mailing list