https://gcc.gnu.org/g:7a3b919608f933b702ca462874e069e582d16994

commit 7a3b919608f933b702ca462874e069e582d16994
Author: Andrew Stubbs <[email protected]>
Date:   Fri Mar 13 14:04:00 2026 +0000

    libgomp, amdgcn: rework team_malloc for SIMT mode
    
    The asm insert explicitly set the EXEC register, but that's illegal in SIMT
    mode.  The new code does the same, but is SIMT safe. The EXEC set is still
    needed for SIMD mode.
    
    libgomp/ChangeLog:
    
            * libgomp.h (team_malloc): Add SIMT variant of the asm.

Diff:
---
 libgomp/libgomp.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index ecb3fcaababa..7a780c96c9b1 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -131,8 +131,16 @@ team_malloc (size_t size)
   /* Allocate directly from the arena.
      The compiler does not support DS atomics, yet. */
   void *result;
+#ifndef __SIMT__
   asm ("ds_add_rtn_u64 %0, %1, %2\n\ts_waitcnt 0"
        : "=v"(result) : "v"(TEAM_ARENA_FREE), "v"(size), "e"(1L) : "memory");
+#else
+  /* SIMT should not touch EXEC.
+     FIXME: this will allocate SIZE bytes for each active thread... is that
+           what we want to happen?  Usually, only one will be active here.  */
+  asm ("ds_add_rtn_u64 %0, %1, %2\n\ts_waitcnt 0"
+       : "=v"(result) : "v"(TEAM_ARENA_FREE), "v"(size) : "memory");
+#endif
 
   /* Handle OOM.  */
   if (result + size > *(void * __lds *)TEAM_ARENA_END)

Reply via email to