[clang] [CUDA] Add support for __grid_constant__ attribute (PR #114589)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 11:29:59 PST 2024
================
@@ -12222,8 +12222,17 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
<< NewFD;
}
- if (!Redeclaration && LangOpts.CUDA)
+ if (!Redeclaration && LangOpts.CUDA) {
----------------
Artem-B wrote:
I deliberately decided *not* to do that.
`__grid_constant__` is an optimization hint, and LLVM *will* ignore it if the attribute is present, but we're targeting an older GPU, or generating an older PTX version. Considering that using the attribute with pre-sm70 GPU does no harm I do not think it should be an error.
NVCC's insistence on erroring out if the attribute is used during compilation for an older GPU is unnecessaryand it makes the attribute a pain to use in practice. Considering that it's not uncommon to compile the same source code for multiple GPUs, including the older ones, we'll have to resort to preprocessor tweaks and undef the attribute way, if we want to give compiler a hint that we want to avoid copying some arguments.
https://github.com/llvm/llvm-project/pull/114589
More information about the cfe-commits
mailing list