[LLVMdev] Question about load clustering in the machine scheduler

Andrew Trick atrick at apple.com
Thu Mar 26 23:50:20 PDT 2015

> On Mar 26, 2015, at 7:36 PM, Tom Stellard <tom at stellard.net> wrote:
> Hi,
> I have a program with over 100 loads (each with a 10 cycle latency)
> at the beginning of the program, and I can't figure out how to get
> the machine scheduler to intermix ALU instructions with the loads to
> effectively hide the latency.
> It seems the issue is with load clustering.  I restrict load clustering
> to 4 at a time, but when I look at the debug output, the loads are
> always being scheduled based on the fact that that are clustered. e.g.
> Pick Top CLUSTER
> Scheduling SU(10) %vreg13<def> = S_BUFFER_LOAD_DWORD_IMM %vreg9, 4; mem:LD4[<unknown>] SGPR_32:%vreg13 SReg_128:%vreg9

Well, only 4 loads in a sequence should have the “cluster” edges. You should be able to see that when the DAG is printed before scheduling.

Even without that limit, stalls take precedence over load clustering. So when you run out of load resources (15?) the scheduler should choose something else.

> I have a feeling there is something wrong with my machine model in the
> R600 backend, but I've experimented with a few variations of it and have
> been unable to solve this problem.  Does anyone have any idea what I
> might be doing wrong?

Sorry, not without actually looking through the debug output. The output lists the cycle time at each instruction, so you can see where the scheduler thinks the stalls are.

BTW- I just checked in a small fix for in-order scheduling that might make debugging this easier.


> Here are my resource definitions from lib/Target/R600/SISchedule.td
> // BufferSize = 0 means the processors are in-order.
> let BufferSize = 0 in {
> // XXX: Are the resource counts correct?
> def HWBranch : ProcResource<1>;  
> def HWExport : ProcResource<7>;   // Taken from S_WAITCNT
> def HWLGKM   : ProcResource<31>;  // Taken from S_WAITCNT
> def HWSALU   : ProcResource<1>;  
> def HWVMEM   : ProcResource<15>;  // Taken from S_WAITCNT
> def HWVALU   : ProcResource<1>;
> }

> Thanks,
> Tom
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list