[Mesa-dev] [PATCH 2/2] nvir/gm107: consider FILE_FLAGS dependencies in SchedDataCalculatorGM107

Samuel Pitoiset samuel.pitoiset at gmail.com
Sat Feb 10 17:25:20 UTC 2018



On 12/05/2017 12:01 PM, Karol Herbst wrote:
> currently while insterting barriers, writes and reads to FILE_FLAGS aren't
> considered. This can lead to WaR hazards in some situations.
> 
> Fixes OpenCL CTS tests on Maxwell+:
> basic/test_basic.intmath_long.LONG_MAD
> basic/test_basic.intmath_long2.LONG_MAD
> basic/test_basic.intmath_long4.LONG_MAD
> 
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>   src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
> index db1585818c..cd75d531df 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
> @@ -3949,6 +3949,7 @@ SchedDataCalculatorGM107::needWrDepBar(const Instruction *insn) const
>   
>      for (int d = 0; insn->defExists(d); ++d) {
>         if (insn->def(d).getFile() == FILE_GPR ||
> +          insn->def(d).getFile() == FILE_FLAGS ||
>             insn->def(d).getFile() == FILE_PREDICATE)
>            return true;
>      }
> @@ -3988,6 +3989,9 @@ SchedDataCalculatorGM107::findFirstUse(const Instruction *bari) const
>                     continue;
>                  return insn;
>               }
> +            if (bari->def(d).getFile() == FILE_FLAGS) {
> +               return insn;
> +            }

So, if an instruction returns the $c flag stuff, you are going to put a 
barrier on the next instruction, always?

Can't this be slightly improved like what we do for predicates? (ie. 
check if the source is a FILE_FLAGS and its id).

>            }
>         }
>      }
> @@ -4007,7 +4011,8 @@ SchedDataCalculatorGM107::findFirstDef(const Instruction *bari) const
>   
>         for (int d = 0; insn->defExists(d); ++d) {
>            const Value *def = insn->def(d).rep();
> -         if (insn->def(d).getFile() != FILE_GPR)
> +         if (insn->def(d).getFile() != FILE_GPR &&
> +             insn->def(d).getFile() != FILE_FLAGS)
>               continue;
>   
>            minGPR = def->reg.data.id;
> @@ -4015,7 +4020,11 @@ SchedDataCalculatorGM107::findFirstDef(const Instruction *bari) const
>   
>            for (int s = 0; bari->srcExists(s); ++s) {
>               const Value *src = bari->src(s).rep();
> +            if (bari->src(s).getFile() == FILE_FLAGS &&
> +                insn->def(d).getFile() == FILE_FLAGS)
> +               return insn;
>               if (bari->src(s).getFile() != FILE_GPR ||
> +                insn->def(d).getFile() != FILE_GPR ||
>                   src->reg.data.id + src->reg.size / 4 - 1 < minGPR ||
>                   src->reg.data.id > maxGPR)
>                  continue;
> 


More information about the mesa-dev mailing list