[gomp4] Implement OpenACC 2.5 reference counting, and finalize clause

Chung-Lin Tang chunglin_tang@mentor.com
Tue May 16 13:11:00 GMT 2017


This patch for gomp-4_0-branch implements OpenACC 2.5 reference counting
of mappings, the finalize clause of the exit data directive, and the
corresponding API routines.

Tested without regressions, committed to gomp-4_0-branch.

Chung-Lin

2017-05-16  Chung-Lin Tang  <cltang@codesourcery.com>

        gcc/c/
        * c-parser.c (c_parser_omp_clause_name):  Handle 'finalize' clause.
        (c_parser_oacc_simple_clause): Add 'finalize' to comments.
        (c_parser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_FINALIZE.
        (OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_FINALIZE.
        * c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_FINALIZE.

        gcc/cp/
        * parser.c (cp_parser_omp_clause_name): Handle 'finalize' clause.
        (cp_parser_oacc_simple_clause): Add 'finalize' to comments.
        (cp_parser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_FINALIZE.
        (OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_FINALIZE.
        * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_FINALIZE.

        gcc/c-family/
        * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_FINALIZE.

        gcc/fortran/
        * gfortran.h (struct gfc_omp_clauses): Add 'finalize:1' bitfield.
        * openmp.c (enum omp_mask2): Add OMP_CLAUSE_FINALIZE.
        (gfc_match_omp_clauses): Handle 'finalize' clause.
        (OACC_EXIT_DATA_CLAUSES): Add OMP_CLAUSE_FINALIZE.
        * trans-openmp.c (gfc_trans_omp_clauses_1): Handle finalize bit.

        gcc/
        * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_FINALIZE.
        * tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_FINALIZE.
        (omp_clause_code_name): Add "finalize" entry.
        * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FINALIZE.
        (expand_omp_target): Add finalize argument for GOACC_enter_exit_data
        call.
        * gimplify.c (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_FINALIZE.
        (gimplify_adjust_omp_clauses): Likewise.

        libgomp/
        * openacc.h (acc_copyout_finalize): Declare new API function.
        (acc_copyout_finalize_async): Likewise.
	(acc_delete_finalize): Likewise.
        (acc_delete_finalize_async): Likewise.
        * openacc_lib.h (acc_copyout_finalize): Declare new API function.
        (acc_copyout_finalize_async): Likewise.
        (acc_delete_finalize): Likewise.
        (acc_delete_finalize_async): Likewise.
        * openacc.f90 (acc_copyout_finalize_32_h): Define.
	(acc_copyout_finalize_64_h): Likewise.
        (acc_copyout_finalize_array_h): Likewise.
        (acc_copyout_finalize_l): Likewise.
        (acc_copyout_finalize_async_32_h): Define.
        (acc_copyout_finalize_async_64_h): Likewise.
        (acc_copyout_finalize_async_array_h): Likewise.
        (acc_copyout_finalize_async_l): Likewise.
	(acc_delete_finalize_32_h): Define.
        (acc_delete_finalize_64_h): Likewise.
        (acc_delete_finalize_array_h): Likewise.
	(acc_delete_finalize_l): Likewise.
        (acc_delete_finalize_async_32_h): Define.
        (acc_delete_finalize_async_64_h): Likewise.
        (acc_delete_finalize_async_array_h): Likewise.
        (acc_delete_finalize_async_l): Likewise.
        * libgomp.map (OACC_2.5): Add acc_copyout_finalize* and
        acc_delete_finalize* entries.
	* libgomp.h (struct splay_tree_key_s): Add 'dynamic_refcount' field.
        (gomp_acc_remove_pointer): Adjust declaration.
        (gomp_remove_var): New declaration.
        * libgomp_g.h (GOACC_enter_exit_data): Adjust declaration.
        * oacc-mem.c (acc_map_data): Adjust new key refcount to REFCOUNT_INFINITY.
        (acc_unmap_data): Adjust key refcount to 1 for removal.
        (present_create_copy): Increment mapping refcounts when mapping exists,
        initialize dynamic refcount when creating new mapping.
        (FLAG_FINALIZE): Define macro.
        (delete_copyout): Adjust delete/copyout handling, add handling for FLAG_FINALIZE.
        (acc_delete_finalize): Define new API function.
	(acc_delete_finalize_async): Likewise.
	(acc_copyout_finalize): Likewise.
        (acc_copyout_finalize_async): Likewise.
        (gomp_acc_insert_pointer): Adjust handling.
        (gomp_acc_remove_pointer): Add finalize parameter, adjust handling.
	* oacc-parallel.c (GOACC_parallel_keyed): Disable async registering when no
        copyout needed.
        (GOACC_enter_exit_data): Add and handle finalize argument, adjust
        gomp_acc_insert_pointer and gomp_acc_remove_pointer calls.
        (GOACC_declare): Adjust calls to GOACC_enter_exit_data.
        * target.c (gomp_map_vars): Initialize dynamic_refcount.
        (gomp_remove_var): Abstract out key unreferencing into new function.
	(gomp_unmap_vars): Adjust to call gomp_remove_var.
        (gomp_unload_image_from_device): Likewise.
        (gomp_exit_data): Likewise.
        * testsuite/libgomp.oacc-c-c++-common/data-2.c: Adjust testcase for 2.5 reference counting.
        * testsuite/libgomp.oacc-c-c++-common/lib-38.c: Likewise.
        * testsuite/libgomp.oacc-fortran/data-2.f90: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/data-4.c: New test.
        * testsuite/libgomp.oacc-c-c++-common/data-5.c: Likewise.
        * testsuite/libgomp.oacc-fortran/data-5.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/data-6.f90: Likewise.







-------------- next part --------------
A non-text attachment was scrubbed...
Name: oacc25-refcount.patch
Type: text/x-patch
Size: 51065 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170516/9c073b0b/attachment.bin>


More information about the Gcc-patches mailing list