[LLVMdev] LLVM and coroutines/microthreads
OvermindDL1
overminddl1 at gmail.com
Sun Apr 19 02:40:11 PDT 2009
On Thu, Apr 16, 2009 at 2:44 PM, Jonathan D. Turner
<jonathan.d.turner at gmail.com> wrote:
> It looks like the article is suggesting that you're keep a pointer and
> do a bunch of derefs on it in all cases. It just sounds inefficient,
> unless I'm missing something.
It is just treating it identically to how the real system stack is
treated. As stated, most of the code will still keep it in registers
and so forth since the front-end outputs the SSA form directly.
On Thu, Apr 16, 2009 at 2:44 PM, Jonathan D. Turner
<jonathan.d.turner at gmail.com> wrote:
> Looks like pretty much all the options are going to require
> bookkeeping, hackery, or both. Even my stack copying suggestion has
> restrictions on stack size.
My method has no restriction, and I do have a decorator keyword for
the actor function that always causes a new stack to be created at
that point as well (good for if a function may use a lot of stack
space, but be called rarely, like an alloca'd known-size array). The
only real limit is system memory.
On Thu, Apr 16, 2009 at 2:44 PM, Jonathan D. Turner
<jonathan.d.turner at gmail.com> wrote:
> That's a handy idea. This technique reminds me of Orc, if you haven't
> seen it you should check it out: http://orc.csres.utexas.edu/
I had not, thanks for the link, will look it over shortly.
On Thu, Apr 16, 2009 at 2:44 PM, Jonathan D. Turner
<jonathan.d.turner at gmail.com> wrote:
> Funny you should mention this. I've spent the better part of the last
> few weeks trying to get a CAS solution to be rock-solid. Then, it
> turns out I could make a locky solution that performed similarly to
> the CAS solution by using tiny (2-3 instructions) locked areas. If
> you look through Art of Multiprocessor Programming, you'll see that a
> lot of the solutions use multiple CAS's per action. As best I can
> tell, if you CAS more than twice per task, you're starting to get into
> the area of tiny locks performance-wise (at least on Intel platforms).
The only places that such things are ever needed is when something is
pushed onto a queue. In this pattern no memory is nor can be aliased
by any other Actor, so things stay very self-contained, so the only
synchronization necessary is when pushing something onto a list, which
should require only one atomic CAS. I have not yet ran into anything
that needed more (although it is possible, the language is no where
near finished yet, need some free time again for that)
On Thu, Apr 16, 2009 at 2:44 PM, Jonathan D. Turner
<jonathan.d.turner at gmail.com> wrote:> >From what you're telling me, as
far as LLVM is concerned there are
> ways to do it manually, you just have to pick one that suits the
> project. There aren't any automatic solutions, nor hooks to attach
> your own. I admit, I assumed that might be the case since there isn't
> any "standard" coroutine style.
The one thing I do wish so much is if you could specify your own
pre-allocated memory for the alloca instructions, then the passes that
raise alloca's to SSA and so forth would just work fine.
More information about the llvm-dev
mailing list