From patchwork Wed Jan 13 22:43:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 567148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 746481402D2 for ; Thu, 14 Jan 2016 09:44:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qIJ4V8CI; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=chyML8mcv1aLY+0XZ V9QoOjC6AKklcP4JfbLqXJZA9ULAe4Lb3msAOT5XpWGRm/BbIHq8fUYBkgOVVmuN JTW9ajwF8zURHopOztwaVbfvsQ8Y0QxsOYjUPHCLW60lieE202BXMXqQ/OJ5k7MC efCp5iAg+TpkQWVbr+IiTADZz4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=3aLMnEFSrEVkkat5JE8edOT ioBQ=; b=qIJ4V8CIHy8ZooAsNIsgSX9rOpaZIX7/AIROgZCCyiVjqDPtQ5N8KjS GmDtzLEe+tuascoF3Tm2SBhwBNZ4hvHEJoT+y+PHYn6GFd/VwUlGabRt70b67KGC 8Xfns0CqTfFjiDLj3pUI+LzNZnnAyQfsNEg2O85ATalj4UA/0MTk= Received: (qmail 107139 invoked by alias); 13 Jan 2016 22:44:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105930 invoked by uid 89); 13 Jan 2016 22:44:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2907 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jan 2016 22:44:00 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1aJU8z-0000Jo-Je from Cesar_Philippidis@mentor.com ; Wed, 13 Jan 2016 14:43:57 -0800 Received: from [IPv6:::1] (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Wed, 13 Jan 2016 14:43:57 -0800 Subject: Re: [openacc] implicit non-scalars data mapping in kernels To: Marek Polacek References: <5696CFC1.9060004@codesourcery.com> <20160113223508.GM25528@redhat.com> CC: "gcc-patches@gcc.gnu.org" , Nathan Sidwell , Jakub Jelinek From: Cesar Philippidis Message-ID: <5696D32D.1080906@codesourcery.com> Date: Wed, 13 Jan 2016 14:43:57 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20160113223508.GM25528@redhat.com> On 01/13/2016 02:35 PM, Marek Polacek wrote: > On Wed, Jan 13, 2016 at 02:29:21PM -0800, Cesar Philippidis wrote: >> --- a/gcc/gimplify.c >> +++ b/gcc/gimplify.c >> @@ -5994,6 +5994,11 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) >> { >> const char *rkind; >> bool on_device = false; >> + tree type = TREE_TYPE (decl); >> + >> + if (TREE_CODE (type) == REFERENCE_TYPE >> + || POINTER_TYPE_P (type)) > > I think this should be just POINTER_TYPE_P--this macro checks for > REFERENCE_TYPE as well. You're right. Thanks for catching that. Is this patch ok for trunk after I regtest it? Cesar 2016-01-13 Cesar Philippidis gcc/ * gimplify.c (oacc_default_clause): Decode reference and pointer types for both kernels and parallel regions. libgomp/ * testsuite/libgomp.oacc-fortran/kernels-data.f90: New test. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 17144d1..5e444a9 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -5994,6 +5994,10 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) { const char *rkind; bool on_device = false; + tree type = TREE_TYPE (decl); + + if (POINTER_TYPE_P (type)) + type = TREE_TYPE (type); if ((ctx->region_type & (ORT_ACC_PARALLEL | ORT_ACC_KERNELS)) != 0 && is_global_var (decl) @@ -6012,7 +6016,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) /* Scalars are default 'copy' under kernels, non-scalars are default 'present_or_copy'. */ flags |= GOVD_MAP; - if (!AGGREGATE_TYPE_P (TREE_TYPE (decl))) + if (!AGGREGATE_TYPE_P (type)) flags |= GOVD_MAP_FORCE; rkind = "kernels"; @@ -6020,12 +6024,6 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) case ORT_ACC_PARALLEL: { - tree type = TREE_TYPE (decl); - - if (TREE_CODE (type) == REFERENCE_TYPE - || POINTER_TYPE_P (type)) - type = TREE_TYPE (type); - if (on_device || AGGREGATE_TYPE_P (type)) /* Aggregates default to 'present_or_copy'. */ flags |= GOVD_MAP; diff --git a/libgomp/testsuite/libgomp.oacc-fortran/kernels-data.f90 b/libgomp/testsuite/libgomp.oacc-fortran/kernels-data.f90 new file mode 100644 index 0000000..bf812b6 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-data.f90 @@ -0,0 +1,30 @@ +! Ensure that a non-scalar dummy argument which is implicitly used in a +! kernels regions is properly mapped using present_or_copy. + +! { dg-do run } + +program main + implicit none + + integer, parameter :: n = 100 + integer :: array(n), i + + !$acc data copy(array) + call data(array, n) + !$acc end data + + do i = 1, n + if (array(i) .ne. i) call abort + end do +end program main + +subroutine data (array, n) + integer, dimension (n) :: array + integer :: n, i + + !$acc kernels + do i = 1, n + array(i) = i + end do + !$acc end kernels +end subroutine data