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

Fabian Mora llvmlistbot at llvm.org
Mon Jul 15 16:03:17 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);
----------------
fabianmcg wrote:

This function assumes that in a parallel context all functions trying to modify the context call this function. If that happens, then deadlocks are avoidable, as the function can be invoked recursively without creating a deadlock and this function would serialize the execution of the potentially dangerous section -assuming all acquired locks are scoped and no coroutine-like behavior is present.

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


More information about the Mlir-commits mailing list