From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA9233858C20; Thu, 1 Feb 2024 08:36:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA9233858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706776581; bh=uBxgOOFvCBAU+cSxci4Spah6WN0xVUS++zTziMoSRrk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ET3w/oQQ6b7gz3Sj41FRVV2YpLYulaUmx5jNl4xAmmxdAte8OhPQ7rssulb6yklb8 os60NDAy4wbLdQhGZR5jEUroPCUHNpl4m3XqKbmKziqB8haWT2cfEFQnfXr8Yh4r9a HiRu08x+3qEfld/udjYma7R7sisz+uI/y7tSNvy4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/113698] GNU OpenMP with OMP_PROC_BIND alters thread affinity in a way that negatively affects performance Date: Thu, 01 Feb 2024 08:36:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization, openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: Message-ID: In-Reply-To: References: 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 --- Comment #3 from Jakub Jelinek --- You can use GOMP_CPU_AFFINITY or different setting of OMP_PROC_BIND together with OMP_PLACES to bind the initial thread to different CPU. While the OpenMP spec allows moving the initial thread from unspecified pla= ce to the requested one only before the first active parallel region, doing th= at there would add to the overhead of #pragma omp parallel and what exactly the application wants is hard to guess, whether the allocations done in the ini= tial thread prior to the first parallel are meant for the initial thread or other threads too. And, if you just add an empty #pragma omp parallel at the start of main, th= en OpenMP requires the thread to be bound there. There are OpenMP allocators one can use and request specific thread binding= for the allocations, or perform the allocations from the threads.=