From patchwork Wed Jul 9 20:06:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 368317 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 E6DE21400AF for ; Thu, 10 Jul 2014 06:06:45 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=WQwLeGhcoLUz4Hcw 6IrB5TO3Ndks+VJA9amDkxpZCvGaSTPcDRUiNQOcsZG9F8JVrr4BzKKALgLCa6oz Vo+ZDpnbAkEX/55yTEDlSi50GI1Z5/2AGYjLNT+gmneJt7x5ehP6JY/MlYLkW8BV hrS9y/4YJAEEDYpCUpPLQZd98/w= 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=T+JNgZejYKbUnvoEobV7QA tZkCo=; b=Jo9kqWkEyVhyeu+edGH4mCOwh/m1/RYbAE7aN1/w1WVINawXWIPeDP NwIKWBQoBpMKhQDTEvL5o+14+DdRRaGExReQ9Izp+c9y5XT3wOSrlgGbAklRFkoQ rx2okFXenUxgdIJ0SdSW8innea3JIsMiMeEXSz5rb56GG+5tUfWLM= Received: (qmail 32028 invoked by alias); 9 Jul 2014 20:06:38 -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 31942 invoked by uid 89); 9 Jul 2014 20:06:33 -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 autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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, 09 Jul 2014 20:06:30 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X4y8D-0007RJ-8h from Thomas_Schwinge@mentor.com ; Wed, 09 Jul 2014 13:06:21 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 9 Jul 2014 13:06:21 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 9 Jul 2014 21:06:19 +0100 From: Thomas Schwinge To: Jakub Jelinek CC: , Subject: Re: [PATCH] Fortran OpenMP 4.0 target support In-Reply-To: <20140617210347.GF31640@tucnak.redhat.com> References: <20140617210347.GF31640@tucnak.redhat.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Wed, 9 Jul 2014 22:06:09 +0200 Message-ID: <87r41uqoum.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 17 Jun 2014 23:03:47 +0200, Jakub Jelinek wrote: > This patch adds the target directives. > Tested both normally plus with target.c/splay-tree.c from > gomp-4_0-branch@203409 plus the attached patch against > target.c to implement the new to_pset map kind (5) and > allow handling of NULL. That patch will need to be forward > ported to whatever gomp-4_0-branch now has after this is merged > from trunk to that branch. Thanks for the target.c patch. In r212405, I have committed your patch to gomp-4_0-branch. All the new libgomp.fortran/target* tests pass with the libgomp/plugin-host.c plugin. commit fb4cfa7ef6e819fa0108ca75b52b86a5826a863f Author: tschwinge Date: Wed Jul 9 19:59:13 2014 +0000 libgomp: Support NULL mappings as well as mapping kind OMP_CLAUSE_MAP_TO_PSET. libgomp/ * target.c (gomp_map_vars, gomp_unmap_vars, gomp_update): Support NULL mappings as well as mapping kind OMP_CLAUSE_MAP_TO_PSET. Also, some code reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@212405 138bc75d-0d04-0410-961f-82ee72b054a4 That is your patch with the following folded in: Grüße, Thomas --- libgomp/target.c +++ libgomp/target.c @@ -357,10 +357,10 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, /* FIXME: Perhaps add some smarts, like if copying several adjacent fields from host to target, use some host buffer to avoid sending each var individually. */ - devicep->device_host2dev_func((void *) (tgt->tgt_start - + k->tgt_offset), - (void *) k->host_start, - k->host_end - k->host_start); + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset), + (void *) k->host_start, + k->host_end - k->host_start); break; case 4: /* POINTER */ cur_node.host_start @@ -368,11 +368,12 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, if (cur_node.host_start == (uintptr_t) NULL) { cur_node.tgt_offset = (uintptr_t) NULL; - /* FIXME: host to device copy, see above FIXME - comment. */ - memcpy ((void *) (tgt->tgt_start + k->tgt_offset), - (void *) &cur_node.tgt_offset, - sizeof (void *)); + /* Copy from host to device memory. */ + /* FIXME: see above FIXME comment. */ + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset), + (void *) &cur_node.tgt_offset, + sizeof (void *)); break; } /* Add bias to the pointer value. */ @@ -406,19 +407,18 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, cur_node.tgt_offset -= sizes[i]; /* Copy from host to device memory. */ /* FIXME: see above FIXME comment. */ - devicep->device_host2dev_func ((void *) (tgt->tgt_start - + k->tgt_offset), - (void *) &cur_node.tgt_offset, - sizeof (void *)); + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset), + (void *) &cur_node.tgt_offset, + sizeof (void *)); break; case 5: /* TO_PSET */ - /* FIXME: This is supposed to be copy from host to device - memory. Perhaps add some smarts, like if copying - several adjacent fields from host to target, use some - host buffer to avoid sending each var individually. */ - memcpy ((void *) (tgt->tgt_start + k->tgt_offset), - (void *) k->host_start, - k->host_end - k->host_start); + /* Copy from host to device memory. */ + /* FIXME: see above FIXME comment. */ + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset), + (void *) k->host_start, + (k->host_end - k->host_start)); for (j = i + 1; j < mapnum; j++) if ((kinds[j] & 7) != 4) break; @@ -435,13 +435,14 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, if (cur_node.host_start == (uintptr_t) NULL) { cur_node.tgt_offset = (uintptr_t) NULL; - /* FIXME: host to device copy, see above FIXME - comment. */ - memcpy ((void *) (tgt->tgt_start + k->tgt_offset - + ((uintptr_t) hostaddrs[j] - - k->host_start)), - (void *) &cur_node.tgt_offset, - sizeof (void *)); + /* Copy from host to device memory. */ + /* FIXME: see above FIXME comment. */ + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset + + ((uintptr_t) hostaddrs[j] + - k->host_start)), + (void *) &cur_node.tgt_offset, + sizeof (void *)); i++; continue; } @@ -475,13 +476,14 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, array section. Now subtract bias to get what we want to initialize the pointer with. */ cur_node.tgt_offset -= sizes[j]; - /* FIXME: host to device copy, see above FIXME - comment. */ - memcpy ((void *) (tgt->tgt_start + k->tgt_offset - + ((uintptr_t) hostaddrs[j] - - k->host_start)), - (void *) &cur_node.tgt_offset, - sizeof (void *)); + /* Copy from host to device memory. */ + /* FIXME: see above FIXME comment. */ + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + k->tgt_offset + + ((uintptr_t) hostaddrs[j] + - k->host_start)), + (void *) &cur_node.tgt_offset, + sizeof (void *)); i++; } break; @@ -501,10 +503,10 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, + tgt->list[i]->tgt_offset; /* Copy from host to device memory. */ /* FIXME: see above FIXME comment. */ - devicep->device_host2dev_func ((void *) (tgt->tgt_start - + i * sizeof (void *)), - (void *) &cur_node.tgt_offset, - sizeof (void *)); + devicep->device_host2dev_func + ((void *) (tgt->tgt_start + i * sizeof (void *)), + (void *) &cur_node.tgt_offset, + sizeof (void *)); } } @@ -546,10 +548,10 @@ gomp_unmap_vars (struct target_mem_desc *tgt) splay_tree_key k = tgt->list[i]; if (k->copy_from) /* Copy from device to host memory. */ - devicep->device_dev2host_func ((void *) k->host_start, - (void *) (k->tgt->tgt_start - + k->tgt_offset), - k->host_end - k->host_start); + devicep->device_dev2host_func + ((void *) k->host_start, + (void *) (k->tgt->tgt_start + k->tgt_offset), + k->host_end - k->host_start); splay_tree_remove (&devicep->dev_splay_tree, k); if (k->tgt->refcount > 1) k->tgt->refcount--; @@ -597,22 +599,22 @@ gomp_update (struct gomp_device_descr *devicep, size_t mapnum, (void *) n->host_end); if ((kinds[i] & 7) == 1) /* Copy from host to device memory. */ - devicep->device_host2dev_func ((void *) (n->tgt->tgt_start - + n->tgt_offset - + cur_node.host_start - - n->host_start), - (void *) cur_node.host_start, - cur_node.host_end - - cur_node.host_start); + devicep->device_host2dev_func + ((void *) (n->tgt->tgt_start + + n->tgt_offset + + cur_node.host_start + - n->host_start), + (void *) cur_node.host_start, + cur_node.host_end - cur_node.host_start); else if ((kinds[i] & 7) == 2) /* Copy from device to host memory. */ - devicep->device_dev2host_func ((void *) cur_node.host_start, - (void *) (n->tgt->tgt_start - + n->tgt_offset - + cur_node.host_start - - n->host_start), - cur_node.host_end - - cur_node.host_start); + devicep->device_dev2host_func + ((void *) cur_node.host_start, + (void *) (n->tgt->tgt_start + + n->tgt_offset + + cur_node.host_start + - n->host_start), + cur_node.host_end - cur_node.host_start); } else gomp_fatal ("Trying to update [%p..%p) object that is not mapped",