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 middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
Date: Wed, 24 Nov 2021 18:41:21 +0000	[thread overview]
Message-ID: <bug-103416-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103416
           Summary: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n
                    [len: 4][implicit])
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: cltang at gcc dot gnu.org, jakub at gcc dot gnu.org
  Target Milestone: ---

Side remark: PR80330 (suggested as possible duplicate) looks a bit similar from
the subject line.

Caused by commit r12-5194-gb7e20480630e3eeb9eed8b3941da3b3f0c22c969
Author: Chung-Lin Tang <cltang@codesourcery.com>
Date:   Fri Nov 12 20:29:00 2021 +0800

    openmp: Relax handling of implicit map vs. existing device mappings

Works when undoing the omp-low.c + gimplify.c bits.

I am not 100% sure whether there is some other issue - and this patch just
exposes it or whether it is the cause. However, the dump looks in any case
wrong/odd.

For some reasons, replacing '8' (double-precision complex) by '4'
(single-precision complex) makes it pass. The ptx assembler looks fine at a
glance, but I do observe that there are other DCmode related issues: PR102429
(nvptx, SIMT_XCHG_BFLY)

 * * *

In any case, running
https://github.com/TApplencourt/OvO/blob/master/test_src/fortran/hierarchical_parallelism/memcopy-double_complex/target_parallel_do.F90
or the program below fails with nvptx offloading with:

  libgomp: cuCtxSynchronize error: misaligned address
  libgomp: cuMemFree_v2 error: misaligned address
  libgomp: device finalization failed

PROGRAM target_parallel_do
  implicit none
  INTEGER :: i0, N
  COMPLEX(8) :: scalar
  COMPLEX(8), ALLOCATABLE :: src(:)
  N = 1
  ALLOCATE(src(1), stat=i0)
  !$OMP TARGET PARALLEL DO map(to: src) map(from: scalar) private(i0)
  DO i0 = 1, N
    scalar%re = src(i0)%re
  END DO
END PROGRAM target_parallel_do

 * * *

When playing around using not the combined directive but

  !$OMP TARGET map(to: src) map(from: scalar)
  !$OMP PARALLEL DO private(i0)
  DO i0 = 1, N
    scalar%re = src(i0)%re
  END DO

it started to work. Looking at the dump of the failing version:

          D.4246 = n;
#pragma omp target map(to:D.4246 [len: 4][implicit]) firstprivate(n) ...
  ...
  #pragma omp parallel firstprivate(D.4246) firstprivate(n) ...


while the second, working version has:

#pragma omp target firstprivate(n)
...
D.4246 = n;
....
  #pragma omp parallel firstprivate(D.4246)

 * * *

In any case, it is very odd to have both a 'map(to:' and a 'firstprivate' for
the same variable. Especially, if it causes wrong results/a crash.

             reply	other threads:[~2021-11-24 18:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24 18:41 burnus at gcc dot gnu.org [this message]
2021-11-24 19:05 ` [Bug middle-end/103416] " cltang at gcc dot gnu.org
2021-11-25  7:18 ` rguenth at gcc dot gnu.org
2021-11-25 10:07 ` burnus at gcc dot gnu.org
2021-11-25 10:52 ` burnus at gcc dot gnu.org
2021-11-25 11:21 ` burnus at gcc dot gnu.org
2021-11-25 11:24 ` burnus at gcc dot gnu.org
2021-12-02 11:07 ` [Bug middle-end/103416] [OpenMP] Double mapping via " burnus at gcc dot gnu.org
2022-05-06  8:32 ` [Bug fortran/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit]) of loop bounds jakub at gcc dot gnu.org
2023-05-08 12:23 ` rguenth 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-103416-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).