[PATCH] D69498: IR: Invert convergent attribute handling

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 30 04:43:42 PDT 2021


sameerds added a comment.

In D69498#2728451 <https://reviews.llvm.org/D69498#2728451>, @JonChesterfield wrote:

> I wonder if it is necessary for the exec mask to be implicit state, managed by a convergent/divergent abstraction.
>
> We could reify it as an argument passed to kernels (where all bits are set), and adjusted by phi nodes at entry to basic blocks. Various intrinsics take and return that reified value. __ballot, a comparison op, possibly load/store.
>
> At that point all the awkward control flow constraints are raised to data flow, and I think (but haven't really chased this into the dark corners) that solves the problems I know about. Notably, a uniform branch would be one where the exec mask value was unchanged, so the associated phi is constant folded.
>
> Makes a mess of the human readable IR, but possibly at a lower overall complexity than continuing to handle divergence as control flow.

That is essentially what the current divergence analysis (Karrenberg and Hack) does anyway. Except that since we don't know how many threads are running concurrently, the mask is a symbolic value that can either be "divergent" or "uniform". If I am looking at this the right way, you seem to be saying two separate things: the notion of divergence/uniformity is what solves the problem at hand, and separately, the notion of divergence can be turned into explicit dataflow.

> edit: said reified mask, if integer, would also be the value post-volta sync intrinsics take, where the developer is supposed to compute the mask across branches and pass it around everywhere. Clang could therefore provide builtins that lower to those sync intrinsics with an always correct mask automatically passed. That would make volta much easier to program.

Additionally, the explicit mask (if we could agree on its type) would make it possible to have "dynamic uniformity". Currently we can only prove static uniformity.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69498/new/

https://reviews.llvm.org/D69498



More information about the llvm-commits mailing list