From patchwork Wed Oct 2 16:55:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul-Antoine Arras X-Patchwork-Id: 1992100 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=Mz+AIH/r; 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 4XJgv344kWz1xtY for ; Thu, 3 Oct 2024 02:56:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA52A3857000 for ; Wed, 2 Oct 2024 16:56:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 83BE03858D29 for ; Wed, 2 Oct 2024 16:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83BE03858D29 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 83BE03858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727888160; cv=none; b=tD8BCqww8SDV4Px9Dq0Z35XysPZH7yROQwbmO/6GJir2w28jLoKXtcFKMgNjPOyELHusNTtrFBcEphjgurYEMQO8Y/JqiDGTG5Dt365MBM63LDcnbOy7ZKnaXe7skNXFxnTb73fZsMBJlPj1DmN0QX1vmUwt69B0/tQSAQFUlKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727888160; c=relaxed/simple; bh=xfG+TXogvONWRd2tZJludTYNDZeVYwpGs2xaVgArtSc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LGMeppVonWVQoFwEbNo5BHmhcgAOzwBFmb3oRwWFYOmrjzvVHlfv467//us4cyXA+LpIF7J9ekFOR+WacZw17kIIiCf4Vh15ETQSNBujMeq/kXIgpkm8G9PESe/kAK7PY+bNlbbCz7Oumre7w9TQbZzF+XNafoXlGMkiv+LQrnY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37cd831ab06so34315f8f.0 for ; Wed, 02 Oct 2024 09:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1727888156; x=1728492956; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hfGfXrV6DAnVQUA+K/fFgPKmBK5SD6phvNbkuXaM3SU=; b=Mz+AIH/rM832HXoUO9s0jIyeDtcYf0AdzBe+4MsD30vLHzW7vR98YQBkbotDF5h59s 7aACLUkzWUh4SgmR493xYLeoITOk5wv5HvFj8dhgJcfHAGaNHKBAInpg3jQ0rdEj6hky uqvWdioEyAuwXUiSj+bPnw+HLAgmwbYu1Lm+OD2qH9Sjz2bh38Z2gnbv4Y9HtfKsYe0t Gq5g2j7eLMOnWGf1ZIJK4RHK3psfRrEmBrWf9C+T5oaBqpAKFNQqXY4rvKTbkiPRP97L rCmo4t7rKRUwHz1wovdHUlIf5AmFvRuivYBZh949YxfXm19NUpigPw45KOJMbgdlJdRo BHzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888156; x=1728492956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hfGfXrV6DAnVQUA+K/fFgPKmBK5SD6phvNbkuXaM3SU=; b=hEi5wRn6MvKuXzt9qUR+bYjaTSHQNX3eYMgDU+EbOrpeSjfvkmKmfDVOwZuWQI9fmB jaLXVWpkeGaNidt6IffIK2em/VpIfsafJzOsDhyiA0iAiIGMuhgrv4OytoKcMo3EqMF0 BvEuwHLzLL6tAJIF/AgsvZMODtyxriGa7wBbPYSmb7dUAjyc0RlSOaLgfmJ7jCrSrBzX fnB8qLOW7BqFogVEEF6bSlTeBpRfTteZ2lzj1nOzUAovQ4BJlydNDv2iWiMlExh6fEqX CYxz6jM+n5pmCdVfLhttfPd02ZNKe9DnFYjeFeJTZR+G4N384/QQa1hKwniclJeie2CU P3EQ== X-Gm-Message-State: AOJu0YyYCXKvKFr11b+3H4xkTDFw0G57VC43QzFw7xFwyQpcWxXHgAcG ZQgB8r5bjBJNWzoxb+MbKPusmQH6MOzp6+MZ8X7VIHJxc+/Ss9/v0gUjI29rPaj4vSw9TtKh3Jd l X-Google-Smtp-Source: AGHT+IHWXEoVGuqspipOJYGcqBnPUIlFAorT+IQ3Ew7wVmNI/3KiXGizwoSdPB1B32zf7f2HFNXwBQ== X-Received: by 2002:adf:b31b:0:b0:37c:cfe4:6997 with SMTP id ffacd0b85a97d-37cfb9f9cf5mr1943134f8f.47.1727888155704; Wed, 02 Oct 2024 09:55:55 -0700 (PDT) Received: from localhost.localdomain (2a01cb0018c22f0003fd7af961426ad9.ipv6.abo.wanadoo.fr. [2a01:cb00:18c2:2f00:3fd:7af9:6142:6ad9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd575de73sm14244859f8f.115.2024.10.02.09.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:54 -0700 (PDT) From: Paul-Antoine Arras To: gcc-patches@gcc.gnu.org Cc: Paul-Antoine Arras Subject: [PATCH v4 1/7] OpenMP: dispatch + adjust_args tree data structures and front-end interfaces Date: Wed, 2 Oct 2024 18:55:32 +0200 Message-ID: <20241002165538.3237107-2-parras@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241002165538.3237107-1-parras@baylibre.com> References: <20241002165538.3237107-1-parras@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 This patch introduces the OMP_DISPATCH tree node, as well as two new clauses `nocontext` and `novariants`. It defines/exposes interfaces that will be used in subsequent patches that add front-end and middle-end support, but nothing generates these nodes yet. gcc/ChangeLog: * builtin-types.def (BT_FN_PTR_CONST_PTR_INT): New. * omp-selectors.h (enum omp_ts_code): Add OMP_TRAIT_CONSTRUCT_DISPATCH. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (dump_generic_node): Handle OMP_DISPATCH. * tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (omp_clause_code_name): Add "novariants" and "nocontext". * tree.def (OMP_DISPATCH): New. * tree.h (OMP_DISPATCH_BODY): New macro. (OMP_DISPATCH_CLAUSES): New macro. (OMP_CLAUSE_NOVARIANTS_EXPR): New macro. (OMP_CLAUSE_NOCONTEXT_EXPR): New macro. gcc/fortran/ChangeLog: * types.def (BT_FN_PTR_CONST_PTR_INT): Declare. --- gcc/builtin-types.def | 1 + gcc/fortran/types.def | 1 + gcc/omp-selectors.h | 1 + gcc/tree-core.h | 7 +++++++ gcc/tree-pretty-print.cc | 21 +++++++++++++++++++++ gcc/tree.cc | 4 ++++ gcc/tree.def | 5 +++++ gcc/tree.h | 7 +++++++ 8 files changed, 47 insertions(+) diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index c97d6bad1de..ef7aaf67d13 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -677,6 +677,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_FEXCEPT_T_PTR_INT, BT_INT, BT_FEXCEPT_T_PTR, DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_FEXCEPT_T_PTR_INT, BT_INT, BT_CONST_FEXCEPT_T_PTR, BT_INT) DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_UINT8, BT_PTR, BT_CONST_PTR, BT_UINT8) +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT) DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR) diff --git a/gcc/fortran/types.def b/gcc/fortran/types.def index 390cc9542f7..5047c8f816a 100644 --- a/gcc/fortran/types.def +++ b/gcc/fortran/types.def @@ -120,6 +120,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_BOOL_INT_BOOL, BT_BOOL, BT_INT, BT_BOOL) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_PTRMODE, BT_VOID, BT_PTR, BT_PTRMODE) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, BT_SIZE) +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT) DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR) diff --git a/gcc/omp-selectors.h b/gcc/omp-selectors.h index 730021ea747..447c3b8173f 100644 --- a/gcc/omp-selectors.h +++ b/gcc/omp-selectors.h @@ -56,6 +56,7 @@ enum omp_ts_code { OMP_TRAIT_CONSTRUCT_PARALLEL, OMP_TRAIT_CONSTRUCT_FOR, OMP_TRAIT_CONSTRUCT_SIMD, + OMP_TRAIT_CONSTRUCT_DISPATCH, OMP_TRAIT_LAST, OMP_TRAIT_INVALID = -1 }; diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 4ba63ebd4f1..b7c92daa1e6 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -542,6 +542,13 @@ enum omp_clause_code { /* OpenACC clause: nohost. */ OMP_CLAUSE_NOHOST, + + /* OpenMP clause: novariants (scalar-expression). */ + OMP_CLAUSE_NOVARIANTS, + + /* OpenMP clause: nocontext (scalar-expression). */ + OMP_CLAUSE_NOCONTEXT, + }; #undef DEFTREESTRUCT diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index b378ffbfb4c..61cd8708524 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -506,6 +506,22 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags) case OMP_CLAUSE_EXCLUSIVE: name = "exclusive"; goto print_remap; + case OMP_CLAUSE_NOVARIANTS: + pp_string (pp, "novariants"); + pp_left_paren (pp); + gcc_assert (OMP_CLAUSE_NOVARIANTS_EXPR (clause)); + dump_generic_node (pp, OMP_CLAUSE_NOVARIANTS_EXPR (clause), spc, flags, + false); + pp_right_paren (pp); + break; + case OMP_CLAUSE_NOCONTEXT: + pp_string (pp, "nocontext"); + pp_left_paren (pp); + gcc_assert (OMP_CLAUSE_NOCONTEXT_EXPR (clause)); + dump_generic_node (pp, OMP_CLAUSE_NOCONTEXT_EXPR (clause), spc, flags, + false); + pp_right_paren (pp); + break; case OMP_CLAUSE__LOOPTEMP_: name = "_looptemp_"; goto print_remap; @@ -3947,6 +3963,11 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags); goto dump_omp_body; + case OMP_DISPATCH: + pp_string (pp, "#pragma omp dispatch"); + dump_omp_clauses (pp, OMP_DISPATCH_CLAUSES (node), spc, flags); + goto dump_omp_body; + case OMP_SECTION: pp_string (pp, "#pragma omp section"); goto dump_omp_body; diff --git a/gcc/tree.cc b/gcc/tree.cc index bc50afca9a3..222d5ffd256 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -331,6 +331,8 @@ unsigned const char omp_clause_num_ops[] = 0, /* OMP_CLAUSE_IF_PRESENT */ 0, /* OMP_CLAUSE_FINALIZE */ 0, /* OMP_CLAUSE_NOHOST */ + 1, /* OMP_CLAUSE_NOVARIANTS */ + 1, /* OMP_CLAUSE_NOCONTEXT */ }; const char * const omp_clause_code_name[] = @@ -427,6 +429,8 @@ const char * const omp_clause_code_name[] = "if_present", "finalize", "nohost", + "novariants", + "nocontext", }; /* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric diff --git a/gcc/tree.def b/gcc/tree.def index 85ab182c6f5..1a6c9512cfc 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -1298,6 +1298,11 @@ DEFTREECODE (OMP_MASKED, "omp_masked", tcc_statement, 2) Operand 1: OMP_SCAN_CLAUSES: List of clauses. */ DEFTREECODE (OMP_SCAN, "omp_scan", tcc_statement, 2) +/* OpenMP - #pragma omp dispatch [clause1 ... clauseN] + Operand 0: OMP_DISPATCH_BODY: Expression statement including a target call. + Operand 1: OMP_DISPATCH_CLAUSES: List of clauses. */ +DEFTREECODE (OMP_DISPATCH, "omp_dispatch", tcc_statement, 2) + /* OpenMP - #pragma omp section Operand 0: OMP_SECTION_BODY: Section body. */ DEFTREECODE (OMP_SECTION, "omp_section", tcc_statement, 1) diff --git a/gcc/tree.h b/gcc/tree.h index 75efc760a16..c8cc9ba31db 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1604,6 +1604,9 @@ class auto_suppress_location_wrappers #define OMP_SCAN_BODY(NODE) TREE_OPERAND (OMP_SCAN_CHECK (NODE), 0) #define OMP_SCAN_CLAUSES(NODE) TREE_OPERAND (OMP_SCAN_CHECK (NODE), 1) +#define OMP_DISPATCH_BODY(NODE) TREE_OPERAND (OMP_DISPATCH_CHECK (NODE), 0) +#define OMP_DISPATCH_CLAUSES(NODE) TREE_OPERAND (OMP_DISPATCH_CHECK (NODE), 1) + #define OMP_CLAUSE_SIZE(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ OMP_CLAUSE_FROM, \ @@ -1751,6 +1754,10 @@ class auto_suppress_location_wrappers OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PARTIAL), 0) #define OMP_CLAUSE_SIZES_LIST(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SIZES), 0) +#define OMP_CLAUSE_NOVARIANTS_EXPR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NOVARIANTS), 0) +#define OMP_CLAUSE_NOCONTEXT_EXPR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NOCONTEXT), 0) #define OMP_CLAUSE_GRAINSIZE_EXPR(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GRAINSIZE),0)