From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 561973858C01 for ; Wed, 23 Aug 2023 11:41:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 561973858C01 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.01,195,1684828800"; d="scan'208";a="17117018" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 23 Aug 2023 03:41:17 -0800 IronPort-SDR: tzZ+A1jFqSAuzOQ+BHEl8z7IgoSDn9DuRlRMxpyW5usuYENOFEXFWulV236IZctJLaD9M+jlcX M+ztg4r0RS4GMxFkJtydkiUd+eNnWx1ceLz1rbQ0Yvsb3Q7nbgfTKxLTDd9JlgSrBEbewIsSvG BMGadXn5cdPeOXTloTHnYp6Zo5jH0o8nDFYDwCGgEkLV6OMp/z9d1G5IzbPVdW1TFgq1Bsc1ML eNIJTwvoA93j/AzHHALTqD5fPCA6mE9CNDbcDL550OZxW1Qt7RLwrmOaM+Nc0Lh+T9mTyhfZ5q tUc= Message-ID: <9cace080-44e8-6cbd-df7e-6fcbc02bee33@codesourcery.com> Date: Wed, 23 Aug 2023 13:41:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: Help with fortran pointer ans OpenACC Content-Language: en-US To: Patrick Begou , References: <1c45183d-cd8f-8672-d9b1-95a59314c51b@univ-grenoble-alpes.fr> From: Tobias Burnus In-Reply-To: <1c45183d-cd8f-8672-d9b1-95a59314c51b@univ-grenoble-alpes.fr> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable 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=-6.7 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,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 List-Id: Hi, On 23.08.23 12:19, Patrick Begou via Fortran wrote: > For several days I have some trouble with OpenACC offloading and > fortran pointers. I'm testing with a very small peace of code to > investigate but I do not progress for several days and I need your help. > > Could someone give me advices or a small explanation on what I have > not understood there ? First, for debugging, using -fdump-tree-original -fdump-tree-gimple -fdump-tree-omplower and looking at the file .* might help - grep for '#pragma'; this shows the internal representation (incomplete) in a C like output. That's how I spotted the issue below. * * * For gfortran, the issue is: !$acc parallel loop collapse(2) default(present) if(runongpu) It works if you add a "present(current)" =E2=86=92 see also newly filed https://gcc.gnu.org/PR111116 gfortran seems to follow - but not completely - the spec: Quoting from OpenACC 3.2: "2.6.2 Variables with Implicitly Determined Data Attributes": "A scalar variable will be treated as if it appears either: * In a copy clause if the compute construct is a kernels construct. * In a firstprivate clause otherwise. Note: Any default(none) clause visible at the compute construct applies to both aggregate and scalar variables. However, any default(present) clause visible at the compute construct applies only to aggregate variables." However, the glossary defines: "Aggregate variables =E2=80=93 a variable of any non-scalar datatype, inclu= ding array or composite variables. In Fortran, this includes any variable with allocatable or pointer attribute and character variables." And, as you have a (scalar) Fortran pointer, the following should have applied instead: "An aggregate variable will be treated as if it appears either: =E2=80=A2 In a present clause if there is a default(present) clause visible= at the compute construct. =E2=80=A2 In a copy clause otherwise." * * * Thus: It looks as if your program is valid, adding 'present(current)' will fix it for gfortran (and Cray?), 'default(...)' and implicit mapping is confusing, and there is now a gfortran PR to track this issue: https://gcc.gnu.org/PR111116 Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955