public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "qinzhao at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/97309] New: Improve documentation of -fallow-store-data-races
Date: Tue, 06 Oct 2020 18:54:03 +0000	[thread overview]
Message-ID: <bug-97309-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97309

            Bug ID: 97309
           Summary: Improve documentation of -fallow-store-data-races
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
  Target Milestone: ---

As of GCC 10, the former --param allow-store-data-races is now 
-fallow-store-data-races.  The default, in both cases, is not to allow them.   

For releases prior to GCC 10, the --param is documented as 

           allow-store-data-races 
               Allow optimizers to introduce new data races on stores.  Set 
to 1 to allow, otherwise to 0. 

The description for GCC 10 is simply: 

       -fallow-store-data-races 
           Allow the compiler to introduce new data races on stores. 
           Enabled at level -Ofast. 

There are three problems with this description. 

(1) The explanation is sparse - basically it just repeats the name of the 
switch.   

(2) It provides no context to explain the circumstances under which it may or 
may not be safe to use. 

(3) Because of the lack of clarity regarding safety, it may be questionable 
as to whether a SPEC CPU user is allowed to use -Ofast 
(http://www.spec.org/cpu2017/Docs/runrules.html#safe) 

Suggested improvement: 

Allow the compiler to perform optimizations that may introduce new data races 
on stores, without proving that the variable cannot be concurrently accessed 
by other threads. Does not affect optimization of local data. It is safe to 
use this option if it is known that global data will not be accessed by 
multiple threads. 

Examples of optimizations enabled by -fallow-store-data-races include 
hoisting or if-conversions that may cause a value that was already in memory 
to be re-written with that same value. Such re-writing is safe in a single 
threaded context but may be unsafe in a multi-threaded context. Note that on 
some processors, if-conversions may be  required in order to enable 
vectorization.

             reply	other threads:[~2020-10-06 18:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 18:54 qinzhao at gcc dot gnu.org [this message]
2020-10-06 20:39 ` [Bug other/97309] " qinzhao at gcc dot gnu.org
2020-10-08 15:01 ` cvs-commit at gcc dot gnu.org
2020-10-08 15:03 ` qinzhao at gcc dot gnu.org
2022-05-12  8:55 ` redi at gcc dot gnu.org
2022-05-12  8:58 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97309-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).