[PATCH, og8] OpenACC: attach/detach array slices on dereferenced struct members

Julian Brown julian@codesourcery.com
Thu Jan 31 11:38:00 GMT 2019


Hi,

This patch adds support for array slices on dereferenced struct
members, e.g.:

#pragma acc parallel copy(mystruct->a[0:n])

This works by making a new mapping pair for each struct pointer used in
the directive ("alloc(mystruct) firstprivate_pointer(mystruct)").

The C/C++ parsers permit chained dereferences
("mystruct->anotherstruct->bla[0:n]"). In this case, the current
implementation performs an attach/detach operation on the
final/innermost dereference only (so, "bla[0:n]" attaches to
the appropriate offset in "anotherstruct"). Other options might be to
explicitly disallow chained dereferences, or attach the whole chain
sequentially. The standard isn't helpful here (as of 2.6), but I think
that the chosen behaviour is reasonably consistent.

Arrays of structures aren't (yet?) supported
(either "copy(structarr[i].a[0:n])" or "copy(structarr[i]->a[0:n])"). I
added a basic test case for that.

Tested with offloading to nvptx, no regressions and the new tests pass.

I will apply shortly (to the og8 branch).

Thanks,

Julian

ChangeLog

    gcc/c/
    * c-typeck.c (handle_omp_array_sections_1): Handle chained dereferences.
    (c_finish_omp_clauses): Likewise.

    gcc/cp/
    * semantics.c (handle_omp_array_sections_1): Handle array section on
    dereferenced struct member.
    (finish_omp_clauses): Don't error on multiple dereferenced struct
    elements with the same base.

    gcc/
    * gimplify.c (gimplify_scan_omp_clauses): Handle array sections on
    dereferenced struct members.

    gcc/testsuite/
    * c-c++-common/goacc/deep-copy-arrayofstruct.c: New test.

    libgomp/
    * testsuite/libgomp.oacc-c++/deep-copy-12.C: New test.
    * testsuite/libgomp.oacc-c++/deep-copy-13.C: New test.
    * testsuite/libgomp.oacc-c-c++-common/deep-copy-9.c: New test.
    * testsuite/libgomp.oacc-c-c++-common/deep-copy-10.c: New test.
    * testsuite/libgomp.oacc-c-c++-common/deep-copy-11.c: New test.
    * testsuite/libgomp.oacc-c-c++-common/deep-copy-14.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attach-detach-derefs-1.diff
Type: text/x-patch
Size: 18351 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190131/71d1cf24/attachment.bin>


More information about the Gcc-patches mailing list