[Mesa-dev] [PATCH v3 1/7] nir: adjust subgroups instructions for 64bit ballot sizes

Jason Ekstrand jason at jlekstrand.net
Tue Apr 10 15:17:47 UTC 2018


On Tue, Apr 10, 2018 at 7:37 AM, Daniel Schürmann <
daniel.schuermann at campus.tu-berlin.de> wrote:

> ---
>  src/compiler/nir/nir_lower_subgroups.c |  5 ++---
>  src/compiler/nir/nir_opcodes.py        | 12 ++++++------
>  2 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/compiler/nir/nir_lower_subgroups.c
> b/src/compiler/nir/nir_lower_subgroups.c
> index 0d3c83b795..9dc7be7947 100644
> --- a/src/compiler/nir/nir_lower_subgroups.c
> +++ b/src/compiler/nir/nir_lower_subgroups.c
> @@ -357,9 +357,8 @@ lower_subgroups_intrin(nir_builder *b,
> nir_intrinsic_instr *intrin,
>        switch (intrin->intrinsic) {
>        case nir_intrinsic_ballot_bitfield_extract:
>           assert(intrin->src[1].is_ssa);
> -         return nir_i2b(b, nir_iand(b, nir_ushr(b, int_val,
> -                                                   intrin->src[1].ssa),
> -                                       nir_imm_int(b, 1)));
> +         return nir_i2b(b, nir_iand(b, nir_ushr(b, int_val,
> intrin->src[1].ssa),
> +                        nir_imm_intN_t(b, 1, options->ballot_bit_size)));
>

Oops.  This didn't automatically scale as I intended. :-/  The indentation
seems a bit weird but there's not much you can do.  This hunk (as it's own
patch) looks good.


>        case nir_intrinsic_ballot_bit_count_reduce:
>           return nir_bit_count(b, int_val);
>        case nir_intrinsic_ballot_find_lsb:
> diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_
> opcodes.py
> index a762fdd220..89a6c6becc 100644
> --- a/src/compiler/nir/nir_opcodes.py
> +++ b/src/compiler/nir/nir_opcodes.py
> @@ -308,17 +308,17 @@ dst = 0;
>  for (unsigned bit = 0; bit < 32; bit++)
>     dst |= ((src0 >> bit) & 1) << (31 - bit);
>  """)
> -unop("bit_count", tuint32, """
> +unop_convert("bit_count", tuint32, tuint, """
>  dst = 0;
> -for (unsigned bit = 0; bit < 32; bit++) {
> +for (unsigned bit = 0; bit < bit_size; bit++) {
>     if ((src0 >> bit) & 1)
>        dst++;
>  }
>  """)
>
> -unop_convert("ufind_msb", tint32, tuint32, """
> +unop_convert("ufind_msb", tint32, tuint, """
>  dst = -1;
> -for (int bit = 31; bit >= 0; bit--) {
> +for (int bit = bit_size - 1; bit >= 0; bit--) {
>     if ((src0 >> bit) & 1) {
>        dst = bit;
>        break;
> @@ -340,9 +340,9 @@ for (int bit = 31; bit >= 0; bit--) {
>  }
>  """)
>
> -unop("find_lsb", tint32, """
> +unop_convert("find_lsb", tint32, tint, """
>  dst = -1;
> -for (unsigned bit = 0; bit < 32; bit++) {
> +for (unsigned bit = 0; bit < bit_size; bit++) {
>

These three changes should probably be their own patch.  They look fine to
me though.


>     if ((src0 >> bit) & 1) {
>        dst = bit;
>        break;
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180410/703bad3b/attachment-0001.html>


More information about the mesa-dev mailing list