https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122543
Bug ID: 122543
Summary: [nvptx] libgomp.fortran/omp_target_memset.f90 fails as
GOMP_OFFLOAD_dev2host overrides ptx_devices
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org, tschwinge at gcc dot gnu.org
Target Milestone: ---
This is somewhat odd - I have:
GOMP_OFFLOAD_run
This calls nvptx_stacks_acquire; omp_stacks.ptr has the default size of
131072 = nvptx_stacks_size () = 128 * 1024
but needs to be larger: 1048576. Hence, nvptx_stacks_acquire allocates
new memory and stores it in
ptx_dev->omp_stacks.ptr + ptx_dev->omp_stacks.size
and all is fine until the end of GOMP_OFFLOAD_run
Then
GOMP_OFFLOAD_dev2host - 0, dst=0xac5c50, src=0x7fffd9620440, size = 1024
and this messes everything up by resetting 'omp_stacks.size' and
'omp_stacks.ptr'.
The next time nvptx_stacks_acquire is called, it fails when attempting to
free ptx_dev->omp_stacks.ptr.
If you wonder why this happens:
Thread 1 "a.out" hit Breakpoint 4.2, GOMP_OFFLOAD_dev2host (ord=0,
dst=0xac5c50, src=0x7fffd9620440, n=1024) at plugin-nvptx.c:2220
2220 {
(gdb) p ptx_devices[0]
$5 = (struct ptx_device *) 0xac5c50
(gdb) p ptx_devices[0] == dst
$6 = 1
* * *
The 100 million dollar question is: Why is ptx_device device copied to and from
the device?