Skip to content
Snippets Groups Projects
  • Tobias Burnus's avatar
    a8caeaac
    OpenMP: Allocate directive for static vars, clean up · a8caeaac
    Tobias Burnus authored
    For the 'allocate' directive, remove the sorry for static variables and
    just keep using normal memory, but honor the requested alignment and set
    a DECL_ATTRIBUTE in case a target may want to make use of this later on.
    The documentation is updated accordingly.
    
    The C diagnostic to check for predefined allocators (req. for static vars)
    failed to accept GCC's ompx_gnu_... allocator, now fixed. (Fortran was
    already okay; but both now use new common #defined value for checking.)
    And while Fortran common block variables are still rejected, the check
    has been improved as before the sorry diagnostic did not work for
    common blocks in modules.
    
    Finally, for 'allocate' clause on the target/task/taskloop directives,
    there is now a warning for omp_thread_mem_alloc (i.e. predefined allocator
    with access = thread), which is undefined behavior according to the
    OpenMP specification.
    
    And, last, testing showed that var decl + static_assert sets TREE_USED
    but does not produce a statement list in C, which did run into an assert
    in gimplify. This special case is now also handled.
    
    gcc/c/ChangeLog:
    
    	* c-parser.cc (c_parser_omp_allocate): Set alignment for alignof;
    	accept static variables and fix predef allocator check.
    
    gcc/fortran/ChangeLog:
    
    	* openmp.cc (is_predefined_allocator): Use gomp-constants.h consts.
    	* trans-common.cc (translate_common): Reject OpenMP allocate directives.
    	* trans-decl.cc (gfc_finish_var_decl): Handle allocate directive
    	for static variables.
    	(gfc_trans_deferred_vars): Update for the latter.
    
    gcc/ChangeLog:
    
    	* gimplify.cc (gimplify_bind_expr): Fix corner case for OpenMP
    	allocate directive.
    	(gimplify_scan_omp_clauses): Warn if omp_thread_mem_alloc is used
    	as allocator with the target/task/taskloop directive.
    
    include/ChangeLog:
    
    	* gomp-constants.h (GOMP_OMP_PREDEF_ALLOC_MAX,
    	GOMP_OMPX_PREDEF_ALLOC_MIN, GOMP_OMPX_PREDEF_ALLOC_MAX,
    	GOMP_OMP_PREDEF_ALLOC_THREADS): New defines.
    
    libgomp/ChangeLog:
    
    	* allocator.c: Add static asserts for news
    	GOMP_OMP{,X}_PREDEF_ALLOC_{MIN,MAX} range values.
    	* libgomp.texi (OpenMP Impl. Status): Allocate directive for
    	static vars is now supported. Refer to PR for allocate clause.
    	(Memory allocation): Update for static vars; minor word tweaking.
    
    gcc/testsuite/ChangeLog:
    
    	* c-c++-common/gomp/allocate-9.c: Update for removed sorry.
    	* gfortran.dg/gomp/allocate-15.f90: Likewise.
    	* gfortran.dg/gomp/allocate-pinned-1.f90: Likewise.
    	* gfortran.dg/gomp/allocate-4.f90: Likewise; add dg-error for
    	previously missing diagnostic.
    	* c-c++-common/gomp/allocate-18.c: New test.
    	* c-c++-common/gomp/allocate-19.c: New test.
    	* gfortran.dg/gomp/allocate-clause.f90: New test.
    	* gfortran.dg/gomp/allocate-static-2.f90: New test.
    	* gfortran.dg/gomp/allocate-static.f90: New test.
    a8caeaac
    History
    OpenMP: Allocate directive for static vars, clean up
    Tobias Burnus authored
    For the 'allocate' directive, remove the sorry for static variables and
    just keep using normal memory, but honor the requested alignment and set
    a DECL_ATTRIBUTE in case a target may want to make use of this later on.
    The documentation is updated accordingly.
    
    The C diagnostic to check for predefined allocators (req. for static vars)
    failed to accept GCC's ompx_gnu_... allocator, now fixed. (Fortran was
    already okay; but both now use new common #defined value for checking.)
    And while Fortran common block variables are still rejected, the check
    has been improved as before the sorry diagnostic did not work for
    common blocks in modules.
    
    Finally, for 'allocate' clause on the target/task/taskloop directives,
    there is now a warning for omp_thread_mem_alloc (i.e. predefined allocator
    with access = thread), which is undefined behavior according to the
    OpenMP specification.
    
    And, last, testing showed that var decl + static_assert sets TREE_USED
    but does not produce a statement list in C, which did run into an assert
    in gimplify. This special case is now also handled.
    
    gcc/c/ChangeLog:
    
    	* c-parser.cc (c_parser_omp_allocate): Set alignment for alignof;
    	accept static variables and fix predef allocator check.
    
    gcc/fortran/ChangeLog:
    
    	* openmp.cc (is_predefined_allocator): Use gomp-constants.h consts.
    	* trans-common.cc (translate_common): Reject OpenMP allocate directives.
    	* trans-decl.cc (gfc_finish_var_decl): Handle allocate directive
    	for static variables.
    	(gfc_trans_deferred_vars): Update for the latter.
    
    gcc/ChangeLog:
    
    	* gimplify.cc (gimplify_bind_expr): Fix corner case for OpenMP
    	allocate directive.
    	(gimplify_scan_omp_clauses): Warn if omp_thread_mem_alloc is used
    	as allocator with the target/task/taskloop directive.
    
    include/ChangeLog:
    
    	* gomp-constants.h (GOMP_OMP_PREDEF_ALLOC_MAX,
    	GOMP_OMPX_PREDEF_ALLOC_MIN, GOMP_OMPX_PREDEF_ALLOC_MAX,
    	GOMP_OMP_PREDEF_ALLOC_THREADS): New defines.
    
    libgomp/ChangeLog:
    
    	* allocator.c: Add static asserts for news
    	GOMP_OMP{,X}_PREDEF_ALLOC_{MIN,MAX} range values.
    	* libgomp.texi (OpenMP Impl. Status): Allocate directive for
    	static vars is now supported. Refer to PR for allocate clause.
    	(Memory allocation): Update for static vars; minor word tweaking.
    
    gcc/testsuite/ChangeLog:
    
    	* c-c++-common/gomp/allocate-9.c: Update for removed sorry.
    	* gfortran.dg/gomp/allocate-15.f90: Likewise.
    	* gfortran.dg/gomp/allocate-pinned-1.f90: Likewise.
    	* gfortran.dg/gomp/allocate-4.f90: Likewise; add dg-error for
    	previously missing diagnostic.
    	* c-c++-common/gomp/allocate-18.c: New test.
    	* c-c++-common/gomp/allocate-19.c: New test.
    	* gfortran.dg/gomp/allocate-clause.f90: New test.
    	* gfortran.dg/gomp/allocate-static-2.f90: New test.
    	* gfortran.dg/gomp/allocate-static.f90: New test.