This fix allows the scheduler to take into account the number of
instances of each ProcResource specified. Previously a declaration in a
scheduler of ProcResource<1> would be treated identically to a
declaration of ProcResource<2>. This patch fixes that. Testsuite
fixes are included for schedulers that have changed.
Details
- Reviewers
javed.absar atrick MatzeB Jackson andreadb - Commits
- rZORGe48a4961acdf: Adjust MachineScheduler to use ProcResource counts
rZORGa5d700ca78c3: Adjust MachineScheduler to use ProcResource counts
rGe48a4961acdf: Adjust MachineScheduler to use ProcResource counts
rGa5d700ca78c3: Adjust MachineScheduler to use ProcResource counts
rGc396f09ce96e: Adjust MachineScheduler to use ProcResource counts
rL360441: Adjust MachineScheduler to use ProcResource counts
Diff Detail
Event Timeline
Would it be possible to add a test case that highlights the problem you are solving e.g. take a processor that has multiple resources (e.g. two adders) and show that it now can use both resources in same cycle.
lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
1945 ↗ | (On Diff #162169) | why Offset is uninitialized ? |
lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
1937 ↗ | (On Diff #162169) | I would write it like: /// Compute the next cycle at which the given processor resource can be /// scheduled. Returns (NextCycle, InstanceIDAssignedTo). std::pair<unsigned, unsigned> SchedBoundary:: getNextResourceCycle(unsigned PIdx, unsigned ResCount, unsigned Cycles) { unsigned MinNextUnreserved = InvalidCycle; unsigned InstanceID = 0; unsigned StartIndex = ProcessorResourceList[PIdx]; unsigned NumUnits = SchedModel->getProcResource(PIdx)->NumUnits; for (unsigned I = StartIndex, E = StartIndex + NumUnits; I < E; ++I) { unsigned NextUnreserved = getNextResourceCycleByInstance(I, Cycles); if (NextUnreserved < MinNextUnreserved) { InstanceID = I; MinNextUnreserved = NextUnreserved; } } return std::make_pair(MinNextUnreserved, InstanceID); } but YMMV. |
lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
1937 ↗ | (On Diff #162169) | Where does InvalidCycle come from here? |
lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
1937 ↗ | (On Diff #162169) | line 1817 |
Thanks for the feedback. I have fixed up the getNextResourceCycle function and added a testcase.
test/CodeGen/ARM/proc_resouces_schedule.ll | ||
---|---|---|
1 ↗ | (On Diff #163088) | The filename has a typo 'resouces'. |
Do you have any benchmark data you could share with this patch? I am curious what the impact is and if there are any regressions.
llvm/include/llvm/CodeGen/MachineScheduler.h | ||
---|---|---|
671 | This name is too generic I think. this is only relevant to ReservedCycles. Also it is basically a map, right? | |
llvm/include/llvm/CodeGen/TargetSchedule.h | ||
119 ↗ | (On Diff #192220) | Is there a benefit if adding this over just using getProcResource? Leaking the table may make future changes harder. |
llvm/lib/CodeGen/MachineScheduler.cpp | ||
1953 | ResCount not used here? I think you can remove it, as you get it from the model in the function. | |
2014–2015 | InstanceID unused? | |
2180 | InstanceID only used with DEBUG? | |
2183 | Can we convert the instanceID to a resource name? | |
llvm/test/CodeGen/ARM/proc-resource-sched.ll | ||
16 | The function is quite small, can you check the full schedule? |
llvm/include/llvm/CodeGen/MachineScheduler.h | ||
---|---|---|
671 | I agree: the name should be improved. | |
llvm/include/llvm/CodeGen/TargetSchedule.h | ||
119 ↗ | (On Diff #192220) | +1. I don't think it is really needed (see my other comment below). |
llvm/lib/CodeGen/MachineScheduler.cpp | ||
1911–1914 | Instead of doing (Resources + i)->NumUnits, you should use So, something like: NumUnits += SchedModel->getProcResource(i)->NumUnits; That way, you can get rid of the code at line 1924. You also don't need method getProcResourceTable(). | |
1958–1959 | We should probably enforce this constraint in the SubtargetEmitter and error out if a processor resource declares zero (or negative) units. (In practice, none of the models available upstream declares a resource with zero units. Only the 'InvalidUnit' at index 0 defaults to having zero units). |
I scanned the code. It seems reasonable to me. Thanks for all the other good review feedback.
No, I'm sorry, I don't have publishable benchmark results at the moment.
llvm/lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
2014–2015 | Yes, it's unused, here and in one more place we care only for the cycle number. | |
llvm/test/CodeGen/ARM/proc-resource-sched.ll | ||
16 | I'm not sure what do you mean. The test tests the difference in the internal state of the scheduler, which does not necesarily results in different schedule. Perhaps I can make a bigger test case, but I'd rather not do it as it'll have the tendency to break with unrelated scheduler changes. |
llvm/lib/CodeGen/MachineScheduler.cpp | ||
---|---|---|
1958–1959 | That would be for a separate patch, wouldn't it ? |
This name is too generic I think. this is only relevant to ReservedCycles. Also it is basically a map, right?