[LLVMdev] LLVM multithreading

Jasmin Jahic jasmin.jahic at gmail.com
Fri May 30 06:28:33 PDT 2014


Hello,

thank you for your answers. I'll explain my problem with giving you a
concrete details.

I have a MAIN program which includes LLVM libraries and loads one bc
file. From MAIN I execute different functions from the bc file using LLVM
interpreter.  On the LLVM website it is said:
"LLVMContext is an opaque class in the LLVM API which clients can use to
operate multiple, isolated instances of LLVM concurrently within the same
address space." - It seems that this is not correct or I'm not
understanding it properly.

One context is used to create two modules, and based on modules all other
things needed for the execution (engine builders, execution engines,
functions). When functions are executed (sequentially), they are obviously
executed in different memory space. I have verified this over access to the
global variable.

However, if functions are executed using the same execution engine
(context, module and execution builder the same), then they are executed in
the same memory space. But using one execution engine is not suitable for
threads, because one execution engine means one stack.

One option is to use different stack frames. Before trying that, I just
wanted to ask is there a different way for sharing memory space between
more execution engines?

Best regards,
Jasmin JAHIC


On Fri, May 30, 2014 at 12:28 PM, Renato Golin <renato.golin at linaro.org>
wrote:

> On 30 May 2014 11:01, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:
> > I think your question is a result of misunderstanding the nature of
> LLVM.  It is not a virtual machine, it is an abstract machine and a set of
> tools implementing compilers for that abstract machine.  You don't run the
> bitcode (well, you can interpret it, but you don't usually), you compile
> the bitcode and then run the resulting code.  If you want to run the same
> code on all threads, then you just use the LLVM [MC]JIT to compile it once
> and then you call the generated functions from different threads.
>
> Try VMKit:
>
> http://vmkit.llvm.org/
>
> They may have answered your question already.
>
> --renato
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140530/9dc3cf1e/attachment.html>


More information about the llvm-dev mailing list