From patchwork Fri Oct 15 14:45:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 46277 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84AE73857C6C for ; Fri, 15 Oct 2021 14:46:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84AE73857C6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634309182; bh=OW8Y11U6oq86AzlDbLWgdSSk2Ikzx0z/jtAa3V30ytc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qfuX7DGq59NH1xkRG25US2pqnhJ9/NzlilSmdKFUK655KoTMtWWG5a7CLRttzoHaA O7PJNhrnv946foVFX7+Xqs0V6lcZBup5DS/02xbzDxkxBZw3tX24jsvc7sb373uBtH 04XIfSe9R+cGgrgAnoWwe+e22KlKg/sNXGxxD1sE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 604F1385842E for ; Fri, 15 Oct 2021 14:45:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 604F1385842E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-OjUKVZZSPPWU5Sg-9hHjkw-1; Fri, 15 Oct 2021 10:45:49 -0400 X-MC-Unique: OjUKVZZSPPWU5Sg-9hHjkw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C49471023F5C; Fri, 15 Oct 2021 14:45:48 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6532319736; Fri, 15 Oct 2021 14:45:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 19FEjj1v424943 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 15 Oct 2021 16:45:46 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 19FEji7f424942; Fri, 15 Oct 2021 16:45:44 +0200 Date: Fri, 15 Oct 2021 16:45:44 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Fix up handling of OMP_PLACES=threads(1) Message-ID: <20211015144544.GE304296@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Tobias Burnus Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! When writing the places-*.c tests, I've noticed that we mishandle threads abstract name with specified num-places if num-places isn't a multiple of number of hw threads in a core. It then happily ignores the maximum count and overwrites for the remaining hw threads in a core further places that haven't been allocated. Regtested on x86_64-linux and i686-linux, committed to trunk. 2021-10-15 Jakub Jelinek * config/linux/affinity.c (gomp_affinity_init_level_1): For level 1 after creating count places clean up and return immediately. * testsuite/libgomp.c/places-6.c: New test. * testsuite/libgomp.c/places-7.c: New test. * testsuite/libgomp.c/places-8.c: New test. * testsuite/libgomp.c/places-9.c: New test. * testsuite/libgomp.c/places-10.c: New test. Jakub --- libgomp/config/linux/affinity.c.jj 2021-10-14 22:04:30.595333461 +0200 +++ libgomp/config/linux/affinity.c 2021-10-15 13:20:19.561484351 +0200 @@ -338,8 +338,13 @@ gomp_affinity_init_level_1 (int level, i if (gomp_affinity_add_cpus (pl, first, 1, 0, true)) { CPU_CLR_S (first, gomp_cpuset_size, copy); - if (level == 1) - gomp_places_list_len++; + if (level == 1 + && ++gomp_places_list_len >= count) + { + fclose (f); + free (line); + return; + } } } if (*p == ',') --- libgomp/testsuite/libgomp.c/places-6.c.jj 2021-10-15 13:28:17.461582786 +0200 +++ libgomp/testsuite/libgomp.c/places-6.c 2021-10-15 13:28:25.228470619 +0200 @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "threads(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} --- libgomp/testsuite/libgomp.c/places-7.c.jj 2021-10-15 13:28:17.465582728 +0200 +++ libgomp/testsuite/libgomp.c/places-7.c 2021-10-15 13:28:30.295397448 +0200 @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "cores(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} --- libgomp/testsuite/libgomp.c/places-8.c.jj 2021-10-15 13:28:17.469582670 +0200 +++ libgomp/testsuite/libgomp.c/places-8.c 2021-10-15 13:28:35.181326887 +0200 @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "sockets(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} --- libgomp/testsuite/libgomp.c/places-9.c.jj 2021-10-15 13:28:17.473582613 +0200 +++ libgomp/testsuite/libgomp.c/places-9.c 2021-10-15 13:28:39.913258548 +0200 @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "ll_caches(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} --- libgomp/testsuite/libgomp.c/places-10.c.jj 2021-10-15 13:28:17.477582555 +0200 +++ libgomp/testsuite/libgomp.c/places-10.c 2021-10-15 13:28:46.433164392 +0200 @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "numa_domains(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +}