[Mlir-commits] [mlir] Added PyThreadPool as wrapper around MlirLlvmThreadPool in MLIR python bindings (PR #130109)

Mehdi Amini llvmlistbot at llvm.org
Thu Mar 6 11:26:06 PST 2025


================
@@ -47,3 +47,17 @@
 assert '"mlir.ir.Context._CAPIPtr"' in repr(c4_capsule)
 c5 = mlir.ir.Context._CAPICreate(c4_capsule)
 assert c4 is c5
+c4 = None
+c5 = None
+gc.collect()
+
+# Create a global threadpool and use it in two contexts
+tp = mlir.ir.ThreadPool()
+assert tp.get_max_concurrency() > 0
+c5 = mlir.ir.Context()
+c5.enable_multithreading(False)
----------------
joker-eph wrote:

That's what I feared, then we need to defend against it in the Python API. That is we shouldn't crash and instead either throw an exception when the user didn't disable multi-threading first, or do it for the user implicitly in the call to `set_thread_pool()`

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


More information about the Mlir-commits mailing list