public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jengelh at inai dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107895] New: mt19937 bad performance on LP64
Date: Mon, 28 Nov 2022 10:36:09 +0000	[thread overview]
Message-ID: <bug-107895-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107895
           Summary: mt19937 bad performance on LP64
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

Input
=====

#include <random>
#include <unistd.h>
static std::mt19937 rng;
int main() {
        for (size_t j = 0; j < 0x8000; ++j) {
                uint32_t numbers[65536];
                for (size_t i = 0; i < std::size(numbers); ++i)
                        numbers[i] = rng();
                // ensure number generation is not all optimized away
                write(STDOUT_FILENO, numbers, sizeof(numbers));
        }
}


Observed
========

Target: x86_64-suse-linux
gcc version 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7]
(SUSE Linux)

$ g++ x.cpp -O2 && time ./a.out >/dev/zero

                  -m32    -m64
===============  =====  ======
std::mt19937      3.9s   11.5s
std::mt19937_64  14.0s   11.6s
===============  =====  ======
error ±0.1s

With -ftree-loop-if-convert [Bug #80520], but still not at -m32 levels:

+-ftree-          -m32    -m64
===============  =====  ======
std::mt19937      3.9s    5.2s
std::mt19937_64  14.0s    5.4s
===============  =====  ======
error ±0.1s


Expected
========

Expected to see <= 4.7s on -m64 at all times. (3.9 + ~20% margin for wider
transfers CPU<->caches/RAM)

The -m64 versions should have somewhat equal runtime or faster runtime (because
more registers, more opportunities); concerns like https://gmplib.org/32vs64
apply to old CPUs, but I do not think it's indicative of how contemporary
x86_64 systems perform.


Additional information
======================

CPUs:
 "11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz"
    [fam 6 model 140 stepping 1 microcode 0xa4] and
 "AMD Ryzen 7 3700X 8-Core Processor"
    [fam 23 model 113 stepping 0 microcode 0x8701013]
    (about 3.0 and 10.2 seconds runtime, respectively)

             reply	other threads:[~2022-11-28 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 10:36 jengelh at inai dot de [this message]
2022-11-28 11:13 ` [Bug tree-optimization/107895] " jengelh at inai dot de
2022-11-28 11:58 ` rguenth at gcc dot gnu.org
2022-11-28 13:48 ` marxin 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-107895-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).