Skip to content

[clang] noconvergent does not affect calls to convergent functions #132701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1658,17 +1658,16 @@ Sample usage:
def NoConvergentDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
This attribute prevents a function from being treated as convergent, which
means that optimizations can only move calls to that function to
control-equivalent blocks. If a statement is marked as ``noconvergent`` and
contains calls, it also prevents those calls from being treated as convergent.
In other words, those calls are not restricted to only being moved to
control-equivalent blocks.
This attribute prevents a function from being treated as convergent; when a
function is marked ``noconvergent``, calls to that function are not
automatically assumed to be convergent, unless such calls are explicitly marked
as ``convergent``. If a statement is marked as ``noconvergent``, any calls to
inline ``asm`` in that statement are no longer treated as convergent.

In languages following SPMD/SIMT programming model, e.g., CUDA/HIP, function
declarations and calls are treated as convergent by default for correctness.
This ``noconvergent`` attribute is helpful for developers to prevent them from
being treated as convergent when it's safe.
declarations and inline asm calls are treated as convergent by default for
correctness. This ``noconvergent`` attribute is helpful for developers to
prevent them from being treated as convergent when it's safe.

.. code-block:: c

Expand All @@ -1677,7 +1676,8 @@ being treated as convergent when it's safe.

__device__ int example(void) {
float x;
[[clang::noconvergent]] x = bar(x);
[[clang::noconvergent]] x = bar(x); // no effect on convergence
[[clang::noconvergent]] { asm volatile ("nop"); } // the asm call is non-convergent
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should have an example of an undefined usage


}];
Expand Down