public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yann.collet.73 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/67435] Large performance drop on apparently unrelated changes (potential cause : critical loop instruction alignment)
Date: Thu, 03 Sep 2015 18:47:00 -0000	[thread overview]
Message-ID: <bug-67435-4-K9kPsCI2GP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67435-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Yann Collet <yann.collet.73 at gmail dot com> ---
Thanks for the link.
It's a very good read, and indeed, completely in line with my recent
experience.
Recommended solution seems to be the same : "-falign-loops=32"


The article also mentions that the issue is valid for Sandy Bridge cpus.
This broadens the scope : it's not just about Broadwell, but also Haswell, Ivy
Bridge and sandy Bridge. All new cpus from Intel since 2011. It looks like a
large enough installed base to care about.

However, for some reason, in the table provided, both Sandy Bridge and Haswell
get a default loop alignment value of 16. not 32.

Is there a reason for that choice ?


> Optimizing for just one specific model will negatively affect performance on an other.

Well, this issue is apparently important for more than one architecture.
Moreover, being inlined on 32 imply being inlined on 16 too, so it doesn't
introduce drawback for older siblings.


Since then, I could find a few other complaints about the same issue. One
example here : https://software.intel.com/en-us/forums/topic/479392

and a close cousin here :
http://stackoverflow.com/questions/9881002/is-this-a-gcc-bug-when-using-falign-loops-option


This last one introduce a good question : while it's possible to use
"-falign-loops=32" to set the preference for the whole program, it seems not
possible to set it precisely for a single loop.

It looks like a good feature request, as this loop-alignment issue can have a
pretty large impact on performance (~20%), but only matters for a few selected
critical loops. The programmer is typically in good position to know which loop
matters the most. Hence, we don't necessarily need *all* loops to be 32-bytes
aligned, just a handful ones.

Less precise but still great, having the ability to set this optimization
parameter for a function or a section code would be great. But my experiment
seem to show that using #pragma or __attribute__ with align-loops does not
work, as if the optimization setting was simply ignored.


  parent reply	other threads:[~2015-09-03 18:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 13:24 [Bug c/67435] New: Large performance drop on apparently unrelated changes (probable cause : strange inlining side-effect) yann.collet.73 at gmail dot com
2015-09-02 14:01 ` [Bug c/67435] " trippels at gcc dot gnu.org
2015-09-02 14:03 ` pinskia at gcc dot gnu.org
2015-09-02 14:51 ` yann.collet.73 at gmail dot com
2015-09-03  2:44 ` yann.collet.73 at gmail dot com
2015-09-03  7:19 ` [Bug c/67435] Large performance drop on apparently unrelated changes (potential cause : critical loop instruction alignment) trippels at gcc dot gnu.org
2015-09-03 18:47 ` yann.collet.73 at gmail dot com [this message]
2015-09-04 10:23 ` [Bug c/67435] Large performance drop on apparently unrelated changes (potential cause : hot loop alignment) trippels at gcc dot gnu.org
2015-09-04 10:34 ` [Bug c/67435] Feature request: Implement align-loops attribute trippels at gcc dot gnu.org
2015-10-20 13:09 ` yann.collet.73 at gmail dot com

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-67435-4-K9kPsCI2GP@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).