public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ruslan Nikolaev via gcc" <gcc@gcc.gnu.org>
To: Torvald Riegel <triegel@redhat.com>
Cc: Alexander Monakov <amonakov@ispras.ru>,
		Szabolcs Nagy <szabolcs.nagy@arm.com>,
		"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>, "nd@arm.com" <nd@arm.com>
Subject: Re: GCC interpretation of C11 atomics (DR 459)
Date: Mon, 26 Feb 2018 18:59:00 -0000	[thread overview]
Message-ID: <1738288554.4867171.1519671329114@mail.yahoo.com> (raw)
In-Reply-To: <1519670138.15077.663.camel@redhat.com>

Torvald, thank you for your output. See my response below. 

    On Monday, February 26, 2018 1:35 PM, Torvald Riegel <triegel@redhat.com> wrote:

> ... does not imply this latter statement.  The statement you cited is
> about what the standard itself requires, not what makes sense for a
> particular implementation. 

True but makes sense to provide true atomics when they are available. Since the standard seem to allow atomic_load implementation using RMW, does not seem to be a problem.
In fact, lock_free flag for this type can return true only if mcx16 is specified; otherwise -- it returns false (since it can only be determined during runtime, assuming worst case scenario)

> So, in such a case, using the wide CAS for
> atomic loads breaks a reasonable assumption.  Moreover, it's also a
> special case, in that 32b atomics do work as intended.

But in this case a programmer already makes an assumption that atomic_load does not use RMW which C11 does not seem to guarantee.Of course, for single-width operations, the programmer may in most practical cases assume it (even though there is no guarantee).
Anyway, there is no good solution here for double-width operations, and the programmer should not assume it is possible when writing portable code.In fact, lock-based solution is even more confusing and potentially error-prone (e.g., cannot be safely used inside signal handlers since it is not lock-free, etc)

> The behavior you favor would violate that, and
> there's no portable way to distinguish one from the other. 

There is already a similar problem with IFFUNC (when used with Linux and glibc). In fact, I do not see any difference here. Redirection to libatomic when mcx16 is specified just adds extra cost + less predictable behavior. Moreover, it seems counterintuitive -- I specify a flag that mcx16 is supported but gcc still does not use it (at least directly). It is possible to make a change to libatomic to always use cmpxchg16b when available (even on systems without IFFUNC), this way it is totally consistent and binary compatible for code compiled with and without mcx16.


> I see your point in wanting to have a builtin or such for the 64b atomic
> CAS.  However, IMO, this doesn't fit into the world of C11/C++11
> atomics, and thus rather should be accessible through a separate
> interface.
Why not? If atomic_load is not really an issue, then it may be good to use standardized interface.




   

  reply	other threads:[~2018-02-26 18:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1615980330.4453149.1519617655582.ref@mail.yahoo.com>
2018-02-26  4:01 ` Ruslan Nikolaev via gcc
2018-02-26  5:50   ` Alexander Monakov
2018-02-26  7:24     ` Fw: " Ruslan Nikolaev via gcc
2018-02-26  8:20       ` Alexander Monakov
2018-02-26  8:43         ` Ruslan Nikolaev via gcc
2018-02-26 19:07       ` Torvald Riegel
2018-02-26 19:43         ` Ruslan Nikolaev via gcc
2018-02-26 22:49           ` Ruslan Nikolaev via gcc
2018-02-27  3:33             ` Ruslan Nikolaev via gcc
2018-02-27 10:34             ` Ramana Radhakrishnan
2018-02-27 11:14               ` Torvald Riegel
2018-02-27 12:39             ` Torvald Riegel
2018-02-27 13:04               ` Ruslan Nikolaev via gcc
2018-02-27 13:08                 ` Szabolcs Nagy
2018-02-27 13:17                   ` Ruslan Nikolaev via gcc
2018-02-27 16:40                     ` Torvald Riegel
2018-02-27 17:07                       ` Ruslan Nikolaev via gcc
2018-02-27 16:21                   ` Torvald Riegel
2018-02-27 16:16                 ` Torvald Riegel
2018-02-27 16:46                 ` Simon Wright
2018-02-27 16:52                   ` Florian Weimer
2018-02-27 17:30                   ` Torvald Riegel
2018-02-27 17:33                     ` Ruslan Nikolaev via gcc
2018-02-27 19:32                       ` Torvald Riegel
2018-02-27 17:59                     ` Simon Wright
2018-02-27 10:40           ` Fw: " Torvald Riegel
2018-02-26 18:56     ` Torvald Riegel
2018-02-26 12:30   ` Szabolcs Nagy
2018-02-26 13:57     ` Alexander Monakov
2018-02-26 14:51       ` Szabolcs Nagy
2018-02-26 14:53       ` Ruslan Nikolaev via gcc
2018-02-26 18:35         ` Torvald Riegel
2018-02-26 18:59           ` Ruslan Nikolaev via gcc [this message]
2018-02-26 19:20             ` Torvald Riegel
2018-02-26 18:16   ` Florian Weimer
2018-02-26 18:34     ` Ruslan Nikolaev via gcc
2018-02-26 18:36     ` Janne Blomqvist
2018-02-27 10:22       ` Florian Weimer
     [not found] <886227277.5611063.1519759959364.ref@mail.yahoo.com>
2018-02-27 20:20 ` Ruslan Nikolaev via gcc
2018-02-27 22:19   ` Torvald Riegel
2018-02-28  1:46     ` Ruslan Nikolaev via gcc

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=1738288554.4867171.1519671329114@mail.yahoo.com \
    --to=gcc@gcc.gnu.org \
    --cc=amonakov@ispras.ru \
    --cc=nd@arm.com \
    --cc=nruslan_devel@yahoo.com \
    --cc=szabolcs.nagy@arm.com \
    --cc=triegel@redhat.com \
    /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).