[llvm] r279995 - AMDGPU/SI: Implement a custom MachineSchedStrategy

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 09:39:06 PDT 2016


On Mon, Aug 29, 2016 at 03:01:00PM -0500, Hal Finkel via llvm-commits wrote:
> Hi Tom,
> 
> This is interesting. I see the following note:
> 
> +  // If two instructions increase the pressure of different register sets
> +  // by the same amount, the generic scheduler will prefer to schedule the
> +  // instruction that increases the set with the least amount of registers,
> +  // which in our case would be SGPRs.  This is rarely what we want, so
> +  // when we report excess/critical register pressure, we do it either
> +  // only for VGPRs or only for SGPRs.
> 
> Is this the main difference? Could you explain why this matters? This seems like a lot of boilerplate just to make that change. Is there some other hook we should have?
> 

There are a few differences between this custom scheduler and
GenericScheduler.

The first and most important is that the GCN scheduler only considers
two register pressure sets one that includes all VGPRs and one that
includes all SGPRs.  There are other pressure sets that are generated
by TableGen, that are either subsets or intersections of these sets,
but we don't need these sets to compute accurate register pressure,
and they usually end up just confusing the scheduler into making bad
choices.

The second difference is the computation of the Excess register sets, which
is what this comment refers to.  There is already a hook to allow 
backends to break ties between register sets that increase pressure
equally: TRI->getRegPressureSetScore(MF, TryPSet), however, there is
one other thing we need to consider and that is if both VGPR and SGPR
sets are determined to be Excess sets, we want the scheduler to only
consider VGPR pressure, because VGPR spills are more expensive.

We also compute our own Excess/Critical limits based on current
register pressure and other properties of the program.

-Tom

> Thanks again,
> Hal
> 
> ----- Original Message -----
> > From: "Tom Stellard via llvm-commits" <llvm-commits at lists.llvm.org>
> > To: llvm-commits at lists.llvm.org
> > Sent: Monday, August 29, 2016 2:42:52 PM
> > Subject: [llvm] r279995 - AMDGPU/SI: Implement a custom MachineSchedStrategy
> > 
> > Author: tstellar
> > Date: Mon Aug 29 14:42:52 2016
> > New Revision: 279995
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=279995&view=rev
> > Log:
> > AMDGPU/SI: Implement a custom MachineSchedStrategy
> > 
> > Summary:
> > GCNSchedStrategy re-uses most of GenericScheduler, it's just uses
> > a different method to compute the excess and critical register
> > pressure limits.
> > 
> > It's not enabled by default, to enable it you need to pass
> > -misched=gcn
> > to llc.
> > 
> ...
> > 
> > 
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> > 
> 
> -- 
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list