llvm can be safely used from multiple threads, it is only challenging to
use because (as Keno pointed out) you need to synchronize the Julia side,
meaning care needs to be taken to compile a function exactly once, and not
attempt to run it until it is finished being compiled.

We need to switch cfunction to generating custom wrappers at some point
anyways, for other reasons, so it is largely irrelevant to the internal
implementation how the external-facing implemention handles function call
entry.


On Friday, August 1, 2014, Keno Fischer <[email protected]>
wrote:

> Yes, that's correct. TLS can be implemented pretty efficiently with a
> small bit of care. Regarding LLVM, it is technically possible to have
> multiple independent instances of LLVM in one thread. The reason that
> wasn't an option for the multithreaded case is that those instances
> can't share any code so it wouldn't be useful.
>
> On Fri, Aug 1, 2014 at 2:17 PM, Stefan Karpinski <[email protected]
> <javascript:;>> wrote:
> > On Fri, Aug 1, 2014 at 9:11 AM, Jameson Nash <[email protected]
> <javascript:;>> wrote:
> >>
> >> There isn't much benefit to running multiple julia instances from one
> >> binary, since Julia uses many c libraries, and these have generally not
> been
> >> written with this in mind.
> >
> >
> > Yes, also a problem, although threads may raise similar issues.
> >
> >>
> >> It might be faster to internally pass around pointer to the TLS in a
> >> register, since many functions need to access the GC-frame, so we might
> >> still want to do that for a different reason. But the external
> interface can
> >> just pull that information out of TLS, and maintaining thread-local
> state is
> >> not the same as having independent instances in one process.
> >
> >
> > My understanding – and Keno can probably correct me if I'm wrong here –
> is
> > that the fast way of doing TLS basically does just store it in a
> register.
> > However, there may be situations where Julia is called in a way that it
> > can't use the fast TLS mechanism (e.g. when libjulia is loaded as a
> shared
> > library), in which case avoiding slow TLS lookups wherever possible would
> > help in those cases.
>

Reply via email to