From patchwork Wed Mar 8 16:28:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1754204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=l40nQm0s; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWyS52yJcz1yWx for ; Thu, 9 Mar 2023 03:28:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 641C7385084F for ; Wed, 8 Mar 2023 16:28:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 641C7385084F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678292931; bh=Nlms1+6cIXv679+8AkiPr4KGBtFw496rjApetW7LxEo=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=l40nQm0sxEyuQShV7iJK9AN5Y6iq3THAPctcLtGQ/M7C/Ge93WvLzFFKdG4oBjqOU huqzYhd8bkiCxaoF3u0/RHGkTN+tMWlD/baKEFVFJFeANdnio1OhuLFMiTeWtBmBoB x4yPK0xWl6xSqmNPiICuiiJ2+Erdp4Y75T9rr/aU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 05FA63858D33 for ; Wed, 8 Mar 2023 16:28:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05FA63858D33 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 373621063; Wed, 8 Mar 2023 08:29:14 -0800 (PST) Received: from [10.57.79.24] (unknown [10.57.79.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15DE13F71A; Wed, 8 Mar 2023 08:28:29 -0800 (PST) Message-ID: <2f1139f6-5ac6-6baa-3190-99b09d35b9b9@arm.com> Date: Wed, 8 Mar 2023 16:28:24 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [RFC 6/X] omp: Allow creation of simd clones from omp declare variant with -fopenmp-simd flag Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Cc: "jakub@redhat.com" , Richard Sandiford , Richard Biener References: In-Reply-To: X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Andre Vieira \(lists\) via Gcc-patches" From: "Andre Vieira (lists)" Reply-To: "Andre Vieira \(lists\)" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This RFC is to propose relaxing the flag needed to allow the creation of simd clones from omp declare variants, such that we can use -fopenmp-simd rather than -fopenmp. This should only change the behaviour of omp simd clones and should not enable any other openmp functionality, though I need to test this furter, for the time being I just played around a bit with some of the existing declare-variant tests. Any objections to this in general? And/or ideas to properly test the effect of this on other omp codegen? My current plan is to have a look at the declare-variant tests we had before this patch series, locally modify them to pass -fopenmp-simd and make sure they fail the same way before and after this patch. diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 21bc3167ce224823c214efc064be399f2da9c787..b28e3d0a8adb520941dc3a17173cc07de4a653c5 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -23564,6 +23564,13 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context) c_parser_omp_declare_reduction (parser, context); return false; } + if (strcmp (p, "variant") == 0) + { + /* c_parser_consume_token (parser); done in + c_parser_omp_declare_simd. */ + c_parser_omp_declare_simd (parser, context); + return true; + } if (!flag_openmp) /* flag_openmp_simd */ { c_parser_skip_to_pragma_eol (parser, false); @@ -23575,13 +23582,6 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context) c_parser_omp_declare_target (parser); return false; } - if (strcmp (p, "variant") == 0) - { - /* c_parser_consume_token (parser); done in - c_parser_omp_declare_simd. */ - c_parser_omp_declare_simd (parser, context); - return true; - } } c_parser_error (parser, "expected %, %, " diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 1aa5f1a7898df9483a2af4f6f9fea99e6b219271..7bd32fd3e345a003be03d1e9acf33db76eed9460 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -8428,7 +8428,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, suppress_warning (decl, OPT_Winit_self); } - if (flag_openmp + if (flag_openmp_simd && TREE_CODE (decl) == FUNCTION_DECL /* #pragma omp declare variant on methods handled in finish_struct instead. */ diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 1a124f5395e018f3c4b2f9f36fcd42159d0b868f..d1c7f9d91d2546ad8f5674232a05f7d7726eeafe 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -47884,7 +47884,7 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok, context, false); return true; } - if (flag_openmp && strcmp (p, "variant") == 0) + if (strcmp (p, "variant") == 0) { cp_lexer_consume_token (parser->lexer); cp_parser_omp_declare_simd (parser, pragma_tok, diff --git a/gcc/testsuite/gcc.target/aarch64/declare-variant-1.c b/gcc/testsuite/gcc.target/aarch64/declare-variant-1.c index c44c9464f4e27047db9be5b0c9710ae3cfee8eee..83eeadd108b5578623c63e73dea11b2b17a08618 100644 --- a/gcc/testsuite/gcc.target/aarch64/declare-variant-1.c +++ b/gcc/testsuite/gcc.target/aarch64/declare-variant-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fopenmp" } */ +/* { dg-options "-O3 -fopenmp-simd" } */ #include "declare-variant-1.x" diff --git a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-1.c b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-1.c index 7a8129fe88ac9759b2337892a3d14f4e8196e61f..616b0ed1c1dc019103dae504d2cec65523a35a3d 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fopenmp" } */ +/* { dg-options "-O3 -fopenmp-simd" } */ #include "../declare-variant-1.x" diff --git a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-2.c b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-2.c index 2b6eabac76cf1cd059ec8d960ddd9e30973dc797..a832c5255306999b0006b68b1890c7f42c3dafb0 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fopenmp -msve-vector-bits=128" } */ +/* { dg-options "-O3 -fopenmp-simd -msve-vector-bits=128" } */ #include "../declare-variant-1.x" diff --git a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-3.c b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-3.c index e8b598fe479d7e1e92eb7f9e3413d5ac183626a9..455c0338d4680d143daae666c29e4f018df5bff9 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-3.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/declare-variant-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fopenmp -msve-vector-bits=256" } */ +/* { dg-options "-O3 -fopenmp-simd -msve-vector-bits=256" } */ #include "../declare-variant-1.x"