From patchwork Wed Jan 3 15:54:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kwok Cheung Yeung X-Patchwork-Id: 184786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5101219dyb; Wed, 3 Jan 2024 07:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIz/+TnC9OoqTXRTztv7nkX08IP3rgCgqYRpqqPKIwz0hXylRlyfoUG7iPv7j0CWmFSe7f X-Received: by 2002:a05:620a:20c5:b0:781:61bf:b59 with SMTP id f5-20020a05620a20c500b0078161bf0b59mr9417807qka.66.1704297336876; Wed, 03 Jan 2024 07:55:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704297336; cv=pass; d=google.com; s=arc-20160816; b=oQVPUepI3U53Vdh2qvpL9yYPikwE7CkV7chqr7O/hB9xI1h4yCUzrBVB/nC84MVlL9 73nOmjM4RsIcUUZDFa6JAP0hqIMxhyV1BGSq7SHzsjX2SbUaFkwWjtqAvQ/hZqrBXMoP 88h8G9gVnPziUdDiztd62a2GZH7l/Fc3y3+7/Oe9+SnEHwWEmH4FQI8IyhDxFBnO7UIr O1bkfyS29s84vKW6X4OAaXMYhvcNQ1BkeiVmK78xHsB9NHKh9g1MNzY6BCDCnbTwmh2y ViiZr6rE4w6E90N7cFCjPzFsRTFkzXM/fhCelyuzlq4CuNIqlBSfSe5zTk+8zpRXvu5K sSLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :ironport-sdr:arc-filter:dmarc-filter:delivered-to; bh=MRHbeL0PoWi6ibYznEyiHJcD3/RsbhY+u3o6Ucsv0Sg=; fh=dGINLZgjgEFQPPVq+qIYAIZHN8g3AfA13cFkVJ41Iic=; b=HdEp/qU5rmDB7wxOrtqvkqYaQ2XPMt2bK4Uk4bRvHQqfISpr6f6KRTiTzX30o/rHMT RJmlypHurShcFu4HbMMKx9IXsO7CS/qz3qDczU+h+cZ6LHYoz4s67EPs9Shzt1j7abr/ 5fw4oW/9HHz8Eu/8EOo7p4Z5SXY5zdmJ+xzEfgtSdoRRhDf/4pOHVOLRsawujXyn4HE0 16bqMwWHPEedhk5GwkF+0bDA3O/WZF3/TTN407Xb0UQ1xcKz5vSOpVvq+F0FsGhChPyf nAFEyDMSSFu2t+zTIXe5VupHPfVwpfvU+rXWdbuwf4gga13hXGudU2G+J0FRNBycXAce jT2w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 27-20020a05620a049b00b00781afb71476si8539848qkr.409.2024.01.03.07.55.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7AAC838582BF for ; Wed, 3 Jan 2024 15:55:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 38D6D3858D38 for ; Wed, 3 Jan 2024 15:54:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38D6D3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 38D6D3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704297292; cv=none; b=h0jGwPIyB899SO5CBgWh6R5fBWhDaUVgVI1u1nQ4vIQXdRrENWaPwaIfIR31tc6jhNzoLHyizgJ+8xur5TBn5VZ7I3ohaP5u9yk9FsLkM2P1bywoaJAtFVxFpXprWd1sXzh7pYv7YEe92vfhZpVO6crimPOXfsKL9ygFuQmlxFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704297292; c=relaxed/simple; bh=IIFLwKNKsiNjZaRNIgLbRwpVIvbeqDtJrsQOLZ6ulUs=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=PKBzb1IIz4R6A3R6eMQgr6h9n1SUosJjBsKEVPirZkOUHLurCKhYQtV5XfWkW3UBPN7HzmurvZn2i15Cwbw38hu1b/CNyJv2CUCNWdyhZoPE0iDSX8+OTRAiy9XhWFw4DnjUCq/CBT6j3LecSFjHX5gemqZm0AKGvY1IteLdezY= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: EYHbXLdASNu3hNKqmcUCvQ== X-CSE-MsgGUID: WmkI7MNOTtGDeMThJSveUA== X-IronPort-AV: E=Sophos;i="6.04,327,1695715200"; d="scan'208,223";a="30089616" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 03 Jan 2024 07:54:48 -0800 IronPort-SDR: pQiy2JwZyG/IEnPFuWxCaqNhAFSK4vdUKa1zQRvzGZstmqEq/4LGmadoDBYPkcgLZ0d01+NmUd dDd46wr40Ss6OfZadyKgh7WYxCqPgvIzaWuPzhBbLcG8ebCA/eGTi/1VVpJpke1a7jZjrO8S6I OF9RjXgjlgkoU8IXT/N8WaF7XXsLkN/Ig39IPVfdo7x+uDnZX6QjxdIDFLQacUWZS/cXnkifdd WM2Shl+cfcJKRip/3QsNSy80JwtJtQDhOs0/sbO6Om2T7a8aryFcaXNuZeyPTI6vy3fjIg0w7X 1Qc= Message-ID: <598af23e-c225-45e3-9298-370823cf7f1d@codesourcery.com> Date: Wed, 3 Jan 2024 15:54:13 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [committed] Re: [PATCH] openmp: Add support for the 'indirect' clause in C/C++ Content-Language: en-GB To: Thomas Schwinge CC: Tobias Burnus , , "Jakub Jelinek" References: <37f412ee-58e7-4bde-a763-591268e8f8f4@codesourcery.com> <87wmurru61.fsf@euler.schwinge.homeip.net> From: Kwok Cheung Yeung In-Reply-To: <87wmurru61.fsf@euler.schwinge.homeip.net> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779193180839435435 X-GMAIL-MSGID: 1787085284368720216 On 09/11/2023 12:24 pm, Thomas Schwinge wrote: >> --- a/gcc/tree-core.h >> +++ b/gcc/tree-core.h >> @@ -350,6 +350,9 @@ enum omp_clause_code { >> /* OpenMP clause: doacross ({source,sink}:vec). */ >> OMP_CLAUSE_DOACROSS, >> >> + /* OpenMP clause: indirect [(constant-integer-expression)]. */ >> + OMP_CLAUSE_INDIRECT, >> + >> /* Internal structure to hold OpenACC cache directive's variable-list. >> #pragma acc cache (variable-list). */ >> OMP_CLAUSE__CACHE_, > > In this position here, isn't 'OMP_CLAUSE_INDIRECT' applicable to the > 'OMP_CLAUSE_RANGE_CHECK' in 'gcc/tree.h:OMP_CLAUSE_SIZE' and > 'gcc/tree.h:OMP_CLAUSE_DECL': > > #define OMP_CLAUSE_SIZE(NODE) \ > OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ > OMP_CLAUSE_FROM, \ > OMP_CLAUSE__CACHE_), 1) > > #define OMP_CLAUSE_DECL(NODE) \ > OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ > OMP_CLAUSE_PRIVATE, \ > OMP_CLAUSE__SCANTEMP_), 0) > > That's probably not intentional? In that case, maybe simply move it at > the end of the clause list? (..., and generally then match that ordering > in any 'switch'es, as applicable, and likewise position > 'gcc/tree.h:OMP_CLAUSE_INDIRECT_EXPR' correspondingly.) I have moved OMP_CLAUSE_INDIRECT to just before OMP_CLAUSE__SIMDUID_ so that it is outside the range checked by OMP_CLAUSE_SIZE and OMP_CLAUSE_DECL. I have also moved its handling in c(p)_parser_omp_clause_name so that the alphabetical ordering is preserved. Committed as trivial. > I would've assumed handling for 'OMP_CLAUSE_INDIRECT' to also be > necessary in the following places: > > - 'gcc/c-family/c-omp.cc:c_omp_split_clauses' > - 'gcc/cp/pt.cc:tsubst_omp_clauses', > - 'gcc/gimplify.cc:gimplify_scan_omp_clauses', > 'gcc/gimplify.cc:gimplify_adjust_omp_clauses' > - 'gcc/omp-low.cc:scan_sharing_clauses' (twice) > - 'gcc/tree-nested.cc:convert_nonlocal_omp_clauses', > 'gcc/tree-nested.cc:convert_local_omp_clauses' > - 'gcc/tree-pretty-print.cc:dump_omp_clause' > > Please verify, and add handling as well as test cases as necessary, or, > as applicable, put 'case OMP_CLAUSE_INDIRECT:' next to > 'default: gcc_unreachable ();' etc., if indeed that clause is not > expected there. As Tobias noted, OMP_CLAUSE_INDIRECT never makes it into the middle-end. It may be generated by c(p)_parser_omp_all_clauses, and if present an attribute is applied to the function declaration, but at no point is it directly incorporated into the tree structure. I'm not sure whether it is best to explicitly list such cases as gcc_unreachable (it might imply that it can reach the ME, but just not at that particular point?) or not though. Kwok From a56a693a74dd3bee71b1266b09dbd753694ace94 Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung Date: Wed, 3 Jan 2024 14:34:39 +0000 Subject: [PATCH] openmp: Adjust position of OMP_CLAUSE_INDIRECT in OpenMP clauses Move OMP_CLAUSE_INDIRECT so that it is outside of the range checked by OMP_CLAUSE_SIZE and OMP_CLAUSE_DECL. 2024-01-03 Kwok Cheung Yeung gcc/c/ * c-parser.cc (c_parser_omp_clause_name): Move handling of indirect clause to correspond to alphabetical order. gcc/cp/ * parser.cc (cp_parser_omp_clause_name): Move handling of indirect clause to correspond to alphabetical order. gcc/ * tree-core.h (enum omp_clause_code): Move OMP_CLAUSE_INDIRECT to before OMP_CLAUSE__SIMDUID_. * tree.cc (omp_clause_num_ops): Update position of entry for OMP_CLAUSE_INDIRECT to correspond with omp_clause_code. (omp_clause_code_name): Likewise. --- gcc/c/c-parser.cc | 4 ++-- gcc/cp/parser.cc | 4 ++-- gcc/tree-core.h | 6 +++--- gcc/tree.cc | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 64e436010d5..e7b74fb07f0 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -14899,10 +14899,10 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_IN_REDUCTION; else if (!strcmp ("inbranch", p)) result = PRAGMA_OMP_CLAUSE_INBRANCH; - else if (!strcmp ("indirect", p)) - result = PRAGMA_OMP_CLAUSE_INDIRECT; else if (!strcmp ("independent", p)) result = PRAGMA_OACC_CLAUSE_INDEPENDENT; + else if (!strcmp ("indirect", p)) + result = PRAGMA_OMP_CLAUSE_INDIRECT; else if (!strcmp ("is_device_ptr", p)) result = PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR; break; diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 1a6b53933a7..37536faf2cf 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -37645,10 +37645,10 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_IN_REDUCTION; else if (!strcmp ("inbranch", p)) result = PRAGMA_OMP_CLAUSE_INBRANCH; - else if (!strcmp ("indirect", p)) - result = PRAGMA_OMP_CLAUSE_INDIRECT; else if (!strcmp ("independent", p)) result = PRAGMA_OACC_CLAUSE_INDEPENDENT; + else if (!strcmp ("indirect", p)) + result = PRAGMA_OMP_CLAUSE_INDIRECT; else if (!strcmp ("is_device_ptr", p)) result = PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR; break; diff --git a/gcc/tree-core.h b/gcc/tree-core.h index d1c7136c204..8a89462bd7e 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -350,9 +350,6 @@ enum omp_clause_code { /* OpenMP clause: doacross ({source,sink}:vec). */ OMP_CLAUSE_DOACROSS, - /* OpenMP clause: indirect [(constant-integer-expression)]. */ - OMP_CLAUSE_INDIRECT, - /* Internal structure to hold OpenACC cache directive's variable-list. #pragma acc cache (variable-list). */ OMP_CLAUSE__CACHE_, @@ -497,6 +494,9 @@ enum omp_clause_code { /* OpenMP clause: filter (integer-expression). */ OMP_CLAUSE_FILTER, + /* OpenMP clause: indirect [(constant-integer-expression)]. */ + OMP_CLAUSE_INDIRECT, + /* Internally used only clause, holding SIMD uid. */ OMP_CLAUSE__SIMDUID_, diff --git a/gcc/tree.cc b/gcc/tree.cc index 82eff2bf34d..8aee3ef18d8 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -269,7 +269,6 @@ unsigned const char omp_clause_num_ops[] = 2, /* OMP_CLAUSE_MAP */ 1, /* OMP_CLAUSE_HAS_DEVICE_ADDR */ 1, /* OMP_CLAUSE_DOACROSS */ - 1, /* OMP_CLAUSE_INDIRECT */ 2, /* OMP_CLAUSE__CACHE_ */ 2, /* OMP_CLAUSE_GANG */ 1, /* OMP_CLAUSE_ASYNC */ @@ -316,6 +315,7 @@ unsigned const char omp_clause_num_ops[] = 0, /* OMP_CLAUSE_ORDER */ 0, /* OMP_CLAUSE_BIND */ 1, /* OMP_CLAUSE_FILTER */ + 1, /* OMP_CLAUSE_INDIRECT */ 1, /* OMP_CLAUSE__SIMDUID_ */ 0, /* OMP_CLAUSE__SIMT_ */ 0, /* OMP_CLAUSE_INDEPENDENT */ @@ -362,7 +362,6 @@ const char * const omp_clause_code_name[] = "map", "has_device_addr", "doacross", - "indirect", "_cache_", "gang", "async", @@ -409,6 +408,7 @@ const char * const omp_clause_code_name[] = "order", "bind", "filter", + "indirect", "_simduid_", "_simt_", "independent",