From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 664E53858C20; Thu, 10 Mar 2022 14:27:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 664E53858C20 From: "cltang at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104696] [OpenMP] Implicit mapping breaks struct mapping Date: Thu, 10 Mar 2022 14:27:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization, openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cltang at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2022 14:27:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104696 --- Comment #3 from Chung-Lin Tang --- The problem, at a low-level, is that the Fortran FE is using always_pointer, while C/C++ front-ends generate attach_detach (and turns in attach after gimplify). attach and always_pointer both modify the GPU-side field into the correct G= PU pointer, but only attach will "clean-up" at the end, restoring the host-side pointer contents, before the full implicit struct mapping copies back to the host (due to tofrom map-kind). Since Fortran array descriptors are like little structs, I think quickest f= ix is to make the Fortran FE use 'attach_detach' for the array data pointer fi= eld. That should immediately make things work. A more elaborate way is to try to turn off the creation of the implicit map= ping for the whole array descriptor, which should be a killer of performance. (n= ot sure when this started, although prior changes did put implicit mappings to= the very front of the sequence)=