[llvm] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

Jakub Chlanda via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 06:04:07 PDT 2023


================
@@ -307,6 +307,14 @@ void CodeGenModule::handleCUDALaunchBoundsAttr(
       NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "minctasm",
                                               MinBlocks.getExtValue());
   }
+  if (Attr->getMaxBlocks()) {
+    llvm::APSInt MaxBlocks(32);
+    MaxBlocks = Attr->getMaxBlocks()->EvaluateKnownConstInt(getContext());
+    if (MaxBlocks > 0)
+      // Create !{<func-ref>, metadata !"maxclusterrank", i32 <val>} node
+      NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "maxclusterrank",
----------------
jchlanda wrote:

That's a good question, so `makeLaunchBoundsArgEspr` does perform a [check for negative values](https://github.com/jchlanda/llvm-project/blob/jakub/launch_bounds_maxclusterrank/clang/lib/Sema/SemaDeclAttr.cpp#L5653), but lets the value pass (unlike for the case of values > 32 bits, when it returns `nullptr`), I didn't want to change it, so catch the negative case here.

https://github.com/llvm/llvm-project/pull/66496


More information about the llvm-commits mailing list