From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 16B183858D37; Thu, 1 Feb 2024 04:48:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16B183858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706762904; bh=MrZ37fHLOuY96Lv47jL5TrFJOHuMWvIhBp+eqgeW9jc=; h=From:To:Subject:Date:From; b=ogT0yl5J/oNuGUIyHNmxc2AsC0EB1fhgGye2MN9u+6llJQYSWaZa+nKt86v7sv/kj 0fNdGaebJtP/8kFIaghauUTBGwIGiXHd+OFsFv3BbOQgnZqN7a3yAth75r5sgdYddX rcOBebmZH47zmGk/e/wMQgc0TlKa5+1+L+Q386CY= From: "kugan at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kugan at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113698 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=3D57275&action=3Dedit testcase When OMP_PROC_BIND=3Dtrue 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=3D72 ./a.out [main thread affinity right after main()]. tid:ffffae511020 aff:0000000000000000.0000000000000000.000000000000ffff.ffffffffffffffff duration: 402.949 msec $ OMP_PROC_BIND=3Dtrue OMP_NUM_THREADS=3D72 ./a.out [main thread affinity right after main()]. tid:fffdded50020 aff:0000000000000000.0000000000000000.0000000000000000.0000000000000001 duration: 7879.59 msec $ OMP_PROC_BIND=3Dtrue OMP_NUM_THREADS=3D72 ./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=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/aarch64-linux-gnu/11/lto-wrapper Target: aarch64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=3Dfile:///usr/share/doc/gcc-11/README.= Bugs --enable-languages=3Dc,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=3D/usr --with-gcc-major-version-only --program-suffix=3D-11 --program-prefix=3Daarch64-linux-gnu- --enable-shared --enable-linker-build= -id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=3Drelea= se --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=3Drelease --build=3Daarch64-linux-gnu --host=3Daarch64-linux-gnu --target=3Daarch64-l= inux-gnu --with-build-config=3Dbootstrap-lto-lean --enable-link-serialization=3D2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)=