This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Caching globals in registers
- From: Jakub Jelinek <jakub at redhat dot com>
- To: jacob navia <jacob at jacob dot remcomp dot fr>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 5 Nov 2017 20:43:35 +0100
- Subject: Re: Caching globals in registers
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 14FE585546
- References: <f0c84c0d-fa81-af9d-35b0-c5e2ebe052d8@jacob.remcomp.fr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sun, Nov 05, 2017 at 08:30:01PM +0100, jacob navia wrote:
> Suppose (one of the multiple scenarios) that you store in a set of memory
> locations data like wind speed, temperature, etc. Only the thread that
> updates that table acquires a lock. All others access the data without any
> locks in read mode.
>
> A program generated with this optimizations reads it once. That's a bug...
A bug in the program that does that. You can use volatile, or atomics
(including e.g. relaxed __atomic_load, which isn't really expensive).
Jakub