- To: gcc-help@xxxxxxxxxxx
- Subject: Re: How to guarantee memory access orthogonality without atomics?
- From: Leonard Plentz <veiokej@xxxxxxxxx>
- Date: Fri, 27 Apr 2012 16:23:39 +0700
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <4F9A60F3.1050507@redhat.com>
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@xxxxxxxxxx> 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.
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]