public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Julian Brown <julian@codesourcery.com>, <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH v5 3/4] OpenMP: Pointers and member mappings
Date: Wed, 7 Dec 2022 17:31:20 +0100	[thread overview]
Message-ID: <aa0da1c7-4bc3-6fc3-ee00-1c2cc04fdcde@codesourcery.com> (raw)
In-Reply-To: <80f87c37a4f8b9f1f61c1668ecb750cefb1aec77.1666088224.git.julian@codesourcery.com>

Hi Julian,

I think this patch is OK; however, at least for gimplify.cc Jakub needs to have a second look.

As remarked for the 2/4 patch, I believe mapping 'map(tofrom: var%f(2:3))' should work
without explicitly mapping 'map(tofrom: var%f)'
(→ [TR11 157:21-26] (approx. [5.2 154:22-27], [5.1 352:17-22], [5.0 320:22-27]).
→ https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608100.html (+ previously in the thread).

Testing the patch, that seems to work fine (i.e. contrary to C/C++, cf. 2/4),
which matches the dump and, if I understood correctly, also your (Julian's) expectation.
Thus, no need to modify the code part.

Regarding the testcases:
* I would prefer if you don't modify the existing libgomp.fortran/struct-elem-map-1.f90 testcase;
   However, you could add your version as another variant ('subroutine nine()', 'four_var()' or
   what's the next free name, possibly with a comment telling that it is 'four()' but with an
   added explicit basepointer mapping.).

* As the new version should map *less*, I wonder whether some -fdump-tree-{original,gimple,omplower}
   scan-dump-tree checks would be useful besides testing whether it works at run time.
   (Your decision regarding which tree, which testcases and whether at all.)

* Likewise, maybe a 'target enter/exit data' check? However, you might very well run into my
   'omp target data exit' issue, cf. https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604887.html
   (needs to be revised based on Jakub's comments; I think those were on IRC only – the problem is that
   not only 'alloc' is affected but also 'from' etc.)

On 18.10.22 12:39, Julian Brown wrote:
> Implementing the "omp declare mapper" functionality, I noticed some
> cases where handling of derived type members that are pointers doesn't
> seem to be quite right. At present, a type such as this:
> ...
>    map(to: tvar%arrptr) map(tofrom: tvar%arrptr(3:8))
>
> and then instead we should follow (OpenMP 5.2, 5.8.3 "map Clause"):
> ...
>    2) map(tofrom: tvar%arrptr(3:8)   -->
>    GOMP_MAP_TOFROM         *tvar%arrptr%data(3)  (size 8-3+1, etc.)
>    GOMP_MAP_TO_PSET        tvar%arrptr
>    GOMP_MAP_ATTACH_DETACH  tvar%arrptr%data      (bias 3, etc.)
>
> ...
> Additionally, the next patch in the series adds a runtime diagnostic
> for the (illegal) case where 'i' and 'j' are different.
>
> 2022-10-18  Julian Brown  <julian@codesourcery.com>
>
> gcc/fortran/
>       * dependency.cc (gfc_omp_expr_prefix_same): New function.
>       * dependency.h (gfc_omp_expr_prefix_same): Add prototype.
>       * gfortran.h (gfc_omp_namelist): Add "duplicate_of" field to "u2"
>       union.
>       * trans-openmp.cc (dependency.h): Include.
>       (gfc_trans_omp_array_section): Use GOMP_MAP_TO_PSET unconditionally for
>       mapping array descriptors.
>       (gfc_symbol_rooted_namelist): New function.
>       (gfc_trans_omp_clauses): Check subcomponent and subarray/element
>       accesses elsewhere in the clause list for pointers to derived types or
>       array descriptors, and adjust or drop mapping nodes appropriately.
>
> gcc/
>       * gimplify.cc (omp_tsort_mapping_groups): Process nodes that have
>       OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P set after those that don't.
>       (omp_accumulate_sibling_list): Adjust GOMP_MAP_TO_PSET handling.
>       Remove GOMP_MAP_ALWAYS_POINTER handling.
>
> libgomp/
>       * testsuite/libgomp.fortran/map-subarray.f90: New test.
>       * testsuite/libgomp.fortran/map-subarray-2.f90: New test.
>       * testsuite/libgomp.fortran/map-subarray-3.f90: New test.
>       * testsuite/libgomp.fortran/map-subarray-4.f90: New test.
>       * testsuite/libgomp.fortran/map-subarray-6.f90: New test.
>       * testsuite/libgomp.fortran/map-subarray-7.f90: New test.
>       * testsuite/libgomp.fortran/map-subcomponents.f90: New test.
>       * testsuite/libgomp.fortran/struct-elem-map-1.f90: Adjust for
>       descriptor-mapping changes.  Remove XFAIL.
...
> --- a/libgomp/testsuite/libgomp.fortran/struct-elem-map-1.f90
> +++ b/libgomp/testsuite/libgomp.fortran/struct-elem-map-1.f90
> @@ -229,7 +229,8 @@ contains
>
>   !   !$omp target map(tofrom: var%d(4:7), var%f(2:3), var%str2(2:3)) &
>   !   !$omp&       map(tofrom: var%str4(2:2), var%uni2(2:3), var%uni4(2:2))
> -    !$omp target map(tofrom: var%d(4:7), var%f(2:3), var%str2(2:3), var%uni2(2:3))
> +    !$omp target map(to: var%f) map(tofrom: var%d(4:7), var%f(2:3), &
> +    !$omp&       var%str2(2:3), var%uni2(2:3))
This adds 'to: var%f'  (to the existing 'var%f(2:3)') – where 'f' is a
POINTER. As discussed at the top, I prefer to leave it as is – and
possibly just add another test-function, replicating this function and
only there adding the basepointer as additional list item.
> -    !$omp target map(tofrom: var%f(2:3))
> +    !$omp target map(to: var%f) map(tofrom: var%f(2:3))
likewise.
> -    !$omp target map(tofrom: var%d(5), var%f(3), var%str2(3), var%uni2(3))
> +    !$omp target map(to: var%f) map(tofrom: var%d(5), var%f(3), &
> +    !$omp&                                  var%str2(3), var%uni2(3))
likewise.
> -    !$omp target map(tofrom: var%f(2:3))
> +    !$omp target map(to: var%f) map(tofrom: var%f(2:3))

likewise.

Thanks,

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

  reply	other threads:[~2022-12-07 16:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 10:39 [PATCH v5 0/4] OpenMP/OpenACC: Fortran array descriptor mappings Julian Brown
2022-10-18 10:39 ` [PATCH v5 1/4] OpenMP/OpenACC: Reindent TO/FROM/_CACHE_ stanza in {c_}finish_omp_clause Julian Brown
2022-10-18 10:39 ` [PATCH v5 2/4] OpenMP/OpenACC: Rework clause expansion and nested struct handling Julian Brown
2022-10-18 12:33   ` Julian Brown
2022-10-18 12:33     ` Julian Brown
2022-12-07 14:54   ` Tobias Burnus
2022-12-07 15:16     ` Julian Brown
2022-12-07 16:13       ` Tobias Burnus
2022-12-12 15:19         ` Julian Brown
2022-10-18 10:39 ` [PATCH v5 3/4] OpenMP: Pointers and member mappings Julian Brown
2022-12-07 16:31   ` Tobias Burnus [this message]
2022-12-15 14:54     ` Julian Brown
2022-12-15 16:46       ` Julian Brown
2022-10-18 10:39 ` [PATCH v5 4/4] OpenMP/OpenACC: Unordered/non-constant component offset runtime diagnostic Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa0da1c7-4bc3-6fc3-ee00-1c2cc04fdcde@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=julian@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).