[PATCH, OpenACC] Fortran "declare create"/allocate support for OpenACC

Julian Brown julian@codesourcery.com
Fri Sep 21 22:32:00 GMT 2018


On Fri, 21 Sep 2018 03:14:22 +0200
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:

> > diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
> > index 95ea615..2ac5908 100644
> > --- a/gcc/fortran/trans-array.c
> > +++ b/gcc/fortran/trans-array.c
> > @@ -88,6 +88,7 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "trans-types.h"
> >  #include "trans-array.h"
> >  #include "trans-const.h"
> > +#include "trans-stmt.h"
> >  #include "dependency.h"  
> 
> please dont mix declarations and definitions, i.e. please put
> gfc_trans_oacc_declare_allocate() into trans-openmp.c, and add the
> declaration to trans.h, in the corresponding /* In trans-openmp.c */
> block there.

Do you mean like this?

Thanks,

Julian

ChangeLog

2018-09-20  Cesar Philippidis  <cesar@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>

	gcc/
	* omp-low.c (scan_sharing_clauses): Update handling of OpenACC declare
	create, declare copyin and declare deviceptr to have local lifetimes.
	(convert_to_firstprivate_int): Handle pointer types.
	(convert_from_firstprivate_int): Likewise.  Create local storage for
	the values being pointed to.  Add new orig_type argument.
	(lower_omp_target): Handle GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.
	Add orig_type argument to convert_from_firstprivate_int call.
	Allow pointer types with GOMP_MAP_FIRSTPRIVATE_INT.  Don't privatize
	firstprivate VLAs.
	* tree-pretty-print.c (dump_omp_clause): Handle
	GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.

	gcc/fortran/
	* gfortran.h (enum gfc_omp_map_op): Add OMP_MAP_DECLARE_ALLOCATE,
	OMP_MAP_DECLARE_DEALLOCATE.
	(gfc_omp_clauses): Add update_allocatable.
	* trans-array.c (gfc_array_allocate): Call
	gfc_trans_oacc_declare_allocate for decls that have oacc_declare_create
	attribute set.
	* trans-decl.c (add_attributes_to_decl): Enable lowering of OpenACC
	declare create, declare copyin and declare deviceptr clauses.
	(add_clause): Don't duplicate OpenACC declare clauses.  Populate
	sym->backend_decl so that it can be used to determine if two symbols are
	unique.
	(find_module_oacc_declare_clauses): Relax oacc_declare_create to
	OMP_MAP_ALLOC, and oacc_declare_copyin to OMP_MAP_TO, in order to 
	match OpenACC 2.5 semantics.
	* trans-openmp.c (gfc_trans_omp_clauses): Use GOMP_MAP_ALWAYS_POINTER
	(for update directive) or GOMP_MAP_FIRSTPRIVATE_POINTER (otherwise) for
	allocatable scalar decls.  Handle OMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}
	clauses.
	(gfc_trans_oacc_executable_directive): Use GOMP_MAP_ALWAYS_POINTER
	for allocatable scalar data clauses inside acc update directives.
	(gfc_trans_oacc_declare_allocate): New function.
	* trans-stmt.c (gfc_trans_allocate): Call
	gfc_trans_oacc_declare_allocate for decls with oacc_declare_create
	attribute set.
	(gfc_trans_deallocate): Likewise.
	* trans.h (gfc_trans_oacc_declare_allocate): Declare.

	gcc/testsuite/
	* gfortran.dg/goacc/declare-allocatable-1.f90: New test.

	include/
	* gomp-constants.h (enum gomp_map_kind): Define
	GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE} and GOMP_MAP_FLAG_SPECIAL_4.

	libgomp/
	* oacc-mem.c (gomp_acc_declare_allocate): New function.
	* oacc-parallel.c (GOACC_enter_exit_data): Handle
	GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.
	* testsuite/libgomp.oacc-fortran/allocatable-array.f90: New test.
	* testsuite/libgomp.oacc-fortran/allocatable-scalar.f90: New test. 
	* testsuite/libgomp.oacc-fortran/declare-allocatable-1.f90: New test.
	* testsuite/libgomp.oacc-fortran/declare-allocatable-2.f90: New test.
	* testsuite/libgomp.oacc-fortran/declare-allocatable-3.f90: New test.
	* testsuite/libgomp.oacc-fortran/declare-allocatable-4.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fortran-declare-create-allocate-support-for-OpenACC-3.patch
Type: text/x-patch
Size: 35689 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20180921/4365320f/attachment.bin>


More information about the Fortran mailing list