]> git.ipfire.org Git - thirdparty/gcc.git/commit
openacc: Deep copy attach/detach should not affect reference counts
authorJulian Brown <julian@codesourcery.com>
Thu, 18 Jun 2020 12:11:08 +0000 (05:11 -0700)
committerJulian Brown <julian@codesourcery.com>
Wed, 29 Jul 2020 10:48:49 +0000 (03:48 -0700)
commitd9a77a17333ab93b023b13c41758adb3dc72ad1c
treeb0223134eb2da6ef18efaef6e8908024ab9872ee
parent2ced237ad122091d4c050f2234349cb90e127e54
openacc: Deep copy attach/detach should not affect reference counts

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>
(cherry picked from commit bc4ed079dc09a62168699227a794ac52a5b6f6a4)
libgomp/libgomp.h
libgomp/oacc-mem.c
libgomp/target.c
libgomp/testsuite/libgomp.oacc-c-c++-common/mdc-refcount-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/mdc-refcount-2.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/mdc-refcount-3.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-fortran/deep-copy-6-no_finalize.F90
libgomp/testsuite/libgomp.oacc-fortran/deep-copy-6.f90