[cpp-threads] Dependency-based ordering

Boehm, Hans hans.boehm at hp.com
Wed Jun 20 22:58:55 BST 2007


Paul -

Doug and I were discussing another possible approach to dealing with
dependency-based ordering at FCRC.  This approach seems cleaner to us.
But there may be some danger that we cleaned it up to the point of being
less useful in the process.

Here's a version with placeholder syntax that clearly needs a lot of
work.  But I think the syntax is secondary.

We would write something like:

with_load_dependent_acquire r1 = x {
	// Any memory references in this block that depend on r1 are
ordered with respect to the original load of x
      y = *r1;	// ordered
	y = *x;  	// not ordered; not dependent on r1
	r2 = r1;
}
// Any memory references after the block are no longer ordered with
respect to the load of x, whether dependent or not.
Y = *r2;	// Not ordered; out of scope

On something like PowerPC, this would compile as:

1) If the compiler can see all memory references in the block that might
be dependent on r1, it would preserve those dependencies and use no
fences.

2) If the block contains non-inlined function calls that might perform
memory operations dependent on r1, it would be compiled as a
load_acquire (as it would be on X86, etc.)

This seems to have the big advantage that it might often be useful
without further annotations.  Since it applies only in a specific scope,
we don't need to worry about dependent memory references later in the
program.

What do you think?

Hans



More information about the cpp-threads mailing list