From patchwork Tue Jul 16 15:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1961131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=Qd3Hy0Qd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNjRn2GN7z1xqc for ; Wed, 17 Jul 2024 01:20:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 465B9386C5A4 for ; Tue, 16 Jul 2024 15:20:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 594933861808 for ; Tue, 16 Jul 2024 15:19:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 594933861808 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 594933861808 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721143181; cv=none; b=Z1uj4vWN/YalhDVE4Z2rOGp85rglObWpdWcQIUs3qYsuXsjpOzsDBOIlnjSVTvPdHse3QvjRC8doURvzD7iYhlBhnGPYoSl9EoyLys7gWyTRqlZ3L3Q0SvZf4AoQ+l3YcVzTMNZSikUMpS8moGMJyOy4h8eskyrnJmG44hkSx+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721143181; c=relaxed/simple; bh=IT75JnSbCdDfCt2Cn4deaEi24mLj03HUS9UsYBcVeKg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aDBMu6hQqYSUldeOQQdhoa27Qrt56XBSQAiy3n4PSELP4yX2cuTcBH4EGqqDmAugrrKvNpYTPtz5j9PNiO2q1hOi9JJ5I28a1ExBlFfGO9j0mM6BEQKF2UFqGuOm2rDELjXexOW5mdA0TCt77ZjGCKFdMb3G/8xlhoAK8W5NRNk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-367940c57ddso3460089f8f.3 for ; Tue, 16 Jul 2024 08:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721143173; x=1721747973; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=KzuPy/QOolnTJPWNefdJauORAefup2HBodmXyPZfE+4=; b=Qd3Hy0QdBIn+Q2ZhBzjtOKHqPVtPiugC5XupAvnfGkuy2B/sQ4kKSrCMjorqUGq4pb 1Al9c2TmeJF9MHzHO60ONEh8RX7nX8LsP0/T7G9IWkdG30eQBQtbIRwtDqF4hOlOYFkd o6Sjp74OXdiRl2bVQoMi5W+zP6otASmQDkq9YgXipqt5YksNYAvIGF7xDmxav0RpM7lb ZD0lDNcG6kxxy9zIppcI0isvA4bzE1pCsEip4rjKNJeLyHDQjkKjkVvSRC1jDvyb2B3n SqyZevL5MVg5V0ayaJw0np9m6678ASyJAVr5oIvuoB6GOZ2/MdFFfc6bAxCFpfAllRqD sf3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721143173; x=1721747973; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KzuPy/QOolnTJPWNefdJauORAefup2HBodmXyPZfE+4=; b=xHh13SbK6GGEw/KurEvy5KcluAaaPbnBqEysO41rnQaTf+8vpnggyS5LHemBtr9qGs XUi+T7h/7U9m9rn/FrEZMZ1E12HYug9vOMAD0TEhhCDdMNno19O3qMJO4HzlJn7pGBY5 SYSDsjN1ixQCQS3lkn/DBYPCSfarjk1zCsLza3PBVm2T3FMbx3e6evkCxAu/qEN6JEDh zhHJCK0mdy1YqdISVqX5SCr4J1QZKzmDTiPur8gQWYUIjqeUtRH+HedCbATep0lpIyj3 +cqwnFeAA60xg0bQRYpLwGxDLrxdULPI1n0ZpDxw0TC0U5MX6T7Bbq2p5lHh6YXMugxm KhJQ== X-Gm-Message-State: AOJu0Yw1SsmeB5lFMZx8Zal5yHThZO4IUFa4e1ca15dm04ZsgWQ5BbDB OaAv1c3jBsf60t41AEZ4Y3YwRkhZv03KTCws8wTEfYOc4jvEVsIBAXEBMrnhDGlbPzldwS/gseX h X-Google-Smtp-Source: AGHT+IE8KSyri6YxSXex5vMT81eFiLOYd5iWwl91IPvFnd+v0LdtdceGh/4bY4tp3N12LJbCaG673Q== X-Received: by 2002:adf:f9c5:0:b0:367:f2ea:13e4 with SMTP id ffacd0b85a97d-3682613a229mr1522926f8f.32.1721143172747; Tue, 16 Jul 2024 08:19:32 -0700 (PDT) Received: from euler.schwinge.ddns.net (p200300c8b733b9005e8fc6f38b6af531.dip0.t-ipconnect.de. [2003:c8:b733:b900:5e8f:c6f3:8b6a:f531]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5ef3256sm132234165e9.39.2024.07.16.08.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 08:19:32 -0700 (PDT) From: Thomas Schwinge To: gcc-patches@gcc.gnu.org, Andrew Stubbs , Jakub Jelinek Cc: Tobias Burnus Subject: libgomp: Document 'GOMP_teams4' (was: GCN: Honor OpenMP 5.1 'num_teams' lower bound) In-Reply-To: <41872a9e-0778-42b1-8c56-035c43ac4aa1@baylibre.com> References: <20211112132023.GC2710@tucnak> <20211112132716.GD2710@tucnak> <20211112175804.GJ2710@tucnak> <87y163t340.fsf@euler.schwinge.ddns.net> <1d6820d0-2f0c-4ef7-8110-9de2442ec189@baylibre.com> <87plrey8dm.fsf@euler.schwinge.ddns.net> <41872a9e-0778-42b1-8c56-035c43ac4aa1@baylibre.com> User-Agent: Notmuch/0.30+8~g47a4bad (https://notmuchmail.org) Emacs/29.4 (x86_64-pc-linux-gnu) Date: Tue, 16 Jul 2024 17:19:27 +0200 Message-ID: <87zfqh2wlc.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! On 2024-07-15T17:01:46+0100, Andrew Stubbs wrote: > On 15/07/2024 16:36, Thomas Schwinge wrote: >> On 2024-07-15T12:16:30+0100, Andrew Stubbs wrote: >>> On 15/07/2024 10:29, Thomas Schwinge wrote: >>>> On 2021-11-12T18:58:04+0100, Jakub Jelinek via Gcc-patches wrote: >>>>> And finally here is a third version, [...] >>>> >>>> ... which became commit 9fa72756d90e0d9edadf6e6f5f56476029925788 >>>> "libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound". >>>> >>>> Attached here is "GCN: Honor OpenMP 5.1 'num_teams' lower bound", which >>>> are exactly the corresponding changes for GCN (see below Jakub's nvptx >>>> changes for reference); OK to push? >> >>> That's a lot of convoluted logic to drop in without a single comment! >> >> Well, I'll pass that compliment over to Jakub ;-) -- my code changes just >> intend to be a faithful "'s%nvptx%GCN'" of his code changes from back >> then. >> >>> The GCN bits look fine, and I assume you've probably thought about the >>> logic here a lot, but I've no idea what you're trying to achieve, or why >>> you're trying to achieve it (from the patch alone). >>> >>> Can we have some comments on motivation and goals, please? >> >> Here's the original context: >> >> - "[PATCH] openmp: Honor OpenMP 5.1 num_teams lower bound" >> - "[PATCH] libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound" >> >> Is that sufficient, and/or would you like to see some commentary to the >> relevant libgomp generic/nvptx/GCN code added? > > Yes, sorry if it wasn't clear; I meant *code* comments. > > /* The team number is usually the same as the gcn_dim_pos(0), except > when num_teams(N) is ..... */ > > The FIXME actually tells me something useful about one of the > conditional cases, but that's being removed here. > > Also, why are we returning "false" in other cases, and what effect does > that have? Is that for "spare" teams when we launch more than we need? How about the attached "libgomp: Document 'GOMP_teams4'"? Jakub, does that accurately reflect the relevant facts? Grüße Thomas From 149c2dc71bb44a9365ea3c360304f75cb9056084 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 16 Jul 2024 17:09:38 +0200 Subject: [PATCH] libgomp: Document 'GOMP_teams4' For reference: - "[PATCH] openmp: Honor OpenMP 5.1 num_teams lower bound" - "[PATCH] libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound" libgomp/ * config/gcn/target.c (GOMP_teams4): Document. * config/nvptx/target.c (GOMP_teams4): Likewise. * target.c (GOMP_teams4): Likewise. --- libgomp/config/gcn/target.c | 8 ++++++++ libgomp/config/nvptx/target.c | 8 ++++++++ libgomp/target.c | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c index e57d2e5f93f..9cafea4e2cc 100644 --- a/libgomp/config/gcn/target.c +++ b/libgomp/config/gcn/target.c @@ -29,6 +29,14 @@ extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS; +/* Implement OpenMP 'teams' construct. + + Initialize upon FIRST call. Return whether this invocation is active. + Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided + in hardware, we may need to loop multiple times; in that case make sure to + update the team-level variable used by 'omp_get_team_num', as we then can't + just use '__builtin_gcn_dim_pos (0)'. */ + bool GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper, unsigned int thread_limit, bool first) diff --git a/libgomp/config/nvptx/target.c b/libgomp/config/nvptx/target.c index f14dcfc8ff6..8d4dc5f661a 100644 --- a/libgomp/config/nvptx/target.c +++ b/libgomp/config/nvptx/target.c @@ -31,6 +31,14 @@ extern int __gomp_team_num __attribute__((shared)); extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS; volatile struct rev_offload *GOMP_REV_OFFLOAD_VAR; +/* Implement OpenMP 'teams' construct. + + Initialize upon FIRST call. Return whether this invocation is active. + Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided + in hardware, we may need to loop multiple times; in that case make sure to + update the team-level variable used by 'omp_get_team_num', as we then can't + just use '%ctaid.x'. */ + bool GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper, unsigned int thread_limit, bool first) diff --git a/libgomp/target.c b/libgomp/target.c index e311e5a8302..47a18477b2a 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -4355,6 +4355,8 @@ gomp_target_task_fn (void *data) return false; } +/* Implement OpenMP 'teams' construct, legacy entry point. */ + void GOMP_teams (unsigned int num_teams, unsigned int thread_limit) { @@ -4367,6 +4369,13 @@ GOMP_teams (unsigned int num_teams, unsigned int thread_limit) (void) num_teams; } +/* Implement OpenMP 'teams' construct. + + Initialize upon FIRST call. Return whether this invocation is active. + Depending on whether NUM_TEAMS_LOW asks for more teams than are provided + in hardware, we may need to loop multiple times; in that case make sure to + update the team-level variable used by 'omp_get_team_num'. */ + bool GOMP_teams4 (unsigned int num_teams_low, unsigned int num_teams_high, unsigned int thread_limit, bool first) -- 2.34.1