public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kugan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/113698] New: GNU OpenMP with OMP_PROC_BIND alters thread affinity in a way that negatively affects performance
Date: Thu, 01 Feb 2024 04:48:21 +0000	[thread overview]
Message-ID: <bug-113698-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113698
           Summary: GNU OpenMP with OMP_PROC_BIND alters thread affinity
                    in a way that negatively affects performance
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kugan at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57275
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57275&action=edit
testcase

When OMP_PROC_BIND=true it seems gomp set the affinity even before main()
starts. In particular, the main thread gets affinity 0x1 (i.e. pinned to the
first core). For the attached, I get

$ OMP_NUM_THREADS=72 ./a.out
[main thread affinity right after main()]. tid:ffffae511020
aff:0000000000000000.0000000000000000.000000000000ffff.ffffffffffffffff
duration: 402.949 msec

$ OMP_PROC_BIND=true OMP_NUM_THREADS=72 ./a.out
[main thread affinity right after main()]. tid:fffdded50020
aff:0000000000000000.0000000000000000.0000000000000000.0000000000000001
duration: 7879.59 msec

$ OMP_PROC_BIND=true OMP_NUM_THREADS=72 ./a.out
[main thread affinity right after main()]. tid:ffffae54c020
aff:0000000000000000.0000000000000000.0000000000000000.0000000000000001
duration: 311219 msec

Compiler options used:
gcc -O0 -fopenmp repro.c

gcc -v:


Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/11/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
11.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release
--build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)

             reply	other threads:[~2024-02-01  4:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  4:48 kugan at gcc dot gnu.org [this message]
2024-02-01  4:58 ` [Bug libgomp/113698] " pinskia at gcc dot gnu.org
2024-02-01  5:00 ` pinskia at gcc dot gnu.org
2024-02-01  8:36 ` jakub at gcc dot gnu.org
2024-02-09 20:31 ` kugan at gcc dot gnu.org
2024-02-09 20:40 ` pinskia 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-113698-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).