public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96668] New: [OpenMP] Re-mapping allocated but previously unallocated allocatable does not work
Date: Tue, 18 Aug 2020 06:56:54 +0000	[thread overview]
Message-ID: <bug-96668-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96668

            Bug ID: 96668
           Summary: [OpenMP] Re-mapping allocated but previously
                    unallocated allocatable does not work
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The exact behaviour is not well specified in OpenMP 4.5 or 5.0 but at least
with 'always' the following is expected to map.
(See OpenMP Issue 2152 + upcoming OpenMP TR9 – which require the always
modifier. There is code which expects that implicit mapping and mapping without
always modifier also works.)

For pointers, at least OpenMP 5.0 seems to require that the POINTER target is
automatically mapped:

module m
implicit none
  integer, pointer :: p1 => null()
  integer, pointer :: p1 => null()
  integer, allocatable :: a1, a2(:)
  !$omp declare target(p1, p2, a1, a2)
end module m

use m
implicit none
  integer, pointer :: q1, q2(:)
  q1 => null()
  q2 => null()
  integer, allocatable :: b1, b2(:)
  allocate (a1, source=12)
  allocate (a2, source=[11,22,33])
  allocate (p1, source=42)
  allocate (p2, source=[1,3,5,7])

  !$omp target data map(b1, b2, q1, q2)
     allocate (b1, source=35)
     allocate (b2, source=[10,11,12,13,14])
     allocate (q1, source=4)
     allocate (q2, source=[9,8,7,6,5,4])

     ! allocatable, TR9 requires 'always' modifier:
     !$omp target map(always, tofrom: a1, a2, b1, b2)
       if (.not. allocated(a1)) stop 1
       if (.not. allocated(a2)) stop 1
       if (.not. allocated(b1)) stop 1
       if (.not. allocated(b2)) stop 1
       if (size(a2) /= 3) stop 1
       if (size(b2) /= 5) stop 1
       if (a1 /= 12) stop 1
       if (any (a2 /= [11,22,33])) stop 1
       if (b1 /= 42) stop 1
       if (any (b2 /= [10,11,12,13,14])) stop 1
       a1 = 3
       a2(:) = [44,55,66]
       b1 = 68
       b2(:) = [101, 102, 103, 104, 105]
     !$omp end target

     ! pointer: allegedly target is automatically mapped
     ! without requiring an explicit mapping or even the always modifier
     !$omp target  !! map(always, tofrom: p1, p2, q1, q2)
       if (.not. associated(p1)) stop 1
       if (.not. associated(p2)) stop 1
       if (.not. associated(q1)) stop 1
       if (.not. associated(q2)) stop 1
       if (size(p2) /= 4) stop 1
       if (size(q2) /= 6) stop 1
       if (p1 /= 42) stop 1
       if (any (p2 /= [1,3,5,7])) stop 1
       if (q1 /= 4) stop 1
       if (any (q2 /= [9,8,7,6,5,4])) stop 1
       p1 = 373
       p2(:) = [2,4,6,8]
       q1 = 497
       q2(:) = [-1, -2, -3, -4, -5, -6]
     !$omp end target
  !$omp end target data

  if (a1 /= 3) stop 1
  if (any (a2 /= [44,55,66])) stop 1
  if (b1 /= 68) stop 1
  if (any (b2 /= [10,11,12,13,14])) stop 1

  if (p1 /= 373) stop 1
  if (any (p2 /= [2,4,6,8])) stop 1
  if (q1 /= 397) stop 1
  if (any (q2 /= [-1, -2, -3, -4, -5, -6])) stop 1

  deallocate(a1, a2, b1, b2, p1, p2, q1, q2)
end

             reply	other threads:[~2020-08-18  6:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  6:56 burnus at gcc dot gnu.org [this message]
2020-08-18  8:59 ` [Bug fortran/96668] " burnus at gcc dot gnu.org
2020-08-18 10:26 ` cltang at gcc dot gnu.org
2020-08-18 16:11 ` kargl at gcc dot gnu.org
2020-08-18 17:02 ` burnus at gcc dot gnu.org
2020-09-15  7:25 ` cvs-commit at gcc dot gnu.org
2020-09-15  7:39 ` burnus at gcc dot gnu.org
2020-09-15 19:44 ` cvs-commit at gcc dot gnu.org
2022-03-10 10:22 ` burnus at gcc dot gnu.org
2022-11-02 20:03 ` cvs-commit at gcc dot gnu.org

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=bug-96668-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).