This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
- From: Andi Kleen <andi at firstfloor dot org>
- To: Tomash Brechko <tomash dot brechko at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 29 Oct 2007 12:54:22 +0100
- Subject: Re: Optimization of conditional access to globals: thread-unsafe?
- References: <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <472492F8.email@example.com> <20071028141821.GA4898@moonlight.home.suse.lists.egcs>
Tomash Brechko <firstname.lastname@example.org> writes:
> - optimization in question might well turn out to be misoptimization
> for anything but microbenchmarks (read LKML for cache flush/dirty
> page issues).
See http://gcc.gnu.org/ml/gcc/2007-10/msg00607.html for a test case
that shows where it can go horrible wrong (optimized code significantly
slower than unoptimized code) Admittedly it is a constructed
one, but I don't think it is that unrealistic.
> - there's also a good talk on lawyer-ish vs attached-to-reality
> approach. I personally doubt those who continue to advise to use
> volatile are actually writing such multithreaded programs. Most
> argue just for the fun of it.
Also they don't volunteer to audit multi-million LOC code bases to add
volatile everywhere. That has to be always taken into account. For
the compiler it is a relatively simple localized change and then the
computer does all the work. For the compiled programs
auditing/changing this would be a huge effort done by humans.