From patchwork Mon Jun 28 17:13:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1498082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GDDjS4kMRz9s24 for ; Tue, 29 Jun 2021 03:14:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7465F39C053F for ; Mon, 28 Jun 2021 17:14:01 +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 2275D39BF4A5; Mon, 28 Jun 2021 17:13:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2275D39BF4A5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: Ydyi+McuR9c98dB1iYOnxuUltQjvpu6kfcV3BRF147Ap1eYdNo60rEKnEx8bOB8UvSldGT8A7i R8G56ZUw7T/nSgxz/3L5URxxrjZBVsU9YQkhAYwC0CZGDDGCDu3oxQ1GZhTiPFb1qbwYeeR5gl jkU/7JZGPyoK/gE1jFkrI77dO4MB/zQJMJwu5tBDYILngWKxcNGTpwm7DeZirmD22FuBPYJ24Q VJkGKGEEXnDbPNzjhG/OUkDgH6mWjLPu0nddsSxHKno8HJENuBCM6+PS8NZNTEjmq83+tJ5h2s kdA= X-IronPort-AV: E=Sophos;i="5.83,306,1616486400"; d="diff'?scan'208";a="62920866" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 28 Jun 2021 09:13:26 -0800 IronPort-SDR: x30s2W+8wtrej66WtKeYXHqczXU1ca1oAbVsNZOvviXjl/SqaXil9VvqRYjDQJXHCmlmimuyfZ NDQJEJEll48RXukdcg4Pg9Oq8nGCeo3F/AJDnaz8OgzNbJf0Y2xef1EmxC8tegZT6AsWM/nsyA qWrElX1E8/AWYEppabyXbN9ldTshyY0G6TtPdETZIPZhRP5415qNEmcPCDZntpPhtpATZ9NnVR KbAZAeUlsNWL6cO2x/pHBzH2mxXwvASzoOvaj3XICbClzgwlT2x8H7QFiKl/BT+l7OYx+SG1x6 obU= From: Tobias Burnus Subject: libgomp.fortran/defaultmap-8.f90: Fix non-shared memory handling To: gcc-patches , fortran , Jakub Jelinek Message-ID: <09158a64-bd30-6845-9f55-5e8bf61822a4@codesourcery.com> Date: Mon, 28 Jun 2021 19:13:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SCC_5_SHORT_WORD_LINES, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The following runs into the problem that the pointer is privatized but not the pointer target (in the C sense, i.e. it affects both allocatables and pointers in Fortran). Thus, when running it with non-shared memory offloading, the pointer shows to an invalid address. I think the fix is obvious (albeit unfortunate). (Tested on x86-64 with -foffload=nvptx-none and -foffload=disable.) Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf libgomp.fortran/defaultmap-8.f90: Fix non-shared memory handling Disable some more parts of the test as firstprivate does not work yet due to PR fortran/90742. libgomp/ * testsuite/libgomp.fortran/defaultmap-8.f90 (bar): Determine whether target has shared memory and disable some scalar pointer/allocatable checks if not as firstprivate does not work. diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 index ddf5057..54f4b2e 100644 --- a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 +++ b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 @@ -205,6 +205,7 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) pointer :: ep1, ep2, ep3 target :: eat1, eat2, eat3, et1, et2, et3 optional :: ea1, ep1, eat1, et1, ei1 + logical :: shared_memory allocate(ea3, eat3, ep3) @@ -212,19 +213,28 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) eat1 = 2; eat2 = 2; eat3 = 2; et1 = 2; et2 = 2; et3 = 2 ei1 = 2; ei2 = 2; ei3 = 2 + shared_memory = .false. + !$omp target map(to: shared_memory) + shared_memory = .true. + !$omp end target + ! While here 'scalar' implies nonallocatable/nonpointer and ! the target attribute plays no role. !$omp target defaultmap(tofrom:scalar) defaultmap(firstprivate:allocatable) & - !$omp& defaultmap(none:aggregate) defaultmap(firstprivate:pointer) - if (ea1 /= 2) stop 91 - if (ea2 /= 2) stop 92 - if (ea3 /= 2) stop 93 - if (ep1 /= 2) stop 94 - if (ep2 /= 2) stop 95 - if (ep3 /= 2) stop 96 - if (eat1 /= 2) stop 97 - if (eat2 /= 2) stop 98 - if (eat3 /= 2) stop 99 + !$omp& defaultmap(none:aggregate) defaultmap(firstprivate:pointer) & + !$omp& map(always, to: shared_memory) + if (shared_memory) then + ! Due to fortran/90742 this fails when doing non-shared memory offloading + if (ea1 /= 2) stop 91 + if (ea2 /= 2) stop 92 + if (ea3 /= 2) stop 93 + if (ep1 /= 2) stop 94 + if (ep2 /= 2) stop 95 + if (ep3 /= 2) stop 96 + if (eat1 /= 2) stop 97 + if (eat2 /= 2) stop 98 + if (eat3 /= 2) stop 99 + end if if (et1 /= 2) stop 100 if (et2 /= 2) stop 101 if (et3 /= 2) stop 102 @@ -232,8 +242,11 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) if (ei2 /= 2) stop 104 if (ei3 /= 2) stop 105 ep1 => null(); ep2 => null(); ep3 => null() - ea1 = 1; ea2 = 1; ea3 = 1 - eat1 = 1; eat2 = 1; eat3 = 1 + if (shared_memory) then + ! Due to fortran/90742 this fails when doing non-shared memory offloading + ea1 = 1; ea2 = 1; ea3 = 1 + eat1 = 1; eat2 = 1; eat3 = 1 + end if et1 = 1; et2 = 1; et3 = 1 ei1 = 1; ei2 = 1; ei3 = 1 !$omp end target