Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"05-26-09 - Automatic Multithreading"

7 Comments -

1 – 7 of 7
Blogger won3d said...

Pending thread annotations in GCC:

http://docs.google.com/Doc?id=ddqtfwhb_0c49t6zgr

The architecture folks realized pretty early on that transactions and speculation are basically the same thing. I think it is also fairly obvious that you don't need to do a fully hardware implementation of transaction memory, just like you don't need to do a fully hardware implementation of virtual memory.

I like the idea of a processor being able to dynamically choose to speculate or hyperthread, or just save power. It would be interesting to see what the "branch predictor" (or whatever would make that decision) would look like. I wonder if the additional complexity would be worthwhile. I suppose the problem is that to actually do speculation well you also need to go out-of-order, and things quickly get big and messy.

May 26, 2009 at 4:25 PM

Blogger cbloom said...

"The architecture folks realized pretty early on that transactions and speculation are basically the same thing."

Yeah I didn't see it; it's cool.

"I like the idea of a processor being able to dynamically choose to speculate or hyperthread, or just save power."

Apparently Rock can be controlled from software to use both hardware hyperthreads to execute a single software thread. In that case one of the hyperthreads runs ahead and speculatively executes and prefetches stuff, while the other one hangs behind and retires what actually happened.

It's cool to be able to control stuff like that from the OS so you have control over power use, whether you target fewer or more threads, etc.

May 26, 2009 at 4:46 PM

Blogger ryg said...

"Yeah I didn't see it; it's cool."
It's interesting how working on hardware, or even just thinking about how you would specify something if it was meant to be implemented as hardware, changes your perspective.

It changes your focus from "what am I trying to accomplish" to "what am I actually doing", which is very liberating sometimes. I remember reading some time ago about how LLVM used to have signed and unsigned integers as distinct types, which they later switched that to just having integer types with distinct signed/unsigned add, sub and multiply instructions, which apparently solved several design problems for them.

This kind of actually peeling high-level information away where it doesn't contribute anything anymore is just as tricky as getting the high-level info to where you need it.

May 26, 2009 at 6:27 PM

Anonymous Anonymous said...

Does your example of lock avoidance actually work? It seems like the hardware transaction needs to be blocked by the lock; i.e. you don't want to fail a transaction, grab the lock, do part of the locked code, then pause and another thread comes along and runs the transaction code and completes it successfully.

But I may not be understanding it correctly.

May 29, 2009 at 5:58 PM

Blogger cbloom said...

I think the key to that is that the light transaction version still checks a bool in the lock. That does two things - if the bool is set it's locked and you don't do the transaction, but it also makes you dependent on the cache line of the lock, so if anyone else is changing the lock at the same time you fail the transaction.

May 29, 2009 at 6:33 PM

Blogger cbloom said...

So the transaction version is something like :

checkpoint

if ( lock.set )
goto fallback

lock.set = true

.. do stuff ..

lock.set = false

commit
on failure goto fallback

So the commit only goes through when I was the only person who got their hands on the lock during that time.

Or something, I dunno, it's more complicated than that I'm sure.

May 29, 2009 at 6:45 PM

Blogger cbloom said...

and of course to be clear on the context, this isn't a general transaction thing, it's just needed when you're trying to replace locks and/or use locks as the fallback mechanism.

May 29, 2009 at 6:46 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.