public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tschwinge at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/106643] [gfortran + OpenACC] Allocate in module causes refcount error
Date: Wed, 02 Nov 2022 21:32:02 +0000	[thread overview]
Message-ID: <bug-106643-4-orku9MhBtG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106643-4@http.gcc.gnu.org/bugzilla/>

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

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |tschwinge at gcc dot gnu.org
         Resolution|---                         |FIXED
                 CC|                            |tschwinge at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
(In reply to Henry Le Berre from comment #0)
> ```
> /nethome/hberre3/USERSCRATCH/build-gcc-amdgpu//gcc/libgomp/oacc-mem.c:1153:
> goacc_enter_data_internal: Assertion `n->refcount != REFCOUNT_INFINITY &&
> n->refcount != REFCOUNT_LINK' failed.
> ```

ACK, and thanks for your detailed report.

> In order to generate this error, I had to create and dynamically allocate
> the array in another module. I initially wrote this in a single F90 file but
> the executable ran as expected.

Maybe the difference was that the '!$acc declare create(valls)' was in a
different scope?  Global scope (Fortran 'module' scope) is important here; then
"the associated region is the implicit region for the whole program" (as you
also had noted), which triggers this code path.

There are cases where it's relevant, but here, the separate module/main program
files are not necessary for demonstrating the issue.

On the other hand, it's helpful to include an OpenACC compute construct where
for 'valls' there is no explicit or implicit data clause due to "exposed
variable access" (OpenACC 3.2 term).  That means, in a separate 'subroutine'
accessing 'valls' in '!$acc declare create(valls)' instead of dummy argument. 
(... as I've implemented in the test case.)

So this is now fixed for GCC 13; not planning on backporting to current GCC
release branches.


> Our main code currently doesn't call `!$acc enter data create` for
> dynamically allocated arrays since it relies on NVIDIA (/PGI) hooking into
> the `allocate` call on the CPU. I ran into the above error when converting
> our allocation/deallocation routines.

ACK, GCC release branches and master branch are still missing support for
OpenACC "Changes from Version 2.0 to 2.5": "The 'declare create' directive with
a Fortran 'allocatable' has new behavior".  Preliminary support exists on the
devel/omp/gcc-12 branch (and earlier development branches), but needs to be
revised for upstream submission.

  parent reply	other threads:[~2022-11-02 21:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 15:37 [Bug libgomp/106643] New: " hberre3 at gatech dot edu
2022-08-31  2:16 ` [Bug libgomp/106643] " hberre3 at gatech dot edu
2022-11-02 20:03 ` cvs-commit at gcc dot gnu.org
2022-11-02 20:03 ` cvs-commit at gcc dot gnu.org
2022-11-02 21:32 ` tschwinge at gcc dot gnu.org [this message]
2022-11-28 22:05 ` pinskia 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-106643-4-orku9MhBtG@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).