[Mlir-commits] [mlir] [MLIR][Python] Remove partial LLVM APIs in python bindings (6/6) (PR #180986)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Feb 11 20:54:14 PST 2026


================
@@ -440,13 +441,20 @@ void PyOpOperandIterator::bind(nb::module_ &m) {
 // PyThreadPool
 //------------------------------------------------------------------------------
 
-PyThreadPool::PyThreadPool() {
-  ownedThreadPool = std::make_unique<llvm::DefaultThreadPool>();
+PyThreadPool::PyThreadPool() { threadPool = mlirLlvmThreadPoolCreate(); }
+
+PyThreadPool::~PyThreadPool() {
+  if (threadPool.ptr)
+    mlirLlvmThreadPoolDestroy(threadPool);
+}
+
+int PyThreadPool::getMaxConcurrency() const {
+  return mlirLlvmThreadPoolGetMaxConcurrency(threadPool);
 }
 
 std::string PyThreadPool::_mlir_thread_pool_ptr() const {
   std::stringstream ss;
-  ss << ownedThreadPool.get();
+  ss << threadPool.ptr;
----------------
RattataKing wrote:

no, because `threadPool.ptr` returns same address as `unwrap(threadPool)`, unwrap would just cast threadPool void * to the `llvm::ThreadPoolInterface *` to, see [here](https://github.com/llvm/llvm-project/blob/e2ac2e0af6f4778ad3724f28105d4d3d029ea9f5/mlir/include/mlir/CAPI/Wrap.h#L25-L29)

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


More information about the Mlir-commits mailing list