[Mlir-commits] [mlir] [mlir] Skip uniquer locks when a context starts without threading (PR #235294)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Oct 24 06:28:42 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Arseniy Obolenskiy (aobolensk)
<details>
<summary>Changes</summary>
Only disableMultithreading() turned these locks off before
Context that was created without threading still took a lock on every type and attribute lookup
---
Full diff: https://github.com/llvm/llvm-project/pull/235294.diff
1 Files Affected:
- (modified) mlir/lib/IR/MLIRContext.cpp (+9-4)
``````````diff
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index c5d66c27557c50..350680692a6e0f 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -286,8 +286,16 @@ class MLIRContextImpl {
if (threadingIsEnabled) {
ownedThreadPool = std::make_unique<llvm::DefaultThreadPool>();
threadPool = ownedThreadPool.get();
+ } else {
+ disableUniquerMultithreading(true);
}
}
+ /// Update the threading mode for each of the uniquers.
+ void disableUniquerMultithreading(bool disable) {
+ affineUniquer.disableMultithreading(disable);
+ attributeUniquer.disableMultithreading(disable);
+ typeUniquer.disableMultithreading(disable);
+ }
~MLIRContextImpl() {
for (auto typeMapping : registeredTypes)
typeMapping.second->~AbstractType();
@@ -624,10 +632,7 @@ void MLIRContext::disableMultithreading(bool disable) {
impl->threadingIsEnabled = !disable;
- // Update the threading mode for each of the uniquers.
- impl->affineUniquer.disableMultithreading(disable);
- impl->attributeUniquer.disableMultithreading(disable);
- impl->typeUniquer.disableMultithreading(disable);
+ impl->disableUniquerMultithreading(disable);
// Destroy thread pool (stop all threads) if it is no longer needed, or create
// a new one if multithreading was re-enabled.
``````````
</details>
https://github.com/llvm/llvm-project/pull/235294
More information about the Mlir-commits
mailing list