From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C15883851C1F; Mon, 12 Oct 2020 14:29:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C15883851C1F From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/97384] New: [libgomp, nvptx] Handle -msoft-stack-reserve-local= overflow in plugin Date: Mon, 12 Oct 2020 14:29:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org 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 cc target_milestone 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2020 14:29:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97384 Bug ID: 97384 Summary: [libgomp, nvptx] Handle -msoft-stack-reserve-local=3D overflow in plugin Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Using the option -msoft-stack-reserve-local=3D results in a: ... .local .align 8 .b8 %simtstack_ar[n+8]; ... However, the CU_LIMIT_STACK_SIZE is set by default to 1kb for my card/driver combo, so if I specify say -msoft-stack-reserve-local=3D2048, I run into: ... libgomp: cuCtxSynchronize error: an illegal memory access was encountered ... or: ... libgomp: cuCtxSynchronize error: an illegal instruction was encountered ... [ The latter at GOMP_NVPTX_JIT=3D-O0. ] Which may look a lot like the behav= iour we're trying to fix by adding -msoft-stack-reserve-local. There's currently no way to make this work. We could add an env var, say GOMP_NVPTX_LIMIT_STACK_SIZE which is used to s= et: ... r =3D cuCtxSetLimit(CU_LIMIT_STACK_SIZE, gomp_nvptx_limit_stack_size); ... and then do: ... $ GOMP_NVPTX_LIMIT_STACK_SIZE=3D3072 ./a.out ... [ Note that GOMP_NVPTX_LIMIT_STACK_SIZE id chosen to be larger than 2048 to accommodate for other .local usage. ] [ It would be nice if we could attempt to accommodate the requested stack s= ize in the libgomp plugin automatically. In the current setup, that would mean scanning the ptx code for "simtstack_ar[]", which is a bit cumbersome and probably too slow. Perhaps emitting an additional additional line before t= he pre-amble like this: ... // SIMTSTACK_AR_SIZE: 2048 ... would be possible to handle quick enough. ]=