[all-commits] [llvm/llvm-project] e4e31e: [mlir][OpGen] Cache Identifiers for known attribut...
River Riddle via All-commits
all-commits at lists.llvm.org
Tue Jun 22 12:57:05 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e4e31e19bb87d154a2da1f5479f778c13a120b3c
https://github.com/llvm/llvm-project/commit/e4e31e19bb87d154a2da1f5479f778c13a120b3c
Author: River Riddle <riddleriver at gmail.com>
Date: 2021-06-22 (Tue, 22 Jun 2021)
Changed paths:
M mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
M mlir/include/mlir/Dialect/MemRef/IR/MemRef.h
M mlir/include/mlir/IR/OperationSupport.h
M mlir/lib/IR/MLIRContext.cpp
M mlir/lib/TableGen/OpClass.cpp
M mlir/test/mlir-tblgen/op-attribute.td
M mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
M mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp
Log Message:
-----------
[mlir][OpGen] Cache Identifiers for known attribute names in AbstractOperation.
Operations currently rely on the string name of attributes during attribute lookup/removal/replacement, in build methods, and more. This unfortunately means that some of the most used APIs in MLIR require string comparisons, additional hashing(+mutex locking) to construct Identifiers, and more. This revision remedies this by caching identifiers for all of the attributes of the operation in its corresponding AbstractOperation. Just updating the autogenerated usages brings up to a 15% reduction in compile time, greatly reducing the cost of interacting with the attributes of an operation. This number can grow even higher as we use these methods in handwritten C++ code.
Methods for accessing these cached identifiers are exposed via `<attr-name>AttrName` methods on the derived operation class. Moving forward, users should generally use these methods over raw strings when an attribute name is necessary.
Differential Revision: https://reviews.llvm.org/D104167
Commit: 87e59e47e936f15e407dba1b963393dd96ff96fb
https://github.com/llvm/llvm-project/commit/87e59e47e936f15e407dba1b963393dd96ff96fb
Author: River Riddle <riddleriver at gmail.com>
Date: 2021-06-22 (Tue, 22 Jun 2021)
Changed paths:
M mlir/lib/IR/MLIRContext.cpp
Log Message:
-----------
[mlir] Remove the Identifier ThreadLocalCache from MLIRContext
This used to be important for reducing lock contention when accessing identifiers, but
the cost of the cache can be quite large if parsing in a multi-threaded context. After
D104167, the win of keeping a cache is not worth the cost.
Differential Revision: https://reviews.llvm.org/D104737
Compare: https://github.com/llvm/llvm-project/compare/5bcbc7ee526c...87e59e47e936
More information about the All-commits
mailing list