[llvm-dev] Do I have to lock ThreadSafeContext and ThreadSafeModule in single threaded env?
mo xiaoming via llvm-dev
llvm-dev at lists.llvm.org
Wed Jul 7 07:13:09 PDT 2021
Hi all,
I’m new to JIT and just started experiencing on some example code with ORCv2, but could not get my head around with the thread safety.
Scenario 1, Application has multiple threads and each thread spawns its own JIT instance, within each JIT instance, there are multiple ThreadSafeModules share one ThreadSafeContext
Do I have to lock TSM/ TSC?
Scenario 2, If JIT itself has multiple compilation threads, like via setting NumCompileThreads in LLJIT classes, and each ThreadSafeModule has its own ThreadSafeContext, so context is not shared
In this case, do I have to lock? If so, what’s the granularity of each lock should be, anything before IR generation in one locking?
I think in scenario 1, locking is not needed because of no concurrent access. And I believe locking is a mandatory in scenario 2, but I don’t know why...
More information about the llvm-dev
mailing list