How to guarantee memory access orthogonality without atomics?

Leonard Plentz veiokej@gmail.com
Fri Apr 27 09:23:00 GMT 2012


Thank you for commenting! So let me understand you:

X is 4 bytes wide. It's based at address 27. Y is also 4 bytes wide.
It's based at address 31. Cache lines happen to be 32 bytes long.
Processor 0 can write to X any time, and processor 1 can write to Y
anytime. Writing to Y causes an implicit read-modify-write to the line
containing X. But this doesn't matter because it's assumed under
C99/C11 that the processor will enforce the orthogonality of X and Y,
provided that their sizes are at least a multiple of whole bytes based
at whole-byte boundaries.

Is that correct?

"You can't have a data race if the threads don't access the same
objects." -- If you or anyone else has a spec subsection you can cite
for this, that would be most helpful. This is, in fact, the guarantee
I'm seeking, to the extent that objects and base addresses are
byte-granular.

On Fri, Apr 27, 2012 at 4:03 PM, Andrew Haley <aph@redhat.com> wrote:

>
> I don't think it could.  You can't have a data race if the threads
> don't access the same objects.  The only way you'd be be able to
> implement C on a machine like this would be to allocate objects so
> that they didn't share cache lines.
>
> Andrew.



More information about the Gcc-help mailing list