aboutsummaryrefslogtreecommitdiff
path: root/libgomp/oacc-mem.c
AgeCommit message (Collapse)Author
2021-01-04Update copyright years.Jakub Jelinek
2020-11-10openmp: Implement OpenMP 5.0 base-pointer attachement and clause orderingChung-Lin Tang
This patch implements some parts of the target variable mapping changes specified in OpenMP 5.0, including base-pointer attachment/detachment behavior for array section list-items in map clauses, and ordering of map clauses according to map kind. 2020-11-10 Chung-Lin Tang <cltang@codesourcery.com> gcc/c-family/ChangeLog: * c-common.h (c_omp_adjust_map_clauses): New declaration. * c-omp.c (struct map_clause): Helper type for c_omp_adjust_map_clauses. (c_omp_adjust_map_clauses): New function. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_target_data): Add use of new c_omp_adjust_map_clauses function. Add GOMP_MAP_ATTACH_DETACH as handled map clause kind. (c_parser_omp_target_enter_data): Likewise. (c_parser_omp_target_exit_data): Likewise. (c_parser_omp_target): Likewise. * c-typeck.c (handle_omp_array_sections): Adjust COMPONENT_REF case to use GOMP_MAP_ATTACH_DETACH map kind for C_ORT_OMP region type. (c_finish_omp_clauses): Adjust bitmap checks to allow struct decl and same struct field access to co-exist on OpenMP construct. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_target_data): Add use of new c_omp_adjust_map_clauses function. Add GOMP_MAP_ATTACH_DETACH as handled map clause kind. (cp_parser_omp_target_enter_data): Likewise. (cp_parser_omp_target_exit_data): Likewise. (cp_parser_omp_target): Likewise. * semantics.c (handle_omp_array_sections): Adjust COMPONENT_REF case to use GOMP_MAP_ATTACH_DETACH map kind for C_ORT_OMP region type. Fix interaction between reference case and attach/detach. (finish_omp_clauses): Adjust bitmap checks to allow struct decl and same struct field access to co-exist on OpenMP construct. gcc/ChangeLog: * gimplify.c (is_or_contains_p): New static helper function. (omp_target_reorder_clauses): New function. (gimplify_scan_omp_clauses): Add use of omp_target_reorder_clauses to reorder clause list according to OpenMP 5.0 rules. Add handling of GOMP_MAP_ATTACH_DETACH for OpenMP cases. * omp-low.c (is_omp_target): New static helper function. (scan_sharing_clauses): Add scan phase handling of GOMP_MAP_ATTACH/DETACH for OpenMP cases. (lower_omp_target): Add lowering handling of GOMP_MAP_ATTACH/DETACH for OpenMP cases. gcc/testsuite/ChangeLog: * c-c++-common/gomp/clauses-2.c: Remove dg-error cases now valid. * gfortran.dg/gomp/map-2.f90: Likewise. * c-c++-common/gomp/map-5.c: New testcase. libgomp/ChangeLog: * libgomp.h (enum gomp_map_vars_kind): Adjust enum values to be bit-flag usable. * oacc-mem.c (acc_map_data): Adjust gomp_map_vars argument flags to 'GOMP_MAP_VARS_OPENACC | GOMP_MAP_VARS_ENTER_DATA'. (goacc_enter_datum): Likewise for call to gomp_map_vars_async. (goacc_enter_data_internal): Likewise. * target.c (gomp_map_vars_internal): Change checks of GOMP_MAP_VARS_ENTER_DATA to use bit-and (&). Adjust use of gomp_attach_pointer for OpenMP cases. (gomp_exit_data): Add handling of GOMP_MAP_DETACH. (GOMP_target_enter_exit_data): Add handling of GOMP_MAP_ATTACH. * testsuite/libgomp.c-c++-common/ptr-attach-1.c: New testcase.
2020-07-27openacc: Deep copy attach/detach should not affect reference countsJulian Brown
Attach and detach operations are not supposed to affect structural or dynamic reference counts for OpenACC. Previously they did so, which led to subtle problems in some circumstances. We can avoid reference-counting attach/detach operations by extending and slightly repurposing the do_detach field in target_var_desc. It is now called is_attach to better reflect its new role. 2020-07-27 Julian Brown <julian@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> libgomp/ * libgomp.h (struct target_var_desc): Rename do_detach field to is_attach. * oacc-mem.c (goacc_exit_datum_1): Add assert. Don't set finalize for GOMP_MAP_FORCE_DETACH. Update checking to use is_attach field. (goacc_enter_data_internal): Don't affect reference counts for attach mappings. (goacc_exit_data_internal): Don't affect reference counts for detach mappings. * target.c (gomp_map_vars_existing): Don't affect reference counts for attach mappings. (gomp_map_vars_internal): Set renamed is_attach flag unconditionally to mark attach mappings. (gomp_unmap_vars_internal): Use is_attach flag to prevent affecting reference count for attach mappings. * testsuite/libgomp.oacc-c-c++-common/mdc-refcount-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/mdc-refcount-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/mdc-refcount-2.c: New test. * testsuite/libgomp.oacc-fortran/deep-copy-6-no_finalize.F90: Mark test as shouldfail. * testsuite/libgomp.oacc-fortran/deep-copy-6.f90: Adjust to fail gracefully in no-finalize mode. Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2020-07-10openacc: Adjust dynamic reference count semanticsJulian Brown
This patch adjusts how dynamic reference counts work so that they match the semantics of the source program more closely, instead of representing "excess" reference counts beyond those that represent pointers in the internal libgomp splay-tree data structure. This allows some corner cases to be handled more gracefully. 2020-07-10 Julian Brown <julian@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> libgomp/ * libgomp.h (struct splay_tree_key_s): Change virtual_refcount to dynamic_refcount. (struct gomp_device_descr): Remove GOMP_MAP_VARS_OPENACC_ENTER_DATA. * oacc-mem.c (acc_map_data): Substitute virtual_refcount for dynamic_refcount. (acc_unmap_data): Update comment. (goacc_map_var_existing, goacc_enter_datum): Adjust for dynamic_refcount semantics. (goacc_exit_datum_1, goacc_exit_datum): Re-add some error checking. Adjust for dynamic_refcount semantics. (goacc_enter_data_internal): Implement "present" case of dynamic memory-map handling here. Update "non-present" case for dynamic_refcount semantics. (goacc_exit_data_internal): Use goacc_exit_datum_1. * target.c (gomp_map_vars_internal): Remove GOMP_MAP_VARS_OPENACC_ENTER_DATA handling. Update for dynamic_refcount handling. (gomp_unmap_vars_internal): Remove virtual_refcount handling. (gomp_load_image_to_device): Substitute dynamic_refcount for virtual_refcount. * testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: Remove XFAILs. * testsuite/libgomp.oacc-c-c++-common/refcounting-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/refcounting-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/struct-3-1-1.c: New test. * testsuite/libgomp.oacc-fortran/deep-copy-6.f90: Remove XFAILs and trace output. * testsuite/libgomp.oacc-fortran/deep-copy-6-no_finalize.F90: Remove trace output. * testsuite/libgomp.oacc-fortran/dynamic-incr-structural-1.f90: New test. * testsuite/libgomp.oacc-c-c++-common/structured-dynamic-lifetimes-4.c: Remove stale comment. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-1-1.f90: Remove XFAILs. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-1-2.F90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-2-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-2-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-3-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-4-1.f90: Adjust XFAIL. Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2020-07-10openacc: Helper functions for enter/exit data using single mappingJulian Brown
This patch factors out the parts of goacc_enter_datum and goacc_exit_datum that can be shared with goacc_enter_data_internal and goacc_exit_data_internal respectively (in the next patch), without overloading function return values or complicating code paths unnecessarily. 2020-07-10 Julian Brown <julian@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> libgomp/ * oacc-mem.c (goacc_map_var_existing): New function. (goacc_enter_datum): Use above function. (goacc_exit_datum_1): New function. (goacc_exit_datum): Use above function. Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2020-07-09openacc: GOMP_MAP_ATTACH handling in find_group_lastJulian Brown
Arrange for GOMP_MAP_ATTACH to be grouped together with a preceding GOMP_MAP_TO_PSET or other "to" data movement clause, except in cases where an explicit "attach" clause is used. 2020-07-09 Julian Brown <julian@codesourcery.com> include/ * gomp-constants.h (gomp_map_kind): Update comment for GOMP_MAP_TO_PSET. libgomp/ * oacc-mem.c (find_group_last): Group data-movement clauses (GOMP_MAP_TO_PSET, GOMP_MAP_TO, etc.) together with a subsequent GOMP_MAP_ATTACH. Allow standalone GOMP_MAP_ATTACH also.
2020-07-03[OpenACC] Revert always-copyfrom behavior for 'GOMP_MAP_FORCE_FROM' in ↵Thomas Schwinge
'libgomp/oacc-mem.c:goacc_exit_data_internal' As done for 'GOMP_MAP_FROM', also for 'GOMP_MAP_FORCE_FROM' we should only 'gomp_copy_dev2host' if 'n->refcount == 0'. This had gotten altered in commit 378da98fcc907d05002bcd3d6ff7951f0cf485e5 (r279621) "OpenACC reference count overhaul". libgomp/ * oacc-mem.c (goacc_exit_data_internal): Revert always-copyfrom behavior for 'GOMP_MAP_FORCE_FROM'. * testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: Adjust XFAIL.
2020-07-03[OpenACC] Remove (unused) 'GOMP_MAP_ALWAYS_FROM' handling from ↵Thomas Schwinge
'libgomp/oacc-mem.c:goacc_exit_data_internal' This had gotten added in commit 378da98fcc907d05002bcd3d6ff7951f0cf485e5 (r279621) "OpenACC reference count overhaul", but it doesn't have any use in OpenACC. libgomp/ * oacc-mem.c (goacc_exit_data_internal): Remove 'GOMP_MAP_ALWAYS_FROM' handling.
2020-06-05[OpenACC 'exit data'] Strip 'GOMP_MAP_STRUCT' mappingsThomas Schwinge
These are not itself necessary for OpenACC 'exit data' directives, and are skipped over (now) in libgomp. We might as well not emit them to start with, in line with the equivalent OpenMP directive. We keep the no-op handling in libgomp for the reason of backward compatibility. gcc/ * gimplify.c (gimplify_adjust_omp_clauses): Remove 'GOMP_MAP_STRUCT' mapping from OpenACC 'exit data' directives. gcc/testsuite/ * c-c++-common/goacc/struct-enter-exit-data-1.c: New file. libgomp/ * oacc-mem.c (goacc_exit_data_internal) <GOMP_MAP_STRUCT>: Explain special handling. Co-Authored-By: Julian Brown <julian@codesourcery.com>
2020-06-05[OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handlingThomas Schwinge
libgomp/ * oacc-mem.c (goacc_exit_data_internal) <GOMP_MAP_STRUCT>: Simplify. Co-Authored-By: Julian Brown <julian@codesourcery.com>
2020-06-04[OpenACC 'exit data'] Evaluate 'copyfrom' individually for 'GOMP_MAP_STRUCT' ↵Thomas Schwinge
entries Currently, we don't at all evaluate 'copyfrom' for 'GOMP_MAP_STRUCT' entries. Fix this by copying/adapting the corresponding non-'GOMP_MAP_STRUCT' code. libgomp/ * oacc-mem.c (goacc_exit_data_internal) <GOMP_MAP_STRUCT>: Evaluate 'copyfrom' individually for each entry. * testsuite/libgomp.oacc-c-c++-common/struct-1.c: Update.
2020-06-04[OpenACC 'exit data'] Evaluate 'finalize' individually for 'GOMP_MAP_STRUCT' ↵Thomas Schwinge
entries Currently, we don't at all evaluate 'finalize' for 'GOMP_MAP_STRUCT' entries. Fix this by copying/adapting the corresponding non-'GOMP_MAP_STRUCT' code. libgomp/ * oacc-mem.c (goacc_exit_data_internal) <GOMP_MAP_STRUCT>: Evaluate 'finalize' individually for each entry. * testsuite/libgomp.oacc-c-c++-common/struct-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/struct-refcount-1.c: Remove file.
2020-06-04[OpenACC] Repair/restore 'is_tgt_unmapped' checkingThomas Schwinge
libgomp/ * oacc-mem.c (goacc_exit_datum): Repair 'is_tgt_unmapped' checking. (acc_unmap_data, goacc_exit_data_internal): Restore 'is_tgt_unmapped' checking. * testsuite/libgomp.oacc-c-c++-common/struct-refcount-1.c: New file. * testsuite/libgomp.oacc-fortran/deep-copy-6.f90: Adjust. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-1-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-2-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-2-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-3-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/mdc-refcount-1-4-1.f90: Likewise. Co-Authored-By: Julian Brown <julian@codesourcery.com>
2020-06-04[OpenACC] Don't open-code 'gomp_remove_var' in 'acc_unmap_data'Thomas Schwinge
libgomp/ * oacc-mem.c (acc_unmap_data): Don't open-code 'gomp_remove_var'. Co-Authored-By: Julian Brown <julian@codesourcery.com>
2020-06-04[OpenACC] Remove 'tgt' reference counting from 'acc_unmap_data' [PR92854]Thomas Schwinge
libgomp/ PR libgomp/92854 * oacc-mem.c (acc_unmap_data): Remove 'tgt' reference counting.
2020-06-04[OpenACC] Use 'tgt' returned from 'gomp_map_vars'Thomas Schwinge
libgomp/ * oacc-mem.c (goacc_enter_datum): Use 'tgt' returned from 'gomp_map_vars'. (acc_map_data): Clean up accordingly. Co-Authored-By: Julian Brown <julian@codesourcery.com>
2020-06-04[OpenACC] Missing unlocking on error paths in attach/detach code, part IIThomas Schwinge
libgomp/ * oacc-mem.c (goacc_exit_data_internal): Unlock on error path.
2020-06-04[OpenACC] Missing unlocking on error paths in attach/detach codeJulian Brown
libgomp/ * oacc-mem.c (acc_attach_async): Add missing gomp_mutex_unlock on error path. (goacc_detach_internal): Likewise. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
2020-01-01Update copyright years.Jakub Jelinek
From-SVN: r279813
2019-12-20OpenACC 2.6 deep copy: libgomp partsJulian Brown
include/ * gomp-constants.h (GOMP_MAP_FLAG_SPECIAL_4, GOMP_MAP_DEEP_COPY): Define. (gomp_map_kind): Add GOMP_MAP_ATTACH, GOMP_MAP_DETACH, GOMP_MAP_FORCE_DETACH. libgomp/ * libgomp.h (struct target_var_desc): Add do_detach flag. * oacc-init.c (acc_shutdown_1): Free aux block if present. * oacc-mem.c (find_group_last): Add SIZES parameter. Support struct components. Tidy up and add some new checks. (goacc_enter_data_internal): Update call to find_group_last. (goacc_exit_data_internal): Support detach operations and GOMP_MAP_STRUCT. (GOACC_enter_exit_data): Handle initial GOMP_MAP_STRUCT or GOMP_MAP_FORCE_PRESENT in finalization detection code. Handle attach/detach in enter/exit data detection code. * target.c (gomp_map_vars_existing): Initialise do_detach field of tgt_var_desc. (gomp_map_vars_internal): Support attach. (gomp_unmap_vars_internal): Support detach. From-SVN: r279625
2019-12-20OpenACC 2.6 deep copy: attach/detach API routinesJulian Brown
libgomp/ * libgomp.h (struct splay_tree_aux): Add attach_count field. (gomp_attach_pointer, gomp_detach_pointer): Add prototypes. * libgomp.map (OACC_2.6): New section. Add acc_attach, acc_attach_async, acc_detach, acc_detach_async, acc_detach_finalize, acc_detach_finalize_async. * oacc-mem.c (acc_attach_async, acc_attach, goacc_detach_internal, acc_detach, acc_detach_async, acc_detach_finalize, acc_detach_finalize_async): New functions. * openacc.h (acc_attach, acc_attach_async, acc_detach, (acc_detach_async, acc_detach_finalize, acc_detach_finalize_async): Add prototypes. * target.c (gomp_attach_pointer, gomp_detach_pointer): New functions. (gomp_remove_var_internal): Free attachment counts if present. * testsuite/libgomp.oacc-c-c++-common/deep-copy-3.c: New test. * testsuite/libgomp.oacc-c-c++-common/deep-copy-5.c: New test. Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r279624
2019-12-20OpenACC reference count overhaulJulian Brown
libgomp/ * libgomp.h (struct splay_tree_key_s): Substitute dynamic_refcount field for virtual_refcount. (enum gomp_map_vars_kind): Add GOMP_MAP_VARS_OPENACC_ENTER_DATA. (gomp_free_memmap): Remove prototype. * oacc-init.c (acc_shutdown_1): Iteratively call gomp_remove_var instead of calling gomp_free_memmap. * oacc-mem.c (acc_map_data): Use virtual_refcount instead of dynamic_refcount. (acc_unmap_data): Open code instead of forcing target_mem_desc's to_free field to NULL then calling gomp_unmap_vars. Handle REFCOUNT_INFINITY on target blocks. (goacc_enter_data): Rename to... (goacc_enter_datum): ...this. Remove MAPNUM parameter and special handling for mapping groups. Use virtual_refcount instead of dynamic_refcount. Use GOMP_MAP_VARS_OPENACC_ENTER_DATA for map_map_vars_async call. Re-do lookup for target pointer return value. (acc_create, acc_create_async, acc_copyin, acc_copyin_async): Call renamed goacc_enter_datum function. (goacc_exit_data): Rename to... (goacc_exit_datum): ...this. Update for virtual_refcount semantics. (acc_delete, acc_delete_async, acc_delete_finalize, acc_delete_finalize_async, acc_copyout, acc_copyout_async, acc_copyout_finalize, acc_copyout_finalize_async): Call renamed goacc_exit_datum function. (gomp_acc_remove_pointer, find_pointer): Remove functions. (find_group_last, goacc_enter_data_internal, goacc_exit_data_internal): New functions. (GOACC_enter_exit_data): Use goacc_enter_data_internal and goacc_exit_data_internal helper functions. * target.c (gomp_map_vars_internal): Handle GOMP_MAP_VARS_OPENACC_ENTER_DATA. Update for virtual_refcount semantics. (gomp_unmap_vars_internal): Update for virtual_refcount semantics. (gomp_load_image_to_device, omp_target_associate_ptr): Zero-initialise virtual_refcount field instead of dynamic_refcount. (gomp_free_memmap): Remove function. * testsuite/libgomp.oacc-c-c++-common/unmap-infinity-1.c: New test. * testsuite/libgomp.c-c++-common/unmap-infinity-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: Add XFAIL. From-SVN: r279621
2019-12-18[OpenACC] Refactor 'goacc_enter_data' so that it can be called from ↵Thomas Schwinge
'goacc_insert_pointer', "present" case, and simplify No functional changes. libgomp/ * oacc-mem.c (goacc_enter_data): Refactor, so that it can be called... (goacc_insert_pointer): ... from here, "present" case. (goacc_insert_pointer): Inline function into... (GOACC_enter_exit_data): ... here, and simplify. From-SVN: r279540
2019-12-18[OpenACC] Refactor 'goacc_enter_data' so that it can be called from ↵Thomas Schwinge
'goacc_insert_pointer', "not present" case No functional changes. libgomp/ * oacc-mem.c (goacc_enter_data): Refactor, so that it can be called... (goacc_insert_pointer): ... from here, "not present" case. From-SVN: r279539
2019-12-18[OpenACC] Refactor 'goacc_remove_pointer' interfaceThomas Schwinge
No functional changes. libgomp/ * oacc-mem.c (goacc_remove_pointer): Refactor interface. Adjust all users. From-SVN: r279538
2019-12-18[OpenACC] Refactor 'GOACC_enter_exit_data' to call 'goacc_enter_data', ↵Thomas Schwinge
'goacc_exit_data' No functional changes. libgomp/ * oacc-mem.c (GOACC_enter_exit_data): Refactor code to call 'goacc_enter_data', 'goacc_exit_data'. From-SVN: r279537
2019-12-18[OpenACC] Refactor 'delete_copyout' into 'goacc_exit_data'Thomas Schwinge
Change 'FLAG_COPYOUT', 'FLAG_FINALIZE' into the usual map kind. No functional changes. libgomp/ * oacc-mem.c (delete_copyout): Refactor into... (goacc_exit_data): ... this. Adjust all users. From-SVN: r279536
2019-12-18[OpenACC] Refactor 'present_create_copy' into 'goacc_enter_data'Thomas Schwinge
Every caller passes in 'FLAG_PRESENT', 'FLAG_CREATE'. Change the remaining 'FLAG_COPY' into the usual map kind. No functional changes. libgomp/ * oacc-mem.c (present_create_copy): Refactor into... (goacc_enter_data): ... this. Adjust all users. From-SVN: r279535
2019-12-18[PR92726, PR92970, PR92984] [OpenACC] Clarify 'acc_delete' etc. for ↵Thomas Schwinge
'NULL'-in, non-present data, or size zero PR92970 "OpenACC 2.5: 'acc_delete' etc. on non-present data is a no-op" is an actual bug fix, and the other ones are fall-out, currently undefined behavior. libgomp/ PR libgomp/92726 PR libgomp/92970 PR libgomp/92984 * oacc-mem.c (delete_copyout): No-op behavior if 'lookup_host' fails. (GOACC_enter_exit_data): Simplify accordingly. * testsuite/libgomp.oacc-c-c++-common/pr92970-1.c: New file, subsuming... * testsuite/libgomp.oacc-c-c++-common/lib-17.c: ... this file... * testsuite/libgomp.oacc-c-c++-common/lib-18.c: ..., and this file. * testsuite/libgomp.oacc-c-c++-common/pr92984-1.c: New file, subsuming... * testsuite/libgomp.oacc-c-c++-common/lib-21.c: ... this file... * testsuite/libgomp.oacc-c-c++-common/lib-29.c: ..., and this file. * testsuite/libgomp.oacc-c-c++-common/pr92726-1.c: New file, subsuming... * testsuite/libgomp.oacc-c-c++-common/lib-28.c: ... this file. From-SVN: r279532
2019-12-18[OpenACC] Elaborate/simplify 'exit data' 'finalize' handlingThomas Schwinge
No functional changes. gcc/ * gimplify.c (gimplify_omp_target_update): Elaborate 'exit data' 'finalize' handling. gcc/testsuite/ * c-c++-common/goacc/finalize-1.c: Extend. * gfortran.dg/goacc/finalize-1.f: Likewise. libgomp/ * oacc-mem.c (GOACC_enter_exit_data): Simplify 'exit data' 'finalize' handling. From-SVN: r279531
2019-12-18[PR92848] [OpenACC] Use 'GOMP_MAP_VARS_ENTER_DATA' for dynamic data lifetimesThomas Schwinge
libgomp/ PR libgomp/92848 * oacc-mem.c (acc_map_data, present_create_copy) (goacc_insert_pointer): Use 'GOMP_MAP_VARS_ENTER_DATA'. (acc_unmap_data, delete_copyout, goacc_remove_pointer): Adjust. * testsuite/libgomp.oacc-c-c++-common/lib-50.c: Remove. * testsuite/libgomp.oacc-c-c++-common/pr92848-1-d-a.c: New file * testsuite/libgomp.oacc-c-c++-common/pr92848-1-d-p.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr92848-1-r-a.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr92848-1-r-p.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-r-p.c: Remove "XFAIL"s. From-SVN: r279530
2019-12-13Fix potential race condition in OpenACC "exit data" operationsJulian Brown
PR libgomp/92881 libgomp/ * libgomp.h (gomp_remove_var_async): Add prototype. * oacc-mem.c (delete_copyout): Call gomp_remove_var_async instead of gomp_remove_var. * target.c (gomp_unref_tgt): Change return type to bool, indicating whether target_mem_desc was unmapped. (gomp_unref_tgt_void): New. (gomp_remove_var): Reimplement in terms of... (gomp_remove_var_internal): ...this new helper function. (gomp_remove_var_async): New, implemented using above helper function. (gomp_unmap_vars_internal): Use gomp_unref_tgt_void instead of gomp_unref_tgt. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r279388
2019-12-11[PR92843] [OpenACC] Fix dynamic reference counting for structured ↵Thomas Schwinge
'REFCOUNT_INFINITY' libgomp/ PR libgomp/92843 * oacc-mem.c (present_create_copy, delete_copyout): Fix dynamic reference counting for structured 'REFCOUNT_INFINITY'. Add some assertions. (goacc_insert_pointer, goacc_remove_pointer): Adjust accordingly. * testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/clauses-1.c: Fix OpenACC. * testsuite/libgomp.oacc-c-c++-common/lib-82.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/nested-1.c: Likewise. From-SVN: r279234
2019-12-11[OpenACC] Consolidate 'GOACC_enter_exit_data' and its helper functions in ↵Thomas Schwinge
'libgomp/oacc-mem.c' libgomp/ * oacc-parallel.c (find_pointer, GOACC_enter_exit_data): Move... * oacc-mem.c: ... here. (gomp_acc_insert_pointer, gomp_acc_remove_pointer): Rename to 'goacc_insert_pointer', 'goacc_remove_pointer', and make 'static'. * libgomp.h (gomp_acc_insert_pointer, gomp_acc_remove_pointer): Remove. * libgomp_g.h: Update. From-SVN: r279233
2019-12-09[PR92116, PR92877] [OpenACC] Replace 'openacc.data_environ' by standard ↵Thomas Schwinge
libgomp mechanics libgomp/ PR libgomp/92116 PR libgomp/92877 * oacc-mem.c (lookup_dev): Reimplement. Adjust all users. * libgomp.h (struct acc_dispatch_t): Remove 'data_environ' member. Adjust all users. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-4-2.c: Remove XFAIL. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr92877-1.c: New file. Co-Authored-By: Julian Brown <julian@codesourcery.com> From-SVN: r279147
2019-12-09[PR92503] [OpenACC] Don't silently 'acc_unmap_data' in 'acc_free'Thomas Schwinge
libgomp/ PR libgomp/92503 * oacc-mem.c (acc_free): Error out instead of 'acc_unmap_data'. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-3-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-4-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_free-pr92503-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/clauses-1.c: Adjust. * testsuite/libgomp.oacc-c-c++-common/context-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-13.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-14.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-18.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-91.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/nested-1.c: Likewise. From-SVN: r279146
2019-12-09[PR92840] [OpenACC] Refuse 'acc_unmap_data' unless mapped by 'acc_map_data'Thomas Schwinge
libgomp/ PR libgomp/92840 * oacc-mem.c (acc_map_data): Clarify reference counting behavior. (acc_unmap_data): Add error case for 'REFCOUNT_INFINITY'. * testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/clauses-1.c: Adjust. * testsuite/libgomp.oacc-c-c++-common/nested-1.c: Adjust. From-SVN: r279145
2019-12-06[OpenMP/OpenACC/Fortran] Fix mapping of optional (present|absent) argumentsTobias Burnus
2019-12-06 Tobias Burnus <tobias@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> gcc/fortran/ * trans-openmp.c (gfc_build_conditional_assign, gfc_build_conditional_assign_expr): New static functions. (gfc_omp_finish_clause, gfc_trans_omp_clauses): Handle mapping of absent optional arguments and fix mapping of present optional args. gcc/ * omp-low.c (lower_omp_target): For optional arguments, deref once more to obtain the type. libgomp/ * oacc-mem.c (update_dev_host, gomp_acc_insert_pointer): Just return if input it a NULL pointer. * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Remove; dependent on diagnostic of NULL pointer. * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Ditto. * testsuite/libgomp.fortran/optional-map.f90: New. * testsuite/libgomp.fortran/use_device_addr-1.f90 (test_dummy_opt_callee_1_absent): New. (test_dummy_opt_call_1): Call it. * testsuite/libgomp.fortran/use_device_addr-2.f90: Likewise. * testsuite/libgomp.fortran/use_device_addr-3.f90: Likewise. * testsuite/libgomp.fortran/use_device_addr-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/optional-cache.f95: New. * testsuite/libgomp.oacc-fortran/optional-data-copyin-by-value.f90: New. * testsuite/libgomp.oacc-fortran/optional-data-copyin.f90: New. * testsuite/libgomp.oacc-fortran/optional-data-copyout.f90: New. * testsuite/libgomp.oacc-fortran/optional-data-enter-exit.f90: New. * testsuite/libgomp.oacc-fortran/optional-declare.f90: New. * testsuite/libgomp.oacc-fortran/optional-firstprivate.f90: New. * testsuite/libgomp.oacc-fortran/optional-host_data.f90: New. * testsuite/libgomp.oacc-fortran/optional-nested-calls.f90: New. * testsuite/libgomp.oacc-fortran/optional-private.f90: New. * testsuite/libgomp.oacc-fortran/optional-reduction.f90: New. * testsuite/libgomp.oacc-fortran/optional-update-device.f90: New. * testsuite/libgomp.oacc-fortran/optional-update-host.f90: New. Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com> From-SVN: r279043
2019-11-20OpenACC "present" subarrays: runtime API return value and unmapping fixesJulian Brown
PR libgomp/92511 libgomp/ * oacc-mem.c (present_create_copy): Fix device pointer return value in case of "present" subarray. Use tgt->tgt_start instead of tgt->to_free in non-present/create case. (delete_copyout): Change error condition to fail only on copies outside of mapped block. Adjust error message accordingly. * testsuite/libgomp.oacc-c-c++-common/copyin-devptr-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/copyin-devptr-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/lib-20.c: Adjust expected error message. * testsuite/libgomp.oacc-c-c++-common/lib-23.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-22.c: Allow test to pass now. * testsuite/libgomp.oacc-c-c++-common/lib-30.c: Likewise. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r278514
2019-05-24re PR libgomp/90585 (libgomp hsa plugin ftbfs in the x32 multilib variant)Jakub Jelinek
PR libgomp/90585 * plugin/plugin-hsa.c: Include gstdint.h. Include inttypes.h only if HAVE_INTTYPES_H is defined. (print_uint64_t): New typedef. (PRIu64): Define if HAVE_INTTYPES_H is not defined. (print_kernel_dispatch, run_kernel): Use PRIu64 macro instead of "lu", cast uint64_t HSA_DEBUG and fprintf arguments to print_uint64_t. (release_kernel_dispatch): Likewise. Cast shadow->debug to uintptr_t before casting to void *. * plugin/plugin-nvptx.c: Include gstdint.h instead of stdint.h. * oacc-mem.c: Don't include config.h nor stdint.h. * target.c: Don't include config.h. * oacc-cuda.c: Likewise. * oacc-host.c: Don't include stdint.h. From-SVN: r271597
2019-05-17OpenACC Profiling Interface (incomplete)Thomas Schwinge
libgomp/ * acc_prof.h: New file. * oacc-profiling.c: Likewise. * Makefile.am (nodist_libsubinclude_HEADERS, libgomp_la_SOURCES): Add these, respectively. * Makefile.in: Regenerate. * env.c (initialize_env): Call goacc_profiling_initialize. * oacc-plugin.c (GOMP_PLUGIN_goacc_thread) (GOMP_PLUGIN_goacc_profiling_dispatch): New functions. * oacc-plugin.h (GOMP_PLUGIN_goacc_thread) (GOMP_PLUGIN_goacc_profiling_dispatch): Declare. * libgomp.map (OACC_2.5.1): Add acc_prof_lookup, acc_prof_register, acc_prof_unregister, and acc_register_library. (GOMP_PLUGIN_1.3): Add GOMP_PLUGIN_goacc_profiling_dispatch, and GOMP_PLUGIN_goacc_thread. * oacc-int.h (struct goacc_thread): Add prof_info, api_info, prof_callbacks_enabled members. (goacc_prof_enabled, goacc_profiling_initialize) (_goacc_profiling_dispatch_p, _goacc_profiling_setup_p) (goacc_profiling_dispatch): Declare. (GOACC_PROF_ENABLED, GOACC_PROFILING_DISPATCH_P) (GOACC_PROFILING_SETUP_P): Define. * oacc-async.c (acc_async_test, acc_async_test_all, acc_wait) (acc_wait_async, acc_wait_all, acc_wait_all_async): Update for OpenACC Profiling Interface. * oacc-cuda.c (acc_get_current_cuda_device) (acc_get_current_cuda_context, acc_get_cuda_stream) (acc_set_cuda_stream): Likewise. * oacc-init.c (acc_init_1, goacc_attach_host_thread_to_device) (acc_init, acc_set_device_type, acc_get_device_type) (acc_get_device_num, goacc_lazy_initialize): Likewise. * oacc-mem.c (acc_malloc, acc_free, memcpy_tofrom_device) (acc_deviceptr, acc_hostptr, acc_is_present, acc_map_data) (acc_unmap_data, present_create_copy, delete_copyout) (update_dev_host): Likewise. * oacc-parallel.c (GOACC_parallel_keyed, GOACC_data_start) (GOACC_data_end, GOACC_enter_exit_data, GOACC_update, GOACC_wait): Likewise. * plugin/plugin-nvptx.c (nvptx_exec, nvptx_alloc, nvptx_free) (GOMP_OFFLOAD_openacc_exec, GOMP_OFFLOAD_openacc_async_exec): Likewise. * libgomp.texi: Update. * testsuite/libgomp.oacc-c-c++-common/acc_prof-dispatch-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/acc_prof-init-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_prof-parallel-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_prof-valid_bytes-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_prof-version-1.c: Likewise. From-SVN: r271346
2019-05-132019-05-13 Chung-Lin Tang <cltang@codesourcery.com>Chung-Lin Tang
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> libgomp/ * libgomp-plugin.h (struct goacc_asyncqueue): Declare. (struct goacc_asyncqueue_list): Likewise. (goacc_aq): Likewise. (goacc_aq_list): Likewise. (GOMP_OFFLOAD_openacc_register_async_cleanup): Remove. (GOMP_OFFLOAD_openacc_async_test): Remove. (GOMP_OFFLOAD_openacc_async_test_all): Remove. (GOMP_OFFLOAD_openacc_async_wait): Remove. (GOMP_OFFLOAD_openacc_async_wait_async): Remove. (GOMP_OFFLOAD_openacc_async_wait_all): Remove. (GOMP_OFFLOAD_openacc_async_wait_all_async): Remove. (GOMP_OFFLOAD_openacc_async_set_async): Remove. (GOMP_OFFLOAD_openacc_exec): Adjust declaration. (GOMP_OFFLOAD_openacc_cuda_get_stream): Likewise. (GOMP_OFFLOAD_openacc_cuda_set_stream): Likewise. (GOMP_OFFLOAD_openacc_async_exec): Declare. (GOMP_OFFLOAD_openacc_async_construct): Declare. (GOMP_OFFLOAD_openacc_async_destruct): Declare. (GOMP_OFFLOAD_openacc_async_test): Declare. (GOMP_OFFLOAD_openacc_async_synchronize): Declare. (GOMP_OFFLOAD_openacc_async_serialize): Declare. (GOMP_OFFLOAD_openacc_async_queue_callback): Declare. (GOMP_OFFLOAD_openacc_async_host2dev): Declare. (GOMP_OFFLOAD_openacc_async_dev2host): Declare. * libgomp.h (struct acc_dispatch_t): Define 'async' sub-struct. (gomp_acc_insert_pointer): Adjust declaration. (gomp_copy_host2dev): New declaration. (gomp_copy_dev2host): Likewise. (gomp_map_vars_async): Likewise. (gomp_unmap_tgt): Likewise. (gomp_unmap_vars_async): Likewise. (gomp_fini_device): Likewise. * oacc-async.c (get_goacc_thread): New function. (get_goacc_thread_device): New function. (lookup_goacc_asyncqueue): New function. (get_goacc_asyncqueue): New function. (acc_async_test): Adjust code to use new async design. (acc_async_test_all): Likewise. (acc_wait): Likewise. (acc_wait_async): Likewise. (acc_wait_all): Likewise. (acc_wait_all_async): Likewise. (goacc_async_free): New function. (goacc_init_asyncqueues): Likewise. (goacc_fini_asyncqueues): Likewise. * oacc-cuda.c (acc_get_cuda_stream): Adjust code to use new async design. (acc_set_cuda_stream): Likewise. * oacc-host.c (host_openacc_exec): Adjust parameters, remove 'async'. (host_openacc_register_async_cleanup): Remove. (host_openacc_async_exec): New function. (host_openacc_async_test): Adjust parameters. (host_openacc_async_test_all): Remove. (host_openacc_async_wait): Remove. (host_openacc_async_wait_async): Remove. (host_openacc_async_wait_all): Remove. (host_openacc_async_wait_all_async): Remove. (host_openacc_async_set_async): Remove. (host_openacc_async_synchronize): New function. (host_openacc_async_serialize): New function. (host_openacc_async_host2dev): New function. (host_openacc_async_dev2host): New function. (host_openacc_async_queue_callback): New function. (host_openacc_async_construct): New function. (host_openacc_async_destruct): New function. (struct gomp_device_descr host_dispatch): Remove initialization of old interface, add intialization of new async sub-struct. * oacc-init.c (acc_shutdown_1): Adjust to use gomp_fini_device. (goacc_attach_host_thread_to_device): Remove old async code usage. * oacc-int.h (goacc_init_asyncqueues): New declaration. (goacc_fini_asyncqueues): Likewise. (goacc_async_copyout_unmap_vars): Likewise. (goacc_async_free): Likewise. (get_goacc_asyncqueue): Likewise. (lookup_goacc_asyncqueue): Likewise. * oacc-mem.c (memcpy_tofrom_device): Adjust code to use new async design. (present_create_copy): Adjust code to use new async design. (delete_copyout): Likewise. (update_dev_host): Likewise. (gomp_acc_insert_pointer): Add async parameter, adjust code to use new async design. (gomp_acc_remove_pointer): Adjust code to use new async design. * oacc-parallel.c (GOACC_parallel_keyed): Adjust code to use new async design. (GOACC_enter_exit_data): Likewise. (goacc_wait): Likewise. (GOACC_update): Likewise. * oacc-plugin.c (GOMP_PLUGIN_async_unmap_vars): Change to assert fail when called, warn as obsolete in comment. * target.c (goacc_device_copy_async): New function. (gomp_copy_host2dev): Remove 'static', add goacc_asyncqueue parameter, add goacc_device_copy_async case. (gomp_copy_dev2host): Likewise. (gomp_map_vars_existing): Add goacc_asyncqueue parameter, adjust code. (gomp_map_pointer): Likewise. (gomp_map_fields_existing): Likewise. (gomp_map_vars_internal): New always_inline function, renamed from gomp_map_vars. (gomp_map_vars): Implement by calling gomp_map_vars_internal. (gomp_map_vars_async): Implement by calling gomp_map_vars_internal, passing goacc_asyncqueue argument. (gomp_unmap_tgt): Remove static, add attribute_hidden. (gomp_unref_tgt): New function. (gomp_unmap_vars_internal): New always_inline function, renamed from gomp_unmap_vars. (gomp_unmap_vars): Implement by calling gomp_unmap_vars_internal. (gomp_unmap_vars_async): Implement by calling gomp_unmap_vars_internal, passing goacc_asyncqueue argument. (gomp_fini_device): New function. (gomp_exit_data): Adjust gomp_copy_dev2host call. (gomp_load_plugin_for_device): Remove old interface, adjust to load new async interface. (gomp_target_fini): Adjust code to call gomp_fini_device. * plugin/plugin-nvptx.c (struct cuda_map): Remove. (struct ptx_stream): Remove. (struct nvptx_thread): Remove current_stream field. (cuda_map_create): Remove. (cuda_map_destroy): Remove. (map_init): Remove. (map_fini): Remove. (map_pop): Remove. (map_push): Remove. (struct goacc_asyncqueue): Define. (struct nvptx_callback): Define. (struct ptx_free_block): Define. (struct ptx_device): Remove null_stream, active_streams, async_streams, stream_lock, and next fields. (enum ptx_event_type): Remove. (struct ptx_event): Remove. (ptx_event_lock): Remove. (ptx_events): Remove. (init_streams_for_device): Remove. (fini_streams_for_device): Remove. (select_stream_for_async): Remove. (nvptx_init): Remove ptx_events and ptx_event_lock references. (nvptx_attach_host_thread_to_device): Remove CUDA_ERROR_NOT_PERMITTED case. (nvptx_open_device): Add free_blocks initialization, remove init_streams_for_device call. (nvptx_close_device): Remove fini_streams_for_device call, add free_blocks destruct code. (event_gc): Remove. (event_add): Remove. (nvptx_exec): Adjust parameters and code. (nvptx_free): Likewise. (nvptx_host2dev): Remove. (nvptx_dev2host): Remove. (nvptx_set_async): Remove. (nvptx_async_test): Remove. (nvptx_async_test_all): Remove. (nvptx_wait): Remove. (nvptx_wait_async): Remove. (nvptx_wait_all): Remove. (nvptx_wait_all_async): Remove. (nvptx_get_cuda_stream): Remove. (nvptx_set_cuda_stream): Remove. (GOMP_OFFLOAD_alloc): Adjust code. (GOMP_OFFLOAD_free): Likewise. (GOMP_OFFLOAD_openacc_register_async_cleanup): Remove. (GOMP_OFFLOAD_openacc_exec): Adjust parameters and code. (GOMP_OFFLOAD_openacc_async_test_all): Remove. (GOMP_OFFLOAD_openacc_async_wait): Remove. (GOMP_OFFLOAD_openacc_async_wait_async): Remove. (GOMP_OFFLOAD_openacc_async_wait_all): Remove. (GOMP_OFFLOAD_openacc_async_wait_all_async): Remove. (GOMP_OFFLOAD_openacc_async_set_async): Remove. (cuda_free_argmem): New function. (GOMP_OFFLOAD_openacc_async_exec): New plugin hook function. (GOMP_OFFLOAD_openacc_create_thread_data): Adjust code. (GOMP_OFFLOAD_openacc_cuda_get_stream): Adjust code. (GOMP_OFFLOAD_openacc_cuda_set_stream): Adjust code. (GOMP_OFFLOAD_openacc_async_construct): New plugin hook function. (GOMP_OFFLOAD_openacc_async_destruct): New plugin hook function. (GOMP_OFFLOAD_openacc_async_test): Remove and re-implement. (GOMP_OFFLOAD_openacc_async_synchronize): New plugin hook function. (GOMP_OFFLOAD_openacc_async_serialize): New plugin hook function. (GOMP_OFFLOAD_openacc_async_queue_callback): New plugin hook function. (cuda_callback_wrapper): New function. (cuda_memcpy_sanity_check): New function. (GOMP_OFFLOAD_host2dev): Remove and re-implement. (GOMP_OFFLOAD_dev2host): Remove and re-implement. (GOMP_OFFLOAD_openacc_async_host2dev): New plugin hook function. (GOMP_OFFLOAD_openacc_async_dev2host): New plugin hook function. From-SVN: r271128
2019-01-01Update copyright years.Jakub Jelinek
From-SVN: r267494
2018-12-14Missing changes from "Adjust copy/copyin/copyout/create for OpenACC 2.5"Thomas Schwinge
Most of that patch's changes were already committed as part of r261813 "Update OpenACC data clause semantics to the 2.5 behavior", but not all of them. libgomp/ * oacc-mem.c (acc_present_or_create): Remove definition and change to alias of acc_create. (acc_present_or_copyin): Remove definition and change to alias of acc_copyin. * oacc-parallel.c (GOACC_enter_exit_data): Call acc_create instead of acc_present_or_create. * testsuite/libgomp.oacc-c-c++-common/data-already-1.c: Remove. * testsuite/libgomp.oacc-c-c++-common/data-already-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-6.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-8.c: Likewise. * testsuite/libgomp.oacc-fortran/data-already-1.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-2.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-3.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-4.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-5.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-6.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-7.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-8.f: Likewise. Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com> From-SVN: r267153
2018-11-062018-11-06 Chung-Lin Tang <cltang@codesourcery.com>Chung-Lin Tang
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> libgomp/ * oacc-mem.c (memcpy_tofrom_device): New function, combined from acc_memcpy_to/from_device functions, now with async parameter. (acc_memcpy_to_device): Modify to use memcpy_tofrom_device. (acc_memcpy_from_device): Likewise. (acc_memcpy_to_device_async): New API function. (acc_memcpy_from_device_async): Likewise. (present_create_copy): Add async parameter and async setting/unsetting. (acc_create): Adjust present_create_copy call. (acc_copyin): Likewise. (acc_present_or_create): Likewise. (acc_present_or_copyin): Likewise. (acc_create_async): New API function. (acc_copyin_async): New API function. (delete_copyout): Add async parameter and async setting/unsetting. (acc_delete): Adjust delete_copyout call. (acc_copyout): Likewise. (acc_delete_async): New API function. (acc_copyout_async): Likewise. (update_dev_host): Add async parameter and async setting/unsetting. (acc_update_device): Adjust update_dev_host call. (acc_update_self): Likewise. (acc_update_device_async): New API function. (acc_update_self_async): Likewise. * openacc.h (acc_copyin_async): Declare new API function. (acc_create_async): Likewise. (acc_copyout_async): Likewise. (acc_delete_async): Likewise. (acc_update_device_async): Likewise. (acc_update_self_async): Likewise. (acc_memcpy_to_device_async): Likewise. (acc_memcpy_from_device_async): Likewise. * openacc_lib.h (acc_copyin_async_32_h): New subroutine. (acc_copyin_async_64_h): New subroutine. (acc_copyin_async_array_h): New subroutine. (acc_create_async_32_h): New subroutine. (acc_create_async_64_h): New subroutine. (acc_create_async_array_h): New subroutine. (acc_copyout_async_32_h): New subroutine. (acc_copyout_async_64_h): New subroutine. (acc_copyout_async_array_h): New subroutine. (acc_delete_async_32_h): New subroutine. (acc_delete_async_64_h): New subroutine. (acc_delete_async_array_h): New subroutine. (acc_update_device_async_32_h): New subroutine. (acc_update_device_async_64_h): New subroutine. (acc_update_device_async_array_h): New subroutine. (acc_update_self_async_32_h): New subroutine. (acc_update_self_async_64_h): New subroutine. (acc_update_self_async_array_h): New subroutine. * openacc.f90 (acc_copyin_async_32_h): New subroutine. (acc_copyin_async_64_h): New subroutine. (acc_copyin_async_array_h): New subroutine. (acc_create_async_32_h): New subroutine. (acc_create_async_64_h): New subroutine. (acc_create_async_array_h): New subroutine. (acc_copyout_async_32_h): New subroutine. (acc_copyout_async_64_h): New subroutine. (acc_copyout_async_array_h): New subroutine. (acc_delete_async_32_h): New subroutine. (acc_delete_async_64_h): New subroutine. (acc_delete_async_array_h): New subroutine. (acc_update_device_async_32_h): New subroutine. (acc_update_device_async_64_h): New subroutine. (acc_update_device_async_array_h): New subroutine. (acc_update_self_async_32_h): New subroutine. (acc_update_self_async_64_h): New subroutine. (acc_update_self_async_array_h): New subroutine. * libgomp.map (OACC_2.5): Add acc_copyin_async*, acc_copyout_async*, acc_copyout_finalize_async*, acc_create_async*, acc_delete_async*, acc_delete_finalize_async*, acc_memcpy_from_device_async*, acc_memcpy_to_device_async*, acc_update_device_async*, and acc_update_self_async* entries. * testsuite/libgomp.oacc-c-c++-common/lib-94.c: New test. * testsuite/libgomp.oacc-c-c++-common/lib-95.c: New test. * testsuite/libgomp.oacc-fortran/lib-16.f90: New test. From-SVN: r265842
2018-06-20Update OpenACC data clause semantics to the 2.5 behaviorChung-Lin Tang
gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_{FINALIZE,IF_PRESENT}. Remove PRAGMA_OACC_CLAUSE_PRESENT_OR_{COPY,COPYIN,COPYOUT,CREATE}. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Add support for finalize and if_present. Make present_or_{copy,copyin,copyout,create} aliases to their non-present_or_* counterparts. Make 'self' an alias to PRAGMA_OACC_CLAUSE_HOST. (c_parser_oacc_data_clause): Update GOMP mappings for PRAGMA_OACC_CLAUSE_{COPY,COPYIN,COPYOUT,CREATE,DELETE}. Remove PRAGMA_OACC_CLAUSE_{SELF,PRESENT_OR_*}. (c_parser_oacc_all_clauses): Handle finalize and if_present clauses. Remove support for present_or_* clauses. (OACC_KERNELS_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_PARALLEL_CLAUSE_MASK): Likewise. (OACC_DECLARE_CLAUSE_MASK): Likewise. (OACC_DATA_CLAUSE_MASK): Likewise. (OACC_ENTER_DATA_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSE_MASK): Add FINALIZE clause. (OACC_UPDATE_CLAUSE_MASK): Remove SELF, add IF_PRESENT. (c_parser_oacc_declare): Remove PRESENT_OR_* clauses. * c-typeck.c (c_finish_omp_clauses): Handle IF_PRESENT and FINALIZE. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Add support for finalize and if_present. Make present_or_{copy,copyin,copyout,create} aliases to their non-present_or_* counterparts. Make 'self' an alias to PRAGMA_OACC_CLAUSE_HOST. (cp_parser_oacc_data_clause): Update GOMP mappings for PRAGMA_OACC_CLAUSE_{COPY,COPYIN,COPYOUT,CREATE,DELETE}. Remove PRAGMA_OACC_CLAUSE_{SELF,PRESENT_OR_*}. (cp_parser_oacc_all_clauses): Handle finalize and if_present clauses. Remove support for present_or_* clauses. (OACC_KERNELS_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_PARALLEL_CLAUSE_MASK): Likewise. (OACC_DECLARE_CLAUSE_MASK): Likewise. (OACC_DATA_CLAUSE_MASK): Likewise. (OACC_ENTER_DATA_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSE_MASK): Add FINALIZE clause. (OACC_UPDATE_CLAUSE_MASK): Remove SELF, add IF_PRESENT. (cp_parser_oacc_declare): Remove PRESENT_OR_* clauses. * pt.c (tsubst_omp_clauses): Handle IF_PRESENT and FINALIZE. * semantics.c (finish_omp_clauses): Handle IF_PRESENT and FINALIZE. gcc/fortran/ * gfortran.h (gfc_omp_clauses): Add unsigned if_present, finalize bitfields. * openmp.c (enum omp_mask2): Remove OMP_CLAUSE_PRESENT_OR_*. Add OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (gfc_match_omp_clauses): Update handling of copy, copyin, copyout, create, deviceptr, present_of_*. Add support for finalize and if_present. (OACC_PARALLEL_CLAUSES): Remove PRESENT_OR_* clauses. (OACC_KERNELS_CLAUSES): Likewise. (OACC_DATA_CLAUSES): Likewise. (OACC_DECLARE_CLAUSES): Likewise. (OACC_UPDATE_CLAUSES): Add IF_PRESENT clause. (OACC_ENTER_DATA_CLAUSES): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSES): Add FINALIZE clause. (gfc_match_oacc_declare): Update to OpenACC 2.5 semantics. * trans-openmp.c (gfc_trans_omp_clauses): Add support for IF_PRESENT and FINALIZE. gcc/ * gimplify.c (gimplify_scan_omp_clauses): Add support for OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (gimplify_adjust_omp_clauses): Likewise. (gimplify_oacc_declare_1): Add support for GOMP_MAP_RELEASE, remove support for GOMP_MAP_FORCE_{ALLOC,TO,FROM,TOFROM}. (gimplify_omp_target_update): Update handling of acc update and enter/exit data. * omp-low.c (install_var_field): Remove unused parameter base_pointers_restrict. (scan_sharing_clauses): Remove base_pointers_restrict parameter. Update call to install_var_field. Handle OMP_CLAUSE_{IF_PRESENT, FINALIZE} (omp_target_base_pointers_restrict_p): Delete. (scan_omp_target): Update call to scan_sharing_clauses. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_{IF_PRESENT, FINALIZE}. * tree-nested.c (convert_nonlocal_omp_clauses): Handle OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (convert_local_omp_clauses): Likewise. * tree-pretty-print.c (dump_omp_clause): Likewise. * tree.c (omp_clause_num_ops): Add entries for OMP_CLAUSE_{IF_PRESENT, FINALIZE}. (omp_clause_code_name): Likewise. gcc/testsuite/ * c-c++-common/goacc/declare-1.c: Update test case to utilize OpenACC 2.5 data clause semantics. * c-c++-common/goacc/declare-2.c: Likewise. * c-c++-common/goacc/default-4.c: Likewise. * c-c++-common/goacc/finalize-1.c: New test. * c-c++-common/goacc/kernels-alias-2.c: Update test case to utilize OpenACC 2.5 data clause semantics. * c-c++-common/goacc/kernels-alias.c: Likewise. * c-c++-common/goacc/routine-5.c: Likewise. * c-c++-common/goacc/update-if_present-1.c: New test. * c-c++-common/goacc/update-if_present-2.c: New test. * g++.dg/goacc/template.C: Update test case to utilize OpenACC 2.5 data clause semantics. * gfortran.dg/goacc/combined-directives.f90: Likewise. * gfortran.dg/goacc/data-tree.f95: Likewise. * gfortran.dg/goacc/declare-2.f95: Likewise. * gfortran.dg/goacc/default-4.f: Likewise. * gfortran.dg/goacc/enter-exit-data.f95: Likewise. * gfortran.dg/goacc/finalize-1.f: New test. * gfortran.dg/goacc/kernels-alias-2.f95: Update test case to utilize OpenACC 2.5 data clause semantics. * gfortran.dg/goacc/kernels-alias.f95: Likewise. * gfortran.dg/goacc/kernels-tree.f95: Likewise. * gfortran.dg/goacc/nested-function-1.f90: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. * gfortran.dg/goacc/reduction-promotions.f90: Likewise. * gfortran.dg/goacc/update-if_present-1.f90: New test. * gfortran.dg/goacc/update-if_present-2.f90: New test. 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. * testsuite/libgomp.oacc-c-c++-common/data-already-1.c: Update test case to utilize OpenACC 2.5 data clause semantics. * testsuite/libgomp.oacc-c-c++-common/data-already-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-6.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-8.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-16.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-25.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-32.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-83.c: Likewise. * testsuite/libgomp.oacc-fortran/data-5.f90: New test. * testsuite/libgomp.oacc-fortran/data-already-1.f: Update test case to utilize OpenACC 2.5 data clause semantics. * testsuite/libgomp.oacc-fortran/data-already-2.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-3.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-4.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-5.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-6.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-7.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-8.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-32-1.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r261813
2018-05-09[openacc] Factor out async argument utility functionsTom de Vries
2018-05-09 Tom de Vries <tom@codesourcery.com> PR libgomp/83792 * oacc-int.h (async_valid_stream_id_p, async_valid_p) (async_synchronous_p): New function. * oacc-async.c (acc_async_test, acc_wait, acc_wait_all_async): Use async_valid_p. * oacc-cuda.c (acc_get_cuda_stream, acc_set_cuda_stream): Use async_valid_stream_id_p. * oacc-mem.c (gomp_acc_remove_pointer): Use async_synchronous_p. * oacc-parallel.c (GOACC_parallel_keyed): Same. From-SVN: r260081
2018-01-03Update copyright years.Jakub Jelinek
From-SVN: r256169
2017-05-24C/C++ OpenACC: acc_pcopyin, acc_pcreateThomas Schwinge
libgomp/ * openacc.h (acc_pcopyin, acc_pcreate): Provide prototypes instead of preprocessor definitions. * libgomp.h (strong_alias): Guard by "#ifdef HAVE_ATTRIBUTE_ALIAS". * oacc-mem.c: Provide "acc_pcreate" as alias for "acc_present_or_create", and "acc_pcopyin" as alias for "acc_present_or_copyin". * libgomp.map: New version "OACC_2.0.1". (OACC_2.0.1): Add "acc_pcopyin", and "acc_pcreate". * testsuite/libgomp.oacc-c-c++-common/lib-38.c: Remove, merging its content into... * testsuite/libgomp.oacc-c-c++-common/lib-32.c: ... this file. Extend testing. From-SVN: r248410
2017-01-01Update copyright years.Jakub Jelinek
From-SVN: r243994