From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16313 invoked by alias); 18 Dec 2013 14:23:20 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 16298 invoked by uid 89); 18 Dec 2013 14:23:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: relay5-d.mail.gandi.net Received: from relay5-d.mail.gandi.net (HELO relay5-d.mail.gandi.net) (217.70.183.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 18 Dec 2013 14:23:18 +0000 Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 2B00D41C075 for ; Wed, 18 Dec 2013 15:23:15 +0100 (CET) Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id ad2r+Eb4Vj7c for ; Wed, 18 Dec 2013 15:23:13 +0100 (CET) Received: from yoga.dhardy (unknown [157.161.131.62]) (Authenticated sender: digben@dhardy.name) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 747A141C07F for ; Wed, 18 Dec 2013 15:23:13 +0100 (CET) From: Diggory Hardy To: gcc-help@gcc.gnu.org Subject: optimisation -O1 changes floating-point results Date: Wed, 18 Dec 2013 14:23:00 -0000 Message-ID: <2630496.spIoGH9TqC@yoga.dhardy> User-Agent: KMail/4.11.3 (Linux/3.12.3-1.fc21.x86_64; KDE/4.11.3; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-SW-Source: 2013-12/txt/msg00125.txt.bz2 Dear list, I am using GCC to compile some modeling software (C++; http://code.google.com/p/openmalaria/). This uses quite a lot of "double"s and results can be quite sensitive to the exact outcomes of floating-point operations (this is due to stochastic influences, and only really a concern since we want to be able to reproduce results independent of the hardware/OS used). Anyway, on 32-bit Linux (Ubuntu 12.04 with the default GCC 4.6.3) some of my test cases generated different results when optimisation is enabled. (This doesn't happen on 64-bit Linux (identical Ubuntu/GCC versions) or our Windows or Mac builds.) On 32-bit linux results are as expected with no optimisation, but different when -O1 (or 2 or 3) is used, _however_, enabling all of the same optimisation flags (either as listed in the man page or as given by `gcc -O -Q -- help=optimizers`) (without listing -O) still produces different results. Is this a known issue? Is it the same with later GCC versions? Is there a way I can turn on most optimisations while still getting exactly the same results as without optimisation? Cheers, Diggory Hardy