[llvm-dev] RFC: make calls "convergent" by default
Sameer Sahasrabuddhe via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 2 21:26:45 PDT 2021
James Y Knight writes:
>> 2. D69498 will be updated so that the convergent property is made
>> default, but the new requirements on CPU frontends will be retracted.
> If I understand correctly, this means the Clang frontend will no longer
> need to add any convergent NOR noconvergent attributes. Instead, LLVM
> analysis passes can infer the new noconvergent attribute as appropriate.
> And on non-GPU platforms, the analysis can be skipped, and the optimization
> passes can simply ignore convergence attributes, because the hardware has
> no operations which can observe convergence. (So, it doesn't matter whether
> a function is marked noconvergent or not.)
> Which is to say: this proposal should make things *easier* for "naive"
> frontends, not harder. By default, a reasonable thing should happen when
> the frontend does nothing -- both on GPU platforms and non-GPU platforms.
> Especially if all of the code is in a single module (e.g., via LTO), there
> will be few calls to unknown destinations, so noconvergent can be inferred
> basically everywhere that is not *in fact* dependent on convergence.
This is more or less the intention, but I would reword it at follows:
- Frontends are no longer required to add a convergent or noconvergent
attribute if all they seek is correct execution on GPUs.
- A frontend or a suitable optimization may add the noconvergent
attribute to gain performance where it can prove that the execution of
the call or callee is not sensitive to which threads are executing
such a call.
- The convergence property is never "ignored" ... it is now built into
LLVM itself. But optimizations may rely on additional knowledge such
as divergence analysis to reason about whether a particular control
flow transformation is safe. This is not an explicitly target-specific
definition. It just so happens that on CPUs, there is no divergent
control flow, and hence it is "as if" the default convergent property
has no effect.
- This use of divergence analysis also benefits GPUs. For example, the
current implementation of sinking always bails out on a convergent
call. In reality, a convergent call can be sunk across a uniform
(non-divergent) branch. This is disallowed by the current overly
conservative definition of convergent, but will be allowed by the new
More information about the llvm-dev