[Haskell-cafe] Can you do everything without shared-memory concurrency?

Richard A. O'Keefe ok at cs.otago.ac.nz
Mon Sep 8 22:34:03 EDT 2008


On 9 Sep 2008, at 8:15 am, Kyle Consalus wrote:

> Anyway, for the time being I believe there are operations that can be
> done with shared memory
> that can't be done with message passing if we make "good performance"
> a requirement.

One of our people here has been working on Distributed Shared Memory
for some years.  It's a programming model where you write AS IF you
had shared memory, but you really don't.  He actually uses plain C
with a library, but I've got a student project to wrap some syntax
around that.

	typedef struct Foo { ... variables ... } Foo;
	typedef struct Bar { ... variables ... } Bar;
	shared Foo foo;
	shared Bar bar;

	shared (const *f = &foo) {
	    ... here we have read access to f->variables ...
	}
	shared (*b = &bar) {
	    ... here we have read-write access to b->variables ...
	}

Underneath, it's message passing.  When you get a view on a
shared region, a copy is fetched from the cheapest source that has
a current copy.  When you release a write view, you become the
holder of the only current copy.  Compressed differences are
sent around the local net.  Zhiyi Huang's library is called VODCA.
There's a plug-compatible version developed by his colleagues in
China called Maotai, so the _same_ code can be run on a multicore
system or on a network of workstations.  The trick is to choose the
chunk size of your problem so that computation and communication
costs are in the right balance.  This certainly seems to be adequate
for numerical software, raytracing, game playing, ...

One issue is that real shared memory comes at a price that most
people don't know they are paying.  We wouldn't need MOESI
protocols or the related bus traffic if there were known to be
no sharing, and one of the things that gets in the way of
massive multicore is keeping caches coherent.  No shared memory
=> no coherence problem => no extra bus traffic => faster.

--
If stupidity were a crime, who'd 'scape hanging?









More information about the Haskell-Cafe mailing list