This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Adjusting DimLevelType numeric values for faster predicates

Authored by wrengr on Sep 30 2022, 6:08 PM.



This differential adjusts the numeric values for DimLevelType values: using the low-order two bits for recording the "No" and "Nu" properties, and the high-order bits for the formats per se. (The choice of encoding may seem a bit peculiar, since the bits are mapped to negative properties rather than positive properties. But this was done in order to preserve the collation order of DimLevelType values. If we don't care about collation order, then we may prefer to flip the semantics of the property bits, so that they're less surprising to readers.)

Using distinguished bits for the properties and formats enables faster implementation for the predicates detecting those properties/formats, which matters because this is in the runtime library itself (rather than on the codegen side of things). This differential pushes through the changes to the enum values, and optimizes the basic predicates. However it does not optimize all the places where we check compound predicates (e.g., "is compressed or singleton"), to help reduce rebasing conflict with D134933. Those optimizations will be done after this differential and D134933 are landed.

Diff Detail

Event Timeline

wrengr created this revision.Sep 30 2022, 6:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2022, 6:08 PM
wrengr requested review of this revision.Sep 30 2022, 6:08 PM
wrengr updated this revision to Diff 465093.Oct 4 2022, 11:24 AM

incorporated the fix from D135034

aartbik accepted this revision.Oct 5 2022, 1:06 PM
This revision is now accepted and ready to land.Oct 5 2022, 1:06 PM
wrengr updated this revision to Diff 465573.Oct 5 2022, 3:16 PM


wrengr updated this revision to Diff 465595.Oct 5 2022, 4:23 PM

Fixing mlir/test/CAPI/sparse_tensor.c

wrengr updated this revision to Diff 465611.Oct 5 2022, 5:20 PM

Rebasing (to hopefully fix the unrelated Flang build errors)