[Mesa-dev] [PATCH 0/4] nir: Cross-thread, uniform-control, and convergent attributes

Connor Abbott connora at valvesoftware.com
Tue Aug 1 02:02:02 UTC 2017


From: Connor Abbott <cwabbott0 at gmail.com>

This series adds some more precise semantics for instructions added by
ARB_shader_ballot and ARB_shader_group_vote, which should allow the
optimizer more freedom. I based it off my previous series [1], but
since the intrinsics have already landed in master since then, this
series changes them to use the new attributes instead. I've also renamed
"convergent" to "uniform-control" to reduce confusion, and I've added a
new "convergent" attribute that's similar in spirit to the LLVM one.

There was some debate last time about whether derivatives should be
marked uniform-control or just convergent. I've realized that our
current behavior actually already assumed that derivatives are
uniform-control. In particular, with something like this (contrived)
example:

do {
   ... = dFdx(a);
} while(...);
... = dFdx(a);

CSE would happily merge the second dFdx into the first, even though in
general this isn't allowed for operations that are convergent, since if
the loop condition is non-uniform, then the first dFdx will be called
with a smaller execution mask than the second. Under the current model,
we'd have to assume that the first dFdx is always called in uniform
control flow to make the transform correct. So, in order to keep the
same behavior for derivatives that we previously had, we need to make
them uniform-control. If we run into problems with people calling
derivatives in non-uniform control flow if/when we add more aggresive
optimizations, then we can always fall back to making them convergent
now that we have the convergent attribute.

[1] https://lists.freedesktop.org/archives/mesa-dev/2017-June/157909.html

Connor Abbott (4):
  nir: add new convergent, uniform-control, and cross-thread attributes
  nir/gcm: use the new convergent attribute
  nir: take cross-thread operations into account into a few places
  nir: use new attributes for ARB_shader_ballot and
    ARB_shader_group_vote

 src/compiler/nir/nir.h                     | 126 +++++++++++++++++++++++++++++
 src/compiler/nir/nir_instr_set.c           |  24 ++++++
 src/compiler/nir/nir_intrinsics.h          |  35 ++++++--
 src/compiler/nir/nir_opt_gcm.c             |  72 ++++++-----------
 src/compiler/nir/nir_opt_peephole_select.c |  11 +++
 5 files changed, 213 insertions(+), 55 deletions(-)

-- 
2.9.4



More information about the mesa-dev mailing list