This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] optimize COO index handling
ClosedPublic

Authored by aartbik on Apr 26 2022, 9:32 PM.

Details

Summary

By using a shared index pool, we reduce the footprint of each "Element"
in the COO scheme and, in addition, reduce the overhead of allocating
indices (trading many allocations of vectors for allocations in a single
vector only). When the capacity is known, this means *all* allocation
can be done in advance.

This is a big win. For example, reading matrix SK-2005, with dimensions
50,636,154 x 50,636,154 and 1,949,412,601 nonzero elements improves
as follows (time in ms), or about 3.5x faster overall

SK-2005 before        after      speedup
  ---------------------------------------------
read     305,086.65    180,318.12    1.69
sort   2,836,096.23    510,492.87    5.56
pack     364,485.67    312,009.96    1.17
  ---------------------------------------------
TOTAL  3,505,668.56  1,002,820.95    3.50

Diff Detail

Event Timeline

aartbik created this revision.Apr 26 2022, 9:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 9:32 PM
aartbik requested review of this revision.Apr 26 2022, 9:32 PM
aartbik edited the summary of this revision. (Show Details)Apr 26 2022, 9:34 PM
aartbik edited the summary of this revision. (Show Details)
aartbik edited the summary of this revision. (Show Details)
aartbik updated this revision to Diff 425414.Apr 26 2022, 9:39 PM

removed old code

bixia accepted this revision.Apr 27 2022, 9:51 AM
bixia added inline comments.
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
93

Nice change! Can we document this design decision here, using a pointer not a vector?

This revision is now accepted and ready to land.Apr 27 2022, 9:51 AM
aartbik marked an inline comment as done.Apr 27 2022, 10:09 AM
aartbik added inline comments.
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
93

Good idea. I added a note to the struct doc.

aartbik updated this revision to Diff 425554.Apr 27 2022, 10:15 AM
aartbik marked an inline comment as done.

added note on change to struct

This revision was landed with ongoing or failed builds.Apr 27 2022, 10:21 AM
This revision was automatically updated to reflect the committed changes.