[LLVMdev] Proposal for a new LLVM concurrency memory model

David Greene dag at cray.com
Tue Apr 27 09:28:56 PDT 2010


On Tuesday 27 April 2010 11:01:16 Renato Golin wrote:
> On 27 April 2010 16:46, David Greene <dag at cray.com> wrote:
> > It shouldn't be very hard for the compiler to detect the second case.
> > It's a pretty straightforward pattern.  For everything else it would
> > have to assume case #1.
>
> The only problem is that threads are rarely within language specs, so
> the compiler would have to choose one particular flavour of threads or
> "find out" what flavour is being used. That would require the compiler
> to know all / implement all types, which are not only time consuming
> and error prone, but not the compiler's job in the first place.

The compiler has to know the threading model.  There's no way around
that.  gcc has the -pthread switch, for example.

The compiler integrates into a comprehensive programming environment.
It has to know what the environment provides and uses.  That _is_ very much 
the compiler's responsibility.

That's why target-independent code is so hard to write.  :)

Again, my vote is to define vector atomics as respecting atomicity across
elements and make it the compiler's and user's job to know when it can use 
them.

                          -Dave





More information about the llvm-dev mailing list