On Tue, May 7, 2019 at 9:28 AM Ilia Mirkin <[email protected]> wrote:
> Divergence is generally when multiple parallel "lanes" go in different > directions -- a jump that some lanes take and others don't, which > requires the GPU to execute some lanes first, and then the rest, > separately. > > IMO better names might be is_scalar_swizzle or something. > I was going to make roughly the same comment but couldn't come up with a good name suggestion. I like is_scalar_swizzle. :-D > On Mon, May 6, 2019 at 11:00 PM Alyssa Rosenzweig <[email protected]> > wrote: > > > > This allows algebraic optimizations to check if the argument accesses > > multiple distinct components of a vector. So a swizzle like "xyz" will > > return true, but "yyy" will return false, as will a scalar. This can be > > useful for optimizations on vector processors, where a convergent > > swizzle can be done in one clock (replicating as if a scalar) but a > > divergent one must be scalarized. In these cases, it is useful to > > optimize differently based on whether the swizzle diverges. (Use case is > > the "csel" condition on Midgard). > > > > Signed-off-by: Alyssa Rosenzweig <[email protected]> > > Cc: Jason Ekstrand <[email protected]> > > --- > > src/compiler/nir/nir_search_helpers.h | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/src/compiler/nir/nir_search_helpers.h > b/src/compiler/nir/nir_search_helpers.h > > index 1624508993d..46d7c300643 100644 > > --- a/src/compiler/nir/nir_search_helpers.h > > +++ b/src/compiler/nir/nir_search_helpers.h > > @@ -143,6 +143,22 @@ is_not_const(nir_alu_instr *instr, unsigned src, > UNUSED unsigned num_components, > > return !nir_src_is_const(instr->src[src].src); > > } > > > > +/* I.e. a vector that actually accesses multiple channels */ > > + > > +static inline bool > > +is_divergent_vector(nir_alu_instr *instr, UNUSED unsigned src, unsigned > num_components, > > + const uint8_t *swizzle) > > +{ > > + unsigned first_component = swizzle[0]; > > + > > + for (unsigned i = 1; i < num_components; ++i) { > > + if (swizzle[i] != first_component) > > + return true; > > + } > > Can num_components be 1? If so, then this will return false, whereas > you probably wanted it to return true. > Yes, it can. Good catch! > > + > > + return false; > > +} > > + > > static inline bool > > is_used_more_than_once(nir_alu_instr *instr) > > { > > -- > > 2.20.1 > > > > _______________________________________________ > > mesa-dev mailing list > > [email protected] > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ > mesa-dev mailing list > [email protected] > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
