[Mesa-dev] [PATCH 03/24] i965/fs: Keep track of flag dependencies with byte granularity during scheduling.

Jason Ekstrand jason at jlekstrand.net
Fri May 27 19:40:08 UTC 2016


On Thu, May 26, 2016 at 8:46 PM, Francisco Jerez <currojerez at riseup.net>
wrote:

> This prevents false dependencies from being created between
> instructions that write disjoint 8-bit portions of the flag register
> and OTOH should make sure that the scheduler considers dependencies
> between instructions that write or read multiple flag subregisters
> at once (e.g. 32-wide predication or conditional mods).
> ---
>  .../drivers/dri/i965/brw_schedule_instructions.cpp | 41
> ++++++++++++++++------
>  1 file changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
> b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
> index d40cbbd..b7ef151 100644
> --- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
> @@ -912,7 +912,7 @@ fs_instruction_scheduler::calculate_deps()
>      */
>     schedule_node *last_grf_write[grf_count * 16];
>     schedule_node *last_mrf_write[BRW_MAX_MRF(v->devinfo->gen)];
> -   schedule_node *last_conditional_mod[2] = { NULL, NULL };
> +   schedule_node *last_conditional_mod[4] = {};
>     schedule_node *last_accumulator_write = NULL;
>     /* Fixed HW registers are assumed to be separate from the virtual
>      * GRFs, so they can be tracked separately.  We don't really write
> @@ -966,8 +966,13 @@ fs_instruction_scheduler::calculate_deps()
>           }
>        }
>
> -      if (inst->reads_flag()) {
> -         add_dep(last_conditional_mod[inst->flag_subreg], n);
> +      if (const uint32_t mask = inst->flags_read(v->devinfo)) {
>

If we switch to a uint8_t, this should change too along with the other 3
below.


> +         assert(mask < (1 << ARRAY_SIZE(last_conditional_mod)));
> +
> +         for (unsigned i = 0; i < ARRAY_SIZE(last_conditional_mod); i++) {
> +            if (mask & (1 << i))
> +               add_dep(last_conditional_mod[i], n);
> +         }
>        }
>
>        if (inst->reads_accumulator_implicitly()) {
> @@ -1021,9 +1026,15 @@ fs_instruction_scheduler::calculate_deps()
>           }
>        }
>
> -      if (inst->writes_flag()) {
> -         add_dep(last_conditional_mod[inst->flag_subreg], n, 0);
> -         last_conditional_mod[inst->flag_subreg] = n;
> +      if (const uint32_t mask = inst->flags_written()) {
> +         assert(mask < (1 << ARRAY_SIZE(last_conditional_mod)));
> +
> +         for (unsigned i = 0; i < ARRAY_SIZE(last_conditional_mod); i++) {
> +            if (mask & (1 << i)) {
> +               add_dep(last_conditional_mod[i], n, 0);
> +               last_conditional_mod[i] = n;
> +            }
> +         }
>        }
>
>        if (inst->writes_accumulator_implicitly(v->devinfo) &&
> @@ -1078,8 +1089,13 @@ fs_instruction_scheduler::calculate_deps()
>           }
>        }
>
> -      if (inst->reads_flag()) {
> -         add_dep(n, last_conditional_mod[inst->flag_subreg]);
> +      if (const uint32_t mask = inst->flags_read(v->devinfo)) {
> +         assert(mask < (1 << ARRAY_SIZE(last_conditional_mod)));
> +
> +         for (unsigned i = 0; i < ARRAY_SIZE(last_conditional_mod); i++) {
> +            if (mask & (1 << i))
> +               add_dep(n, last_conditional_mod[i]);
> +         }
>        }
>
>        if (inst->reads_accumulator_implicitly()) {
> @@ -1130,8 +1146,13 @@ fs_instruction_scheduler::calculate_deps()
>           }
>        }
>
> -      if (inst->writes_flag()) {
> -         last_conditional_mod[inst->flag_subreg] = n;
> +      if (const uint32_t mask = inst->flags_written()) {
> +         assert(mask < (1 << ARRAY_SIZE(last_conditional_mod)));
> +
> +         for (unsigned i = 0; i < ARRAY_SIZE(last_conditional_mod); i++) {
> +            if (mask & (1 << i))
> +               last_conditional_mod[i] = n;
> +         }
>        }
>
>        if (inst->writes_accumulator_implicitly(v->devinfo)) {
> --
> 2.7.3
>
> _______________________________________________
> 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/20160527/159b2e23/attachment-0001.html>


More information about the mesa-dev mailing list