From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D9EF3858D1E; Tue, 2 May 2023 15:28:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D9EF3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683041285; bh=kVnAGPOzwaXVva4Noavke5Xnh/wHmS/8lcdu4U7bzps=; h=From:To:Subject:Date:From; b=CULTuxUM+zAW1GS8cRagPk2z4ZdXRALuZNniIXbfa1k5iXVhSWkxC7EefU56GsxaG EjaQauN9ZCDaJWDQukwZniyW5tSQRBggwE6WzbR64MV2uNv21ObPr7iwKa1SzEg13F zKIPj1coHR66XGkV176Hf99m3Jm496UnCKTys6Dc= From: "patrick.begou@univ-grenoble-alpes.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109699] New: With OpenACC reallocating a fortran pointer on a user type with allocatable fails. Date: Tue, 02 May 2023 15:28:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: patrick.begou@univ-grenoble-alpes.fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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=3D109699 Bug ID: 109699 Summary: With OpenACC reallocating a fortran pointer on a user type with allocatable fails. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: patrick.begou@univ-grenoble-alpes.fr Target Milestone: --- Created attachment 54970 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54970&action=3Dedit Test case to show the problem With OpenACC reallocating a fortran pointer on a user type with allocatable fails.=20 Type is: type r2tab double precision, dimension(:,:), allocatable :: val integer :: dim1 integer :: dim2 end type r2tab Variable in main to offload is: type(r2tab), pointer :: tab=3D>null() Gfortran 14.0 from master branch commit 8d2793ef6b15dbdd347c854f663eb145af5ee593 Author: Marek Polacek Date: Thu Mar 9 18:43:34 2023 -0500 But also 12.2.1 20230302 [OG12] Short test case attached to reproduce. Compilation with gfortran 14 using:=20 gfortran -cpp -g -fopenacc testcase_begou.f90 -o testcase_begou Execution output (wrong) with gfortran from master: $ ./testcase_begou=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1 =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D>> ajoute: allocating on host and on device =3D=3D=3D=3D=3D>> ajoute OK =3D=3D=3D=3D> usage in main: set array to 1 on device =3D=3D=3D=3D> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 100: 100.000000 =3D=3D=3D=3D=3D>> destroy datas on device and on host =3D=3D=3D=3D=3D>> destroy OK =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 2 =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D>> ajoute: allocating on host and on device =3D=3D=3D=3D=3D>> ajoute OK =3D=3D=3D=3D> usage in main: set array to 2 on device libgomp: cuStreamSynchronize error: an illegal memory access was encountered With gfortran 12.2.1 the error message is a little bit more detailed (only error message below, standard output is the same): libgomp: cuStreamSynchronize error: an illegal memory access was encountered libgomp: cuModuleGetFunction (__do_global_dtors__entry) error: an illegal memory access was encountered libgomp: device finalization failed Hosts used with GNU compilers:=20 - AMD Epyc 7302 + Nvidia A100, CentOS8=20 - i7-12700H + Nvidia T600, Alma Linux8 Code works on : - AMD Epyc 7302 + Nvidia A100, CentOS8 with Nvfortran 22.5-0: nvfortran -acc=3Dgpu,noautopar -gpu=3Dcc80 -Mpreprocess testcase_begou.f= 90 -o testcase_begou - i7-12700H + Nvidia T600, Alma Linux8 with Nvfortran 23.3-0: - nvfortran -acc=3Dgpu,noautopar -gpu=3Dcc75 -Mpreprocess testcase_begou.f= 90 -o testcase_begou - AMD EPYC 7542 + AMD MI 100 with Cray ftn 14.0.2: - ftn -g -hacc -hnoomp -eF testcase_begou.f90 -o testcase_begou Correct output is: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1 =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D>> ajoute: allocating on host and on device =3D=3D=3D=3D=3D>> ajoute OK =3D=3D=3D=3D> usage in main: set array to 1 on device =3D=3D=3D=3D> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 100: 100.000000 =3D=3D=3D=3D=3D>> destroy datas on device and on host =3D=3D=3D=3D=3D>> destroy OK =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 2 =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D>> ajoute: allocating on host and on device =3D=3D=3D=3D=3D>> ajoute OK =3D=3D=3D=3D> usage in main: set array to 2 on device =3D=3D=3D=3D> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 800: 800.000000 =3D=3D=3D=3D=3D>> destroy datas on device and on host =3D=3D=3D=3D=3D>> destroy OK Thanks Patrick=