[LLVMdev] IR code generation and JIT execution in a multithread environment
Edgar Geisler
e.ge at gmx.net
Tue Jan 13 10:39:02 PST 2009
Hi Gordon,
> Module and Value are unsafe for concurrent access--even disjoint
> instances thereof. So you'll need to hold a global mutex while
> loading, building, or transforming IR.
>From my (limited) point of view it would be nice to have some
fine grained lock mechanisms for IR/JIT generation. AFAIK the
critical sections during IR (Module) generation are the alteration
or access to the static/global Type-/ValueMaps. Wouldn't it be
sufficient to protect them by some kind of 'null'-mutex and leaving the
implemtation to the particular project?
> I think serializing code generation in a JIT will usually be adequate,
> since presumably the compiled program (rather than the compiler)
> should dominate runtime. However, if your project truly needs
> concurrent JIT compilation, LLVM doesn't yet meet your needs.
I am using LLVM as a kind of glue between a controlling process (exe) and
some services (lib). Within my mentioned scenario IR/JIT generation
dominates
runtime with an average factor of 5-10. Simply speaking, executing a
service needs ~ 10 ms while IR/JIT generation for this service needs
~ 40 - 100 ms on the average. So, if the controller gets a bulk
of service requests, it can be expected that the requests will be lined up
at a global Module generator or at the global JIT generator mutex.
Edgar
More information about the llvm-dev
mailing list