This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Refactor InterfaceMap to use a sorted vector of interfaces, as opposed to a DenseMap
ClosedPublic

Authored by rriddle on Feb 4 2021, 3:46 PM.

Details

Summary

A majority of operations have a very small number of interfaces, which means that the cost of using a hash map is generally larger for interface lookups than just a binary search. In the future when there are a number of operations with large amounts of interfaces, we can switch to a hybrid approach that optimizes lookups based on the number of interfaces. For now, however, a binary search is the best approach.

This dropped compile time on a largish TF MLIR module by 20%(half a second).

Diff Detail

Event Timeline

rriddle created this revision.Feb 4 2021, 3:46 PM
rriddle requested review of this revision.Feb 4 2021, 3:46 PM
jpienaar accepted this revision.Feb 4 2021, 4:27 PM

Nice

mlir/include/mlir/IR/OperationSupport.h
330–332

Was this change needed too?

mlir/include/mlir/Support/InterfaceSupport.h
195

Could this be hoisted into a helper function that we could use both places?

This revision is now accepted and ready to land.Feb 4 2021, 4:27 PM
rriddle marked 2 inline comments as done.Feb 9 2021, 12:48 AM
rriddle added inline comments.
mlir/include/mlir/IR/OperationSupport.h
330–332

Yes, it's important for ensuring that interface lookups get optimized properly. In most cases, this function gets inlined.

This revision was landed with ongoing or failed builds.Feb 23 2021, 2:37 PM
This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.