From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 928A4385740B; Wed, 2 Nov 2022 21:32:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 928A4385740B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667424723; bh=ov8Css8r4a4Zw1Zc5YrIQCf4Hlu8ViQDbDjKeaSrZhs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DgLj84TDc0mhVHFcq9W2KSvx3wNwaJiz5Qinybr6zPcOaIuuI1PQcOKfm+75VHYaj kPFx5X+FJIQoE9uF9fSgBtSluoCgqMHGX/WldyzCLFPmd0k+0JC7S3HjNp+hLGVma9 /d3J4Es4AGN5PQ18IKXD4opU4RuXdUuoAjtOSxNA= From: "tschwinge at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: openacc X-Bugzilla-Severity: normal X-Bugzilla-Who: tschwinge at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: tschwinge at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to resolution cc bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106643 Thomas Schwinge changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |tschwinge at gcc do= t gnu.org Resolution|--- |FIXED CC| |tschwinge at gcc dot gnu.o= rg Status|UNCONFIRMED |RESOLVED --- Comment #4 from Thomas Schwinge --- (In reply to Henry Le Berre from comment #0) > ``` > /nethome/hberre3/USERSCRATCH/build-gcc-amdgpu//gcc/libgomp/oacc-mem.c:115= 3: > goacc_enter_data_internal: Assertion `n->refcount !=3D REFCOUNT_INFINITY = && > n->refcount !=3D 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 pro= gram files are not necessary for demonstrating the issue. On the other hand, it's helpful to include an OpenACC compute construct whe= re 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 argumen= t.=20 (... 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 t= he devel/omp/gcc-12 branch (and earlier development branches), but needs to be revised for upstream submission.=