This is an archive of the discontinued LLVM Phabricator instance.

MachineScheduler/ScheduleDAG: Add support for getSUTopoIndex
AcceptedPublic

Authored by axeldavy on Apr 2 2017, 2:38 PM.

Details

Reviewers
MatzeB
vpykhtin
Summary

Add support for getSUTopoIndex to ScheduleDAGTopologicalSort.
Node2Index is a topological sort on the SUs.
getSUTopoIndex returns Node2Index[SU->NodeNum] (when not boundary SU),
which is the topological index in the topological sort of ScheduleDAGTopologicalSort.

I would like to use Node2Index in my updated register tracking for D31124.

Diff Detail

Repository
rL LLVM

Event Timeline

axeldavy created this revision.Apr 2 2017, 2:38 PM
MatzeB edited edge metadata.Apr 3 2017, 9:25 AM
  • Choose a better function name!
  • Now that the function is public you should also document some facts about it like what to use as index into the vector or the range of indizes coming out of it.
  • Instead of returning const vector<int>& better use ArrayRef<int> as that gives less constraints on the internal implementation.
  • Is it necessary to return the array as a whole or would a simpler function suffice that takes a single const SUnit& and returns the index into the corresponding topological ordering?
  • Choose a better function name!

getTopoIndexes ?

  • Now that the function is public you should also document some facts about it like what to use as index into the vector or the range of indizes coming out of it.

What about:
/ / / Node2Index[SU->NodeNum] (when not boundary SU) gives the topological index in the topological sort of ScheduleDAGTopologicalSort.
/ / / The index is contained between 0 and SUnits.count()-1

  • Instead of returning const vector<int>& better use ArrayRef<int> as that gives less constraints on the internal implementation.

Ok

  • Is it necessary to return the array as a whole or would a simpler function suffice that takes a single const SUnit& and returns the index into the corresponding topological ordering?

No, I'd be fine with a function returning Node2Index[SU->NodeNum]. Do you think a function would be preferable ?
One worry is that if we write a function that takes SU and returns the index, it'd likely have to check for boundaries every call.

MatzeB added a comment.Apr 3 2017, 1:04 PM
  • Choose a better function name!

getTopoIndexes ?

  • Now that the function is public you should also document some facts about it like what to use as index into the vector or the range of indizes coming out of it.

What about:
/ / / Node2Index[SU->NodeNum] (when not boundary SU) gives the topological index in the topological sort of ScheduleDAGTopologicalSort.
/ / / The index is contained between 0 and SUnits.count()-1

  • Instead of returning const vector<int>& better use ArrayRef<int> as that gives less constraints on the internal implementation.

Ok

  • Is it necessary to return the array as a whole or would a simpler function suffice that takes a single const SUnit& and returns the index into the corresponding topological ordering?

No, I'd be fine with a function returning Node2Index[SU->NodeNum]. Do you think a function would be preferable ?
One worry is that if we write a function that takes SU and returns the index, it'd likely have to check for boundaries every call.

The function would not expose the fact that we currently have an underlying std::vector to the API (ArrayRef makes it slightly better but it still forces the implementation to use some form of array). So if the function works as well I would prefer that.

As for performance you would perform the bound checks in an assert() so they are not present in a release compiler.

MatzeB added a comment.Apr 3 2017, 1:09 PM
  • Choose a better function name!

getTopoIndexes ?

that sounds better.

  • Now that the function is public you should also document some facts about it like what to use as index into the vector or the range of indizes coming out of it.

What about:
/ / / Node2Index[SU->NodeNum] (when not boundary SU) gives the topological index in the topological sort of ScheduleDAGTopologicalSort.
/ / / The index is contained between 0 and SUnits.count()-1

Maybe "Maps an SUnit node number to indexes of a topological ordering. The index is between 0 and SUnits.count()-1. Boundary SUnits are not mapped."

  • Instead of returning const vector<int>& better use ArrayRef<int> as that gives less constraints on the internal implementation.

Ok

  • Is it necessary to return the array as a whole or would a simpler function suffice that takes a single const SUnit& and returns the index into the corresponding topological ordering?

No, I'd be fine with a function returning Node2Index[SU->NodeNum]. Do you think a function would be preferable ?
One worry is that if we write a function that takes SU and returns the index, it'd likely have to check for boundaries every call.

axeldavy updated this revision to Diff 93943.Apr 3 2017, 2:05 PM
axeldavy retitled this revision from MachineScheduler/ScheduleDAG: Add support for getNode2Index to MachineScheduler/ScheduleDAG: Add support for getSUTopoIndex.
axeldavy edited the summary of this revision. (Show Details)

Replaced getNode2Index by getSUTopoIndex, and completed documentation.

axeldavy updated this revision to Diff 93946.Apr 3 2017, 2:07 PM

Bad diff uploaded. This is the correct diff.

axeldavy updated this revision to Diff 93947.Apr 3 2017, 2:14 PM

I made the input const.
Should the result be const as well ?

MatzeB accepted this revision.Apr 3 2017, 3:25 PM

LGTM.

Should the result be const as well ?

The result is passed by value so no need for const (it wouldn't change anything). You should make the getSUTopoIndex() method const though.

This revision is now accepted and ready to land.Apr 3 2017, 3:25 PM
vpykhtin accepted this revision.Apr 12 2017, 3:58 AM

LGTM.