Hi! On Tue, 17 Jun 2014 23:03:47 +0200, Jakub Jelinek <ja...@redhat.com> 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 <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> 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: --- 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", Grüße, Thomas
pgpS0L_uPkCOu.pgp
Description: PGP signature