This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Using non-empty function name suffix for OverheadType::kIndex
ClosedPublic

Authored by wrengr on May 31 2022, 3:04 PM.

Details

Summary

The trick of using an empty token in the FOREVERY_O x-macro relies on preprocessor behavior which is only standard since C99 6.10.3/4 and C++11 N3290 16.3/4 (whereas it was undefined behavior up through C++03 16.3/10). Since the ExecutionEngine/SparseTensorUtils.cpp file is required to be compile-able under C++98 compatibility mode (unlike the C++11 used elsewhere in MLIR), we shouldn't rely on that behavior.

Also, using a non-empty suffix helps improve uniformity of the API, since all other primary/overhead suffixes are also non-empty. I'm using the suffix 0 since that's the value used by the SparseTensorEncoding attribute for indicating the index overhead-type.

Depends On D126720

Diff Detail

Event Timeline

wrengr created this revision.May 31 2022, 3:04 PM
wrengr requested review of this revision.May 31 2022, 3:04 PM

Actually, come to think of it, maybe using 0 wouldn't be so bad afterall— since that's the value used by the SparseTensorEncodingAttr attribute to indicate the index type for $pointerBitWidth and $indexBitWidth. Yes, I think I'll change it to that.

wrengr edited the summary of this revision. (Show Details)May 31 2022, 3:22 PM
wrengr updated this revision to Diff 433208.May 31 2022, 3:27 PM

Using suffix 0 instead of X.

aartbik accepted this revision.Jun 1 2022, 2:15 PM
This revision is now accepted and ready to land.Jun 1 2022, 2:15 PM