From patchwork Sat Jul 20 20:42:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 57249 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 276C23861030 for ; Sat, 20 Jul 2024 20:43:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id 1F1123858D20 for ; Sat, 20 Jul 2024 20:42:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F1123858D20 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 1F1123858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721508163; cv=none; b=dK1FpbJFkobJWuJla1EehbHGucYlHX8uvGIs0l4r6k1QSxywa1ZArc2j6t/OmuqYuyJBuvCkPsOQwPTNdk8B0RvO2MJjDmxceZsK3jiv37x2CtI190Js98+SrU5o5UATtbUlUIwNJHeGftPQlpo+hrG7El32ZqPSjajwkin0trA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721508163; c=relaxed/simple; bh=J2kCfN61B8KjtMp+c7uUMoJpfIrIzEHzpDCA01cwnek=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=BN4GWzKhKIjn7Lj3cUoxokXR+q33lPQ0v2VBksnQ27WNUNbNdAXiX6kzLYHo6NnFi36sCOU+JLMmv/vOfsUrplvMFr7qWAuIn8+rGmM79Gcvqs1JFQvPsXBd0Z8f1lX/QiNHhD6C6qA3DN9rHeZvzXTGxu9asByADFEOAP5vN8k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7fb93b2e2a3so118876839f.1 for ; Sat, 20 Jul 2024 13:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721508159; x=1722112959; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hgKlzfs64CJ04prV0b2iHAbsrpjEBk/eqNQTAdjP7lk=; b=a+wQ9eWjQuL4q6A0YFe/dAxBCBCRavZTfRDHIcmFuH8ZVtLfA9Kvg+BLzlKfCWo0pS Zwz+5zZ8ZnGcTY4cbuEguqwYHeXmEC2omWCfAetSec8C6Vp5Pp/NrNYlBJ8sJa0Vt2GW RYHTVLbfdoFCnRw4HtOdVmk1bz4Wub8+tTFUNNCipYVMe0Fbd+vO44qw8tVgygG8q70t 7t4SaUYuPGSxv6rE3vXUAPvaYJUnYU6A00nEP6nV7GPaeIDZOl3x3vheG2ZCIn1TlJah WJFQHiCurALVYAP+IRcWlgb+hKxP/4f+0fX1DQKVdrVeAKWLBR+R1obzyyMsofmoV75j gS0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721508159; x=1722112959; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hgKlzfs64CJ04prV0b2iHAbsrpjEBk/eqNQTAdjP7lk=; b=ZIqriKt/ge7++TKxcGXRpkjBS8ycej1QgXScNNGfHAkyQjRjLoi6KSXIpD1350ajKq PTGyW2pI8PkafMTeNhHN5//zXMEoU0F5tvs60OaJr/rWtQhCPSXfPkbNCcH65cIIa0N/ 8izEsX1apHrmXIxyWb6m9CTLpbRgOl9yLZhEspzLxHPUiMClYQCCkfwoBYSlGJcwZkeR NkZ+gLMjdT3eyE9emRJ5Jzbj6Xbm5IxIf9eK6x2rw6J0kw2dpHM1EzINtME/TUPf74Yy /T6Qt4D7Syz+acCojYdF+F9pqfAVeBCXYzOb4qOqNdmM55KTFEaIeiwvOA/vX8yihI7m NG8g== X-Gm-Message-State: AOJu0YyLVkx5rRxibyvkFUjP12Lcitye3A0/3OHmgte+soSDZQpO9zba sk2e1gTxcPsPdA13xgKmMqgeFvM1035s0VD85NLExMRz4i2Zd53XzrKefKvOI8GXPJEEFWp9u3q +IN8= X-Google-Smtp-Source: AGHT+IF1WIuNJC9mdEuCLYEjIproHem+BeHoeKSlDWH6nRL/2OGoDdLAUNc/x1c55Lf6thVTxGT6UQ== X-Received: by 2002:a92:c244:0:b0:396:55ff:f57e with SMTP id e9e14a558f8ab-3993ffd58a2mr31299725ab.22.1721508158759; Sat, 20 Jul 2024 13:42:38 -0700 (PDT) Received: from pondscum.hsd1.co.comcast.net ([2601:281:d901:5620:ee50:43b7:d7db:ddf2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-397f5c2b74esm13133105ab.35.2024.07.20.13.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jul 2024 13:42:38 -0700 (PDT) From: Sandra Loosemore To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, tburnus@baylibre.com Subject: [PATCH v3 00/12] Metadirective support + "declare variant" improvements Date: Sat, 20 Jul 2024 14:42:19 -0600 Message-Id: <20240720204231.2229891-1-sloosemore@baylibre.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, KAM_SHORT, 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~patchwork=sourceware.org@gcc.gnu.org This is a revised version of the patch set I last posted in late May: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653066.html Aside from rebasing the patch set so it applies cleanly to mainline head again, I incorporated a few small code cleanups and testsuite fixes I'd collected, plus a few more substantive improvements: - I changed the metadirective pretty-printers to use "otherwise" instead of the now-deprecated "default" clause, as Tobias suggested in his review of the previous version of part 1, and made corresponding tweaks to the test cases that were examining the dump output. - I also re-did the device_num support for the target_device selector along the lines suggested by Tobias (simplifying the libgomp support and adding a conditional to the generated code), and added a new testcase for that. - When I was working on something else I observed that the C front end now has support for attribute-syntax directives; when I originally implemented that for metadirectives on the OG13 branch about a year ago, only C++ had general support for attribute syntax. My C++ testcases failed to "just work" in C because the lookahead save/restore mechanism for attribute directives collided with the token caching used by metadirective for parsing the body. So I fixed that, now the testcases work in both languages. Also note the lists of improvements and bug fixes for previous versions of the patch set, which I won't duplicate here. I realize this is a large and complicated patch set with many dependencies between the pieces (and I have another layer on top of this in the works to support "begin declare variant"). If the maintainers would find it easier to review if I refactored the pieces in some other way, please let me know what would help to expedite the process. I'd really like to get these patches in somehow or another, so I don't have to continue to spend so much time maintaining them out of tree. :-S -Sandra Sandra Loosemore (12): OpenMP: metadirective tree data structures and front-end interfaces OpenMP: middle-end support for metadirectives libgomp: runtime support for target_device selector OpenMP: C front end support for metadirectives OpenMP: C++ front-end support for metadirectives OpenMP: common c/c++ testcases for metadirectives OpenMP: Fortran front-end support for metadirectives. OpenMP: Reject other properties with kind(any) OpenMP: Extend dynamic selector support to declare variant OpenMP: Remove dead code from declare variant reimplementation OpenMP: Update "declare target"/OpenMP context interaction OpenMP: Update documentation of metadirective implementation status. gcc/Makefile.in | 2 +- gcc/builtin-types.def | 2 + gcc/c-family/c-attribs.cc | 2 - gcc/c-family/c-common.h | 4 +- gcc/c-family/c-gimplify.cc | 27 + gcc/c-family/c-omp.cc | 60 +- gcc/c-family/c-pragma.cc | 1 + gcc/c-family/c-pragma.h | 1 + gcc/c/c-decl.cc | 8 +- gcc/c/c-parser.cc | 508 +++- gcc/cgraph.cc | 2 - gcc/cgraph.h | 12 +- gcc/cgraphclones.cc | 2 +- gcc/cp/cp-tree.h | 2 + gcc/cp/decl.cc | 2 +- gcc/cp/decl2.cc | 9 +- gcc/cp/parser.cc | 526 ++++- gcc/cp/parser.h | 7 + gcc/cp/pt.cc | 120 + gcc/cp/semantics.cc | 3 +- gcc/doc/generic.texi | 32 + gcc/doc/gimple.texi | 6 + gcc/fortran/decl.cc | 29 + gcc/fortran/dump-parse-tree.cc | 21 + gcc/fortran/gfortran.h | 21 +- gcc/fortran/io.cc | 2 +- gcc/fortran/match.h | 2 + gcc/fortran/openmp.cc | 294 ++- gcc/fortran/parse.cc | 578 +++-- gcc/fortran/parse.h | 8 +- gcc/fortran/resolve.cc | 6 + gcc/fortran/st.cc | 4 + gcc/fortran/symbol.cc | 25 +- gcc/fortran/trans-decl.cc | 5 +- gcc/fortran/trans-openmp.cc | 238 +- gcc/fortran/trans-stmt.h | 1 + gcc/fortran/trans.cc | 1 + gcc/fortran/types.def | 2 + gcc/gimple-low.cc | 36 + gcc/gimple-pretty-print.cc | 78 + gcc/gimple-streamer-in.cc | 13 + gcc/gimple-streamer-out.cc | 10 + gcc/gimple-walk.cc | 28 + gcc/gimple.cc | 36 + gcc/gimple.def | 8 + gcc/gimple.h | 122 +- gcc/gimplify.cc | 574 +++-- gcc/gimplify.h | 2 +- gcc/gsstruct.def | 2 + gcc/ipa-free-lang-data.cc | 2 +- gcc/ipa.cc | 3 - gcc/lto-cgraph.cc | 12 +- gcc/lto-streamer-out.cc | 3 +- gcc/lto-streamer.h | 6 - gcc/lto/lto-partition.cc | 5 +- gcc/omp-builtins.def | 3 + gcc/omp-expand.cc | 32 +- gcc/omp-general.cc | 2043 +++++++++-------- gcc/omp-general.h | 50 +- gcc/omp-low.cc | 83 + gcc/omp-offload.cc | 117 +- gcc/omp-simd-clone.cc | 3 +- gcc/passes.cc | 3 +- gcc/symtab.cc | 2 +- .../c-c++-common/gomp/attrs-metadirective-1.c | 41 + .../c-c++-common/gomp/attrs-metadirective-2.c | 75 + .../c-c++-common/gomp/attrs-metadirective-3.c | 23 + .../c-c++-common/gomp/attrs-metadirective-4.c | 41 + .../c-c++-common/gomp/attrs-metadirective-5.c | 25 + .../c-c++-common/gomp/attrs-metadirective-6.c | 32 + .../c-c++-common/gomp/attrs-metadirective-7.c | 32 + .../c-c++-common/gomp/attrs-metadirective-8.c | 17 + .../gomp/declare-target-indirect-2.c | 10 +- .../c-c++-common/gomp/declare-variant-10.c | 4 +- .../c-c++-common/gomp/declare-variant-12.c | 14 +- .../c-c++-common/gomp/declare-variant-13.c | 6 +- .../c-c++-common/gomp/declare-variant-2.c | 4 +- .../c-c++-common/gomp/declare-variant-3.c | 10 +- .../c-c++-common/gomp/declare-variant-8.c | 4 +- .../c-c++-common/gomp/declare-variant-9.c | 4 +- .../c-c++-common/gomp/declare-variant-any.c | 10 + .../gomp/declare-variant-arg-exprs.c | 29 + .../gomp/declare-variant-dynamic-1.c | 26 + .../gomp/declare-variant-dynamic-2.c | 30 + .../c-c++-common/gomp/metadirective-1.c | 52 + .../c-c++-common/gomp/metadirective-2.c | 74 + .../c-c++-common/gomp/metadirective-3.c | 22 + .../c-c++-common/gomp/metadirective-4.c | 40 + .../c-c++-common/gomp/metadirective-5.c | 24 + .../c-c++-common/gomp/metadirective-6.c | 31 + .../c-c++-common/gomp/metadirective-7.c | 31 + .../c-c++-common/gomp/metadirective-8.c | 16 + .../gomp/metadirective-construct.c | 177 ++ .../c-c++-common/gomp/metadirective-device.c | 147 ++ .../gomp/metadirective-no-score.c | 95 + .../gomp/metadirective-target-device.c | 147 ++ .../c-c++-common/gomp/reverse-offload-1.c | 2 +- .../g++.dg/gomp/declare-variant-class-1.C | 32 + .../g++.dg/gomp/declare-variant-class-2.C | 37 + gcc/testsuite/gcc.dg/gomp/metadirective-1.c | 15 + .../gfortran.dg/gomp/declare-variant-10.f90 | 4 +- .../gfortran.dg/gomp/declare-variant-12.f90 | 14 +- .../gfortran.dg/gomp/declare-variant-13.f90 | 28 +- .../gfortran.dg/gomp/declare-variant-3.f90 | 12 +- .../gfortran.dg/gomp/declare-variant-8.f90 | 12 +- .../gfortran.dg/gomp/declare-variant-9.f90 | 2 +- .../gfortran.dg/gomp/declare-variant-any.f90 | 28 + .../gfortran.dg/gomp/metadirective-1.f90 | 73 + .../gfortran.dg/gomp/metadirective-10.f90 | 40 + .../gfortran.dg/gomp/metadirective-11.f90 | 33 + .../gfortran.dg/gomp/metadirective-2.f90 | 62 + .../gfortran.dg/gomp/metadirective-3.f90 | 25 + .../gfortran.dg/gomp/metadirective-4.f90 | 39 + .../gfortran.dg/gomp/metadirective-5.f90 | 30 + .../gfortran.dg/gomp/metadirective-6.f90 | 31 + .../gfortran.dg/gomp/metadirective-7.f90 | 36 + .../gfortran.dg/gomp/metadirective-8.f90 | 22 + .../gfortran.dg/gomp/metadirective-9.f90 | 30 + .../gomp/metadirective-construct.f90 | 260 +++ .../gomp/metadirective-no-score.f90 | 122 + gcc/testsuite/gfortran.dg/gomp/pure-1.f90 | 7 + gcc/testsuite/gfortran.dg/gomp/pure-2.f90 | 8 - gcc/tree-cfg.cc | 24 + gcc/tree-inline.cc | 45 +- gcc/tree-nested.cc | 43 + gcc/tree-pretty-print.cc | 36 +- gcc/tree-pretty-print.h | 2 + gcc/tree-ssa-operands.cc | 17 + gcc/tree.def | 6 + gcc/tree.h | 3 + include/cuda/cuda.h | 2 + libgomp/Makefile.am | 2 +- libgomp/Makefile.in | 5 +- libgomp/config/gcn/selector.c | 102 + libgomp/config/linux/selector.c | 65 + libgomp/config/linux/x86/selector.c | 406 ++++ libgomp/config/nvptx/selector.c | 77 + libgomp/libgomp-plugin.h | 2 + libgomp/libgomp.h | 1 + libgomp/libgomp.map | 5 + libgomp/libgomp.texi | 39 +- libgomp/libgomp_g.h | 8 + libgomp/oacc-host.c | 11 + libgomp/plugin/plugin-gcn.c | 52 + libgomp/plugin/plugin-nvptx.c | 82 + libgomp/selector.c | 64 + libgomp/target.c | 22 + .../libgomp.c++/metadirective-template-1.C | 37 + .../libgomp.c++/metadirective-template-2.C | 41 + .../libgomp.c++/metadirective-template-3.C | 41 + .../libgomp.c-c++-common/metadirective-1.c | 35 + .../libgomp.c-c++-common/metadirective-2.c | 41 + .../libgomp.c-c++-common/metadirective-3.c | 34 + .../libgomp.c-c++-common/metadirective-4.c | 52 + .../libgomp.c-c++-common/metadirective-5.c | 46 + .../metadirective-target-device.c | 63 + .../libgomp.fortran/metadirective-1.f90 | 61 + .../libgomp.fortran/metadirective-2.f90 | 40 + .../libgomp.fortran/metadirective-3.f90 | 29 + .../libgomp.fortran/metadirective-4.f90 | 46 + .../libgomp.fortran/metadirective-5.f90 | 44 + .../libgomp.fortran/metadirective-6.f90 | 58 + 162 files changed, 8273 insertions(+), 1664 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-4.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-5.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-6.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-7.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-8.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-any.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-arg-exprs.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-3.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-4.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-5.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-6.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-7.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-8.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-construct.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-device.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-no-score.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-target-device.c create mode 100644 gcc/testsuite/g++.dg/gomp/declare-variant-class-1.C create mode 100644 gcc/testsuite/g++.dg/gomp/declare-variant-class-2.C create mode 100644 gcc/testsuite/gcc.dg/gomp/metadirective-1.c create mode 100644 gcc/testsuite/gfortran.dg/gomp/declare-variant-any.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90 create mode 100644 libgomp/config/gcn/selector.c create mode 100644 libgomp/config/linux/selector.c create mode 100644 libgomp/config/linux/x86/selector.c create mode 100644 libgomp/config/nvptx/selector.c create mode 100644 libgomp/selector.c create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-1.C create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-2.C create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-3.C create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-2.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-3.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-4.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-5.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-target-device.c create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-1.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-2.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-3.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-4.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-5.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-6.f90