On Tue, Jun 19, 2018 at 10:01:20AM -0700, Cesar Philippidis wrote: > This patch implements the OpenACC 2.5 data clause semantics in libgomp. > > Is it OK for trunk?
> 2018-06-19 Chung-Lin Tang <clt...@codesourcery.com> > Thomas Schwinge <tho...@codesourcery.com> > Cesar Philippidis <ce...@codesourcery.com> > > libgomp/ > * libgomp.h (struct splay_tree_key_s): Add dynamic_refcount member. > (gomp_acc_remove_pointer): Update declaration. > (gomp_acc_declare_allocate): Declare. > (gomp_remove_var): Declare. > * libgomp.map (OACC_2.5): Define. > * oacc-mem.c (acc_map_data): Update refcount. > (acc_unmap_data): Likewise. > (present_create_copy): Likewise. > (acc_create): Add FLAG_PRESENT when calling present_create_copy. > (acc_copyin): Likewise. > (FLAG_FINALIZE): Define. > (delete_copyout): Update dynamic refcounts, add support for FINALIZE. > (acc_delete_finalize): New function. > (acc_delete_finalize_async): New function. > (acc_copyout_finalize): New function. > (acc_copyout_finalize_async): New function. > (gomp_acc_insert_pointer): Update refcounts. > (gomp_acc_remove_pointer): Return if data is not present on the > accelerator. > * oacc-parallel.c (find_pset): Rename to find_pointer. > (find_pointer): Add support for GOMP_MAP_POINTER. > (handle_ftn_pointers): New function. > (GOACC_parallel_keyed): Update refcounts of variables. > (GOACC_enter_exit_data): Add support for finalized data mappings. > Add support for GOMP_MAP_{TO,ALLOC,RELESE,FROM}. Update handling > of fortran arrays. > (GOACC_update): Add support for GOMP_MAP_{ALWAYS_POINTER,TO,FROM}. > (GOACC_declare): Add support for GOMP_MAP_RELEASE, remove support > for GOMP_MAP_FORCE_FROM. > * openacc.f90 (module openacc_internal): Add > acc_copyout_finalize_{32_h,64_h,array_h,_l}, and > acc_delete_finalize_{32_h,64_h,array_h,_l}. Add interfaces for > acc_copyout_finalize and acc_delete_finalize. > (acc_copyout_finalize_32_h): New subroutine. > (acc_copyout_finalize_64_h): New subroutine. > (acc_copyout_finalize_array_h): New subroutine. > (acc_delete_finalize_32_h): New subroutine. > (acc_delete_finalize_64_h): New subroutine. > (acc_delete_finalize_array_h): New subroutine. > * openacc.h (acc_copyout_finalize): Declare. > (acc_copyout_finalize_async): Declare. > (acc_delete_finalize): Declare. > (acc_delete_finalize_async): Declare. > * openacc_lib.h (acc_copyout_finalize): New interface. > (acc_delete_finalize): New interface. > * target.c (gomp_map_vars): Update dynamic_refcount. > (gomp_remove_var): New function. > (gomp_unmap_vars): Use it. > (gomp_unload_image_from_device): Likewise. > > > >From 53ee03231c5e6e4747b4ef01335079a2d4a98480 Mon Sep 17 00:00:00 2001 > From: Cesar Philippidis <ce...@codesourcery.com> > Date: Tue, 19 Jun 2018 09:33:04 -0700 > Subject: [PATCH 7/7] runtime changes > > --- > libgomp/libgomp.h | 7 +- > libgomp/libgomp.map | 12 +++ > libgomp/oacc-mem.c | 196 ++++++++++++++++++++++++++++++++------- > libgomp/oacc-parallel.c | 198 ++++++++++++++++++++++++++++++++++------ > libgomp/openacc.f90 | 112 +++++++++++++++++++++++ > libgomp/openacc.h | 6 ++ > libgomp/openacc_lib.h | 40 ++++++++ > libgomp/target.c | 41 ++++----- > 8 files changed, 528 insertions(+), 84 deletions(-) > > diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h > index 10ea8940c96..3a8cc2bd7d6 100644 > --- a/libgomp/libgomp.h > +++ b/libgomp/libgomp.h > @@ -853,6 +853,8 @@ struct splay_tree_key_s { > uintptr_t tgt_offset; > /* Reference count. */ > uintptr_t refcount; > + /* Dynamic reference count. */ > + uintptr_t dynamic_refcount; > /* Pointer to the original mapping of "omp declare target link" object. */ > splay_tree_key link_key; > }; I'm not entirely happy about this, it grows the structure for not just OpenACC, but also OpenMP which will never use it. Are there any fields not used by OpenACC? E.g. is link_key used? Or could the dynamic refcounts be an array allocated (for OpenACC mappings only) after the tgt->array array, accessed using key->tgt->dynamic_refcounts[key - key->tgt->array] ? Jakub