From patchwork Tue Mar 31 15:14:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1264799 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (unknown [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 48sCYJ3RzVz9sPJ for ; Wed, 1 Apr 2020 02:14:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 96D0B385DC04; Tue, 31 Mar 2020 15:14:41 +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 53F54385DC02 for ; Tue, 31 Mar 2020 15:14:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 53F54385DC02 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: 1atSfSlqUbPW3D7RZHMTvYcbUsC1lEVsDvO5s/HY4ANmOH1IZx1sma97RHhJ9jqvT0g0IPRqnE Y58Uzzrk+upfVcMwcQldGE4RVlC4iowksNrodrVMS4TsHvWd20eezNt+kl7A6Xi59a12Jp0qLY 0IhyxRc3SSC9Hu5e7wDW2QXOKqjU13CoQ55+EQl3/w4a50F2KZPQpazBUAConFqLguKbVyr1k/ uD9l/NsQDzCeupG9WtpP9dwcjgIqzyv6rOk8P/52oCj8Agzo98wUFyOnUeRCjy0ubiI1uOsLJf sns= X-IronPort-AV: E=Sophos;i="5.72,328,1580803200"; d="diff'?scan'208";a="47216485" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 31 Mar 2020 07:14:33 -0800 IronPort-SDR: 2WL8yK+kTdP+3rpgRqzZ7T2AYW8phBKFjzPVdUOGccTrbSOpggo6pb12mMNOTTeWy60bVcHpx9 pNHI2z/kaBZRDhUGy2M6idWiPHujqKIhBdZ7SoFrAhVZkulKkLrRoX457xr5rEpZzM1kEd6V/b ID22j90c2WTQTWQthkmlm/89GdjsnDNasO00sn+QacPJNjASmMv3QhQE1fZoAZNXxLtS3m7IAx V0YXCTYv5MgksUugib5LR1RobJvTYjhQ+lbpddaekWrfG1SGlitCqcvAcJyIrFppXwajxYx3Fb BSE= To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: =?utf-8?q?=5BPatch=5D_libgomp_=E2=80=93_fix_handling_of_=27targe?= =?utf-8?q?t_enter_data=27?= Message-ID: Date: Tue, 31 Mar 2020 17:14:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.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-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, 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@gcc.gnu.org Sender: "Gcc-patches" gomp_map_vars_internal contains: if ((kind & typemask) == GOMP_MAP_TO_PSET) { size_t j; for (j = i + 1; j < mapnum; j++) if (!GOMP_MAP_POINTER_P (get_kind (short_mapkind, kinds, j) where one accesses not only the i-th hostaddr but items following it. On the other hand, in GOMP_target_enter_exit_data one currently has: for (i = 0; i < mapnum; i++) if ((kinds[i] & 0xff) == GOMP_MAP_STRUCT) … else gomp_map_vars (devicep, 1, &hostaddrs[i], NULL, &sizes[i], &kinds[i], true, GOMP_MAP_VARS_ENTER_DATA); passing the argument one by one. I first thought to pass all non MAP_STRUCT items as block before the MAP_STRUCT, then a MAP_STRUCT and then try to group the next items. However, I could not find a difference between MAP_STRUCT and not, hence, I now decided to simply pass the data on "as is". OK for mainline? (What about older versions?) Cheers, Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter libgomp – fix handling of 'target enter data' * target.c (GOMP_target_enter_exit_data): Call gomp_map_vars with multiples args at once. * testsuite/libgomp.fortran/target-enter-data-1.f90: New. libgomp/target.c | 13 ++------ .../libgomp.fortran/target-enter-data-1.f90 | 36 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/libgomp/target.c b/libgomp/target.c index c99dd5196fa..3de85434f5d 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -2480,18 +2480,9 @@ GOMP_target_enter_exit_data (int device, size_t mapnum, void **hostaddrs, } } - size_t i; if ((flags & GOMP_TARGET_FLAG_EXIT_DATA) == 0) - for (i = 0; i < mapnum; i++) - if ((kinds[i] & 0xff) == GOMP_MAP_STRUCT) - { - gomp_map_vars (devicep, sizes[i] + 1, &hostaddrs[i], NULL, &sizes[i], - &kinds[i], true, GOMP_MAP_VARS_ENTER_DATA); - i += sizes[i]; - } - else - gomp_map_vars (devicep, 1, &hostaddrs[i], NULL, &sizes[i], &kinds[i], - true, GOMP_MAP_VARS_ENTER_DATA); + gomp_map_vars (devicep, mapnum, hostaddrs, NULL, sizes, kinds, + true, GOMP_MAP_VARS_ENTER_DATA); else gomp_exit_data (devicep, mapnum, hostaddrs, sizes, kinds); } diff --git a/libgomp/testsuite/libgomp.fortran/target-enter-data-1.f90 b/libgomp/testsuite/libgomp.fortran/target-enter-data-1.f90 new file mode 100644 index 00000000000..91dedebf0a0 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-enter-data-1.f90 @@ -0,0 +1,36 @@ +program main + implicit none + integer, allocatable, dimension(:) :: AA, BB, CC, DD + integer :: i, N = 20 + + allocate(BB(N)) + AA = [(i, i=1,N)] + + !$omp target enter data map(alloc: BB) + !$omp target enter data map(to: AA) + + !$omp target + BB = 3 * AA + !$omp end target + + !$omp target exit data map(delete: AA) + !$omp target exit data map(from: BB) + + if (any (BB /= [(3*i, i=1,N)])) stop 1 + if (any (AA /= [(i, i=1,N)])) stop 2 + + + CC = 31 * BB + DD = [(-i, i=1,N)] + + !$omp target enter data map(to: CC) map(alloc: DD) + + !$omp target + DD = 5 * CC + !$omp end target + + !$omp target exit data map(delete: CC) map(from: DD) + + if (any (CC /= [(31*3*i, i=1,N)])) stop 3 + if (any (DD /= [(31*3*5*i, i=1,N)])) stop 4 +end