[Mlir-commits] [mlir] [mlir] Add `MLIRContext::executeCriticalSection` and `Pass::getOpDependentDialects` methods. (PR #98953)

Mehdi Amini llvmlistbot at llvm.org
Mon Jul 15 14:46:56 PDT 2024


================
@@ -240,6 +240,10 @@ class MLIRContext {
   /// (attributes, operations, types, etc.).
   llvm::hash_code getRegistryHash();
 
+  /// Execute a critical section guarded by the context. This method guarantees
+  /// that calling `function` is thread-safe with respect to the context.
+  void executeCriticalSection(function_ref<void()> function);
----------------
joker-eph wrote:

I have two questions: 
1) Why is this useful?
2) How do we guarantee that it will work in general?
 - We can split the context thread safety over multiple mutexes
 - this function could call other functions that transitively try to acquire again some locks in the context.

https://github.com/llvm/llvm-project/pull/98953


More information about the Mlir-commits mailing list