From: Michael Matz <matz@suse.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>,
Paul McKenney <paulmck@linux.vnet.ibm.com>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
parallel@lists.isocpp.org, llvm-dev@lists.llvm.org,
Will Deacon <will.deacon@arm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
David Howells <dhowells@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
Luc Maranget <luc.maranget@inria.fr>,
Andrew Morton <akpm@linux-foundation.org>,
Jade Alglave <j.alglave@ucl.ac.uk>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [isocpp-parallel] Proposal for new memory_order_consume definition
Date: Mon, 29 Feb 2016 18:37:02 +0100 (CET) [thread overview]
Message-ID: <alpine.LSU.2.20.1602291825401.20277@wotan.suse.de> (raw)
In-Reply-To: <CA+55aFyauwKmUdxfrKcy5Q2kvdej5fWt6xL+amVyPFhzmHMcsg@mail.gmail.com>
Hi,
On Sun, 28 Feb 2016, Linus Torvalds wrote:
> > So the kernel obviously is already using its own C dialect, that is
> > pretty far from standard C. All these options also have a negative
> > impact on the performance of the generated code.
>
> They really don't.
They do.
> Have you ever seen code that cared about signed integer overflow?
>
> Yeah, getting it right can make the compiler generate an extra ALU
> instruction once in a blue moon, but trust me - you'll never notice.
> You *will* notice when you suddenly have a crash or a security issue
> due to bad code generation, though.
No, that's not at all the important piece of making signed overflow
undefined. The important part is with induction variables controlling
loops:
short i; for (i = start; i < end; i++)
vs.
unsigned short u; for (u = start; u < end; u++)
For the former you're allowed to assume that the loop will terminate, and
that its iteration count is easily computable. For the latter you get
modulo arithmetic and (if start/end are of larger type than u, say 'int')
it might not even terminate at all. That has direct consequences of
vectorizability of such loops (or profitability of such transformation)
and hence quite important performance implications in practice. Not for
the kernel of course. Now we can endlessly debate how (non)practical it
is to write HPC code in C or C++, but there we are.
> The fact is, undefined compiler behavior is never a good idea. Not for
> serious projects.
Perhaps if these undefinednesses wouldn't have been put into the standard,
people wouldn't have written HPC code, and if that were so the world would
be a nicer place sometimes (certainly for the compiler). Alas, it isn't.
Ciao,
Michael.
next prev parent reply other threads:[~2016-02-29 17:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 1:10 Paul E. McKenney
2016-02-20 2:15 ` [isocpp-parallel] " Tony V E
2016-02-20 19:53 ` Paul E. McKenney
[not found] ` <CAPUmR1bw=N4NkjAK1zn_X0+84KEaEAM6HZCHZJy_txqC9hMgSg@mail.gmail.com>
2016-02-26 23:56 ` Lawrence Crowl
2016-02-27 17:06 ` Paul E. McKenney
[not found] ` <CA+55aFyHmykKc=YybJMo9ZUO352MY5noJVB4-K1Lkjmw4UHXfA@mail.gmail.com>
2016-02-27 23:10 ` Paul E. McKenney
2016-02-28 8:27 ` Markus Trippelsdorf
2016-02-28 16:13 ` Linus Torvalds
2016-02-28 16:50 ` [llvm-dev] " cbergstrom
2016-02-29 17:37 ` Michael Matz [this message]
2016-02-29 17:57 ` Linus Torvalds
2016-02-29 19:38 ` Lawrence Crowl
2016-02-29 21:12 ` [llvm-dev] " James Y Knight
2016-02-29 20:45 ` Toon Moene
2016-02-29 18:17 ` Michael Matz
2016-03-01 1:28 ` Paul E. McKenney
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=alpine.LSU.2.20.1602291825401.20277@wotan.suse.de \
--to=matz@suse.de \
--cc=Ramana.Radhakrishnan@arm.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=j.alglave@ucl.ac.uk \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm-dev@lists.llvm.org \
--cc=luc.maranget@inria.fr \
--cc=markus@trippelsdorf.de \
--cc=mingo@kernel.org \
--cc=parallel@lists.isocpp.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.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
all inboxes | Powered by JetHome®