From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60769 invoked by alias); 22 Oct 2015 19:19:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 60712 invoked by uid 89); 22 Oct 2015 19:19:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_FROM_12LTRDOM autolearn=ham version=3.3.2 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; Thu, 22 Oct 2015 19:19:49 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZpLOr-0004K8-TX from James_Norris@mentor.com ; Thu, 22 Oct 2015 12:19:45 -0700 Received: from [172.30.80.51] (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.224.2; Thu, 22 Oct 2015 12:19:45 -0700 Message-ID: <562936CF.5030200@codesourcery.com> Date: Thu, 22 Oct 2015 19:20:00 -0000 From: James Norris User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: GCC Patches CC: "Joseph S. Myers" , Nathan Sidwell , Jakub Jelinek Subject: [OpenACC 6/7] host_data construct References: <56293476.5020801@codesourcery.com> In-Reply-To: <56293476.5020801@codesourcery.com> X-TagToolbar-Keys: D20151022141943807 Content-Type: multipart/mixed; boundary="------------080001040000010106000703" X-SW-Source: 2015-10/txt/msg02338.txt.bz2 --------------080001040000010106000703 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 242 libgomp/libgomp.map b/libgomp/libgomp.map - Add new symbol GOACC_deviceptr. libgomp/oacc-mem.c b/libgomp/oacc-mem.c - Add new function GOACC_deviceptr() to handle pointer lookup for host_data regions. --------------080001040000010106000703 Content-Type: text/x-patch; name="p6.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p6.patch" Content-length: 1251 diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map index 2153661..2a43a8c 100644 --- a/libgomp/libgomp.map +++ b/libgomp/libgomp.map @@ -378,6 +378,7 @@ GOACC_2.0 { GOACC_wait; GOACC_get_thread_num; GOACC_get_num_threads; + GOACC_deviceptr; }; GOACC_2.0.1 { diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index af067d6..497ab92 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -204,6 +204,38 @@ acc_deviceptr (void *h) return d; } +/* This function is used as a helper in generated code to implement pointer + lookup in host_data regions. Unlike acc_deviceptr, it returns its argument + unchanged on a shared-memory system (e.g. the host). */ + +void * +GOACC_deviceptr (void *h) +{ + splay_tree_key n; + void *d; + void *offset; + + goacc_lazy_initialize (); + + struct goacc_thread *thr = goacc_thread (); + + if ((thr->dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) == 0) + { + n = lookup_host (thr->dev, h, 1); + + if (!n) + return NULL; + + offset = h - n->host_start; + + d = n->tgt->tgt_start + n->tgt_offset + offset; + + return d; + } + else + return h; +} + /* Return the host pointer that corresponds to device data D. Or NULL if no mapping. */ --------------080001040000010106000703--