The context can be created with threading disabled, to avoid creating a thread pool
that may be destroyed when injecting another one later.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Seems good
mlir/lib/IR/MLIRContext.cpp | ||
---|---|---|
595 | This interaction was confusing to me initially, could you add a comment here? May also be good to document that threadPool != nullptr doesn't mean threading is enabled. |
mlir/lib/IR/MLIRContext.cpp | ||
---|---|---|
606 | So, if I want to bring my own thread pool and avoid thrashing things by having the context spin up a bunch of threads just to reset them, is the sequence: llvm::ThreadPool myAwesomeThreadPool; MLIRContext ctx(registry, Threading::disabled); ctx.setThreadPool(myAwesomeThreadPool); ctx.enableMultithreading(); I feel that a slight improvement might be to call ctx.enableMultithreading() from setThreadPool. Also, since the comment says This method requires that multithreading is disabled for this context prior to the call., maybe add an assert() on that here? |
Address comments:
- More docs, in particular include an extended version of Stella's example in the class doc.
- Enable multi-threading when setting an external pool
- Add some asserts around the invariants for threadPool/ownedThreadPool.
We generally capitalize the values of enums .