From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27161 invoked by alias); 19 Mar 2015 14:50:04 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 27144 invoked by uid 89); 19 Mar 2015 14:50:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ig0-f177.google.com Received: from mail-ig0-f177.google.com (HELO mail-ig0-f177.google.com) (209.85.213.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 19 Mar 2015 14:50:02 +0000 Received: by igbqf9 with SMTP id qf9so25128013igb.1 for ; Thu, 19 Mar 2015 07:50:00 -0700 (PDT) X-Received: by 10.107.134.9 with SMTP id i9mr103257191iod.90.1426776600716; Thu, 19 Mar 2015 07:50:00 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.40]) by mx.google.com with ESMTPSA id 5sm4192633igr.17.2015.03.19.07.49.57 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 07:49:59 -0700 (PDT) Date: Thu, 19 Mar 2015 14:50:00 -0000 From: Ilya Verbin To: Jakub Jelinek Cc: gcc@gcc.gnu.org, Kirill Yukhin Subject: Re: [gomp4] Questions about "declare target" and "target update" pragmas Message-ID: <20150319144947.GA20881@msticlxl57.ims.intel.com> References: <20140122155151.GA50489@msticlxl57.ims.intel.com> <20150310165252.GC37666@msticlxl57.ims.intel.com> <20150316184153.GA42550@msticlxl57.ims.intel.com> <20150319134744.GW1746@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150319134744.GW1746@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00234.txt.bz2 On Thu, Mar 19, 2015 at 14:47:44 +0100, Jakub Jelinek wrote: > Here is untested patch. I'm going to check it in after bootstrap/regtest. Thanks. > > I am investigating run-fails on some benchmark, and have found a second > > questionable place, where a function argument overrides a global array. > > Just to be sure, is this a bug in the test? > > > > #pragma omp declare target > > int a1[50], a2[50]; > > #pragma omp end declare target > > > > void foo (int a1[]) > > { > > #pragma omp target > > { > > a1[10]++; > > a2[10]++; > > } > > } > > That is a buggy test. int a1[] function argument is changed > into int *a1, so it is actually > #pragma omp target map(tofrom:a1, a2) Actually, it copies only a1 pointer, since a2 points to the global array. > { > a1[10]++; > a2[10]++; > } > which copies the a1 pointer to the device by value (no pointer > transformation). > Perhaps the testcase writer meant to use #pragma omp target map(a1[10]) > instead (or map(a1[0:50])? If I understand correctly, it's not allowed to map global target arrays this way, since it's already present in the initial device data environment: 2.9.4 declare target Directive If a list item is a variable then the original variable is mapped to a corresponding variable in the initial device data environment for all devices. 2.14.5 map Clause If a corresponding list item of the original list item is in the enclosing device data environment, the new device data environment uses the corresponding list item from the enclosing device data environment. No additional storage is allocated in the new device data environment and neither initialization nor assignment is performed, regardless of the map-type that is specified. So, to fix this testcase I can just remove the "int a1[]" function argument, and add some "#pragma omp target update" where needed. -- Ilya