On 1/6/22 10:29, Tom de Vries wrote:
At first glance, the above behaviour doesn't look like a too short timeout.

Using patch below, this passes for me, I'm currently doing a full build and test to confirm.

Looks like it has to do with:
...
For sm_6x and earlier architectures, atom operations on .shared state space do not guarantee atomicity with respect to normal store instructions to the same address. It is the programmer's responsibility to guarantee correctness of programs that use shared memory atomic instructions, e.g., by inserting barriers between normal stores and atomic operations to a common address, or by using atom.exch to store to locations accessed by other atomic operations.
...

My current understanding is that this is a backend problem, and needs to be fixed by defining atomic_store patterns which take care of this peculiarity.

Thanks,
- Tom

diff --git a/libgomp/config/nvptx/allocator.c b/libgomp/config/nvptx/allocator.c
index 6bc2ea48043..4524122b3e7 100644
--- a/libgomp/config/nvptx/allocator.c
+++ b/libgomp/config/nvptx/allocator.c
@@ -122,7 +122,8 @@ nvptx_memspace_alloc (omp_memspace_handle_t memspace, size_t size)

        }

       /* Update the free chain root and release the lock.  */
- __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE);
+      __atomic_exchange_n (&__nvptx_lowlat_heap_root,
+                          root.raw, MEMMODEL_RELEASE);
       return result;
     }
   else-
@@ -221,7 +222,8 @@ nvptx_memspace_free (omp_memspace_handle_t memspace, void *addr, s
ize_t size)
        root.raw = newfreechunk.raw;

       /* Update the free chain root and release the lock.  */
- __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE);
+      __atomic_exchange_n (&__nvptx_lowlat_heap_root,
+                          root.raw, MEMMODEL_RELEASE);
     }
   else
     free (addr);
@@ -331,7 +333,8 @@ nvptx_memspace_realloc (omp_memspace_handle_t memspace, void *addr
,
       /* Else realloc in-place has failed and result remains NULL.  */

       /* Update the free chain root and release the lock.  */
- __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE);
+      __atomic_exchange_n (&__nvptx_lowlat_heap_root,
+                          root.raw, MEMMODEL_RELEASE);

       if (result == NULL)
        {

Reply via email to