[Mesa-dev] [PATCH 4/5] nir: Lower flrp(1.0, b, c) and flrp(a, 1.0, c) differently
Jason Ekstrand
jason at jlekstrand.net
Wed Aug 15 09:58:40 UTC 2018
re-associating based on whether or not something has a constant value of
1.0 seems a bit sneaky. I think it's well within the rules but it seems
like something that could bite you.
On Mon, Aug 13, 2018 at 6:35 PM Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Instead of lowering as (a + c(b - a)), lower as (a(1 - c) + bc). Since
> either a or b is 1.0, some of the multiplications drop out.
>
> I am CC'ing people who are responsible for drivers that set lower_flrp32
> as this patch will likely affect shader-db results for those drivers.
>
> No changes on any Gen6+ platform.
>
> Iron Lake
> total instructions in shared programs: 7745041 -> 7731595 (-0.17%)
> instructions in affected programs: 1647106 -> 1633660 (-0.82%)
> helped: 5522
> HURT: 281
> helped stats (abs) min: 1 max: 12 x̄: 2.53 x̃: 2
> helped stats (rel) min: 0.14% max: 12.00% x̄: 1.45% x̃: 0.99%
> HURT stats (abs) min: 1 max: 5 x̄: 1.94 x̃: 2
> HURT stats (rel) min: 0.13% max: 4.17% x̄: 0.74% x̃: 0.68%
> 95% mean confidence interval for instructions value: -2.35 -2.28
> 95% mean confidence interval for instructions %-change: -1.38% -1.31%
> Instructions are helped.
>
> total cycles in shared programs: 178004318 -> 177937186 (-0.04%)
> cycles in affected programs: 31813800 -> 31746668 (-0.21%)
> helped: 5420
> HURT: 631
> helped stats (abs) min: 2 max: 168 x̄: 13.15 x̃: 12
> helped stats (rel) min: 0.01% max: 6.37% x̄: 0.67% x̃: 0.30%
> HURT stats (abs) min: 2 max: 328 x̄: 6.57 x̃: 4
> HURT stats (rel) min: 0.01% max: 2.78% x̄: 0.16% x̃: 0.11%
> 95% mean confidence interval for cycles value: -11.35 -10.84
> 95% mean confidence interval for cycles %-change: -0.60% -0.56%
> Cycles are helped.
>
> GM45
> total instructions in shared programs: 4777279 -> 4770160 (-0.15%)
> instructions in affected programs: 928555 -> 921436 (-0.77%)
> helped: 2902
> HURT: 149
> helped stats (abs) min: 1 max: 12 x̄: 2.55 x̃: 2
> helped stats (rel) min: 0.14% max: 11.11% x̄: 1.38% x̃: 0.91%
> HURT stats (abs) min: 1 max: 5 x̄: 1.93 x̃: 2
> HURT stats (rel) min: 0.13% max: 4.00% x̄: 0.72% x̃: 0.68%
> 95% mean confidence interval for instructions value: -2.38 -2.28
> 95% mean confidence interval for instructions %-change: -1.33% -1.23%
> Instructions are helped.
>
> total cycles in shared programs: 122063992 -> 122021958 (-0.03%)
> cycles in affected programs: 20838672 -> 20796638 (-0.20%)
> helped: 2921
> HURT: 454
> helped stats (abs) min: 2 max: 168 x̄: 15.40 x̃: 14
> helped stats (rel) min: 0.01% max: 6.37% x̄: 0.67% x̃: 0.29%
> HURT stats (abs) min: 2 max: 328 x̄: 6.49 x̃: 4
> HURT stats (rel) min: 0.02% max: 2.78% x̄: 0.16% x̃: 0.11%
> 95% mean confidence interval for cycles value: -12.86 -12.04
> 95% mean confidence interval for cycles %-change: -0.59% -0.53%
> Cycles are helped.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: Marek Olšák <marek.olsak at amd.com>
> Cc: Rob Clark <robdclark at gmail.com>
> Cc: Eric Anholt <eric at anholt.net>
> ---
> src/compiler/nir/nir_opt_algebraic.py | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py
> b/src/compiler/nir/nir_opt_algebraic.py
> index e770a61d9ff..f11a987c462 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -116,6 +116,10 @@ optimizations = [
> (('~flrp', 0.0, a, b), ('fmul', a, b)),
> (('~flrp', a, b, ('b2f', c)), ('bcsel', c, b, a),
> 'options->lower_flrp32'),
> (('~flrp', a, 0.0, c), ('fadd', ('fmul', ('fneg', a), c), a)),
> + (('flrp at 32', 1.0, b, c), ('fadd', ('fsub', 1.0, c), ('fmul', b, c)),
> 'options->lower_flrp32'),
> + (('flrp at 64', 1.0, b, c), ('fadd', ('fsub', 1.0, c), ('fmul', b, c)),
> 'options->lower_flrp64'),
> + (('flrp at 32', a, 1.0, c), ('fadd', a, ('fmul', c, ('fsub', 1.0, a))),
> 'options->lower_flrp32'),
> + (('flrp at 64', a, 1.0, c), ('fadd', a, ('fmul', c, ('fsub', 1.0, a))),
> 'options->lower_flrp64'),
> (('flrp at 32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a),
> 'options->lower_flrp32'),
> (('flrp at 64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a),
> 'options->lower_flrp64'),
> (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> @@ -125,6 +129,8 @@ optimizations = [
> (('~fadd', a, ('fmul', ('b2f', c), ('fadd', b, ('fneg', a)))),
> ('bcsel', c, b, a), 'options->lower_flrp32'),
> (('~fadd at 32', a, ('fmul', c , ('fadd', b, ('fneg', a)))),
> ('flrp', a, b, c), '!options->lower_flrp32'),
> (('~fadd at 64', a, ('fmul', c , ('fadd', b, ('fneg', a)))),
> ('flrp', a, b, c), '!options->lower_flrp64'),
> + (('~fadd at 32', 1.0, ('fmul', c , ('fadd', b, -1.0 ))),
> ('fadd', ('fsub', 1.0, c), ('fmul', b, c)), 'options->lower_flrp32'),
> + (('~fadd at 64', 1.0, ('fmul', c , ('fadd', b, -1.0 ))),
> ('fadd', ('fsub', 1.0, c), ('fmul', b, c)), 'options->lower_flrp64'),
> (('ffma', a, b, c), ('fadd', ('fmul', a, b), c),
> 'options->lower_ffma'),
> (('~fadd', ('fmul', a, b), c), ('ffma', a, b, c),
> 'options->fuse_ffma'),
>
> --
> 2.14.4
>
> _______________________________________________
> 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/20180815/a8f90d24/attachment.html>
More information about the mesa-dev
mailing list