]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: support for uses_allocators clause: Fix libgomp build for PTX < 4.1
authorThomas Schwinge <tschwinge@baylibre.com>
Wed, 1 Jul 2026 21:24:46 +0000 (23:24 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Thu, 2 Jul 2026 07:05:06 +0000 (09:05 +0200)
Fix-up for commit 7a8f98b48104ccf10c6dceccc51b70de69288eaa
"OpenMP: support for uses_allocators clause", which regressed libgomp build for
PTX < 4.1 configurations:

    In file included from [...]/libgomp/config/nvptx/allocator.c:48:
    [...]/libgomp/config/nvptx/allocator.c:47:28: error: ‘__nvptx_lowlat_realloc’ defined but not used [-Werror=unused-function]
       47 | #define BASIC_ALLOC_PREFIX __nvptx_lowlat
          |                            ^~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:63:27: note: in definition of macro ‘fn1’
       63 | #define fn1(prefix, name) prefix ## _ ## name
          |                           ^~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:69:29: note: in expansion of macro ‘fn’
       69 | #define basic_alloc_realloc fn(BASIC_ALLOC_PREFIX,realloc)
          |                             ^~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:69:32: note: in expansion of macro ‘BASIC_ALLOC_PREFIX’
       69 | #define basic_alloc_realloc fn(BASIC_ALLOC_PREFIX,realloc)
          |                                ^~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:257:1: note: in expansion of macro ‘basic_alloc_realloc’
      257 | basic_alloc_realloc (char *heap, void *addr, size_t oldsize,
          | ^~~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/allocator.c:47:28: error: ‘__nvptx_lowlat_calloc’ defined but not used [-Werror=unused-function]
       47 | #define BASIC_ALLOC_PREFIX __nvptx_lowlat
          |                            ^~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:63:27: note: in definition of macro ‘fn1’
       63 | #define fn1(prefix, name) prefix ## _ ## name
          |                           ^~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:67:28: note: in expansion of macro ‘fn’
       67 | #define basic_alloc_calloc fn(BASIC_ALLOC_PREFIX,calloc)
          |                            ^~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:67:31: note: in expansion of macro ‘BASIC_ALLOC_PREFIX’
       67 | #define basic_alloc_calloc fn(BASIC_ALLOC_PREFIX,calloc)
          |                               ^~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:167:1: note: in expansion of macro ‘basic_alloc_calloc’
      167 | basic_alloc_calloc (char *heap, size_t size)
          | ^~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    make[7]: *** [Makefile:819: allocator.lo] Error 1

If, for PTX < 4.1, we're not proving OpenMP low-latency memory, just disable
the whole '__nvptx_lowlat_pool' machinery.

libgomp/
* config/nvptx/allocator.c [PTX < 4.1]: Fix build.
* config/nvptx/team.c [PTX < 4.1]: Disable the whole
'__nvptx_lowlat_pool' machinery.

libgomp/config/nvptx/allocator.c
libgomp/config/nvptx/team.c

index 577ebb7d1a58833031164d5693a6943d09d9d127..5c6f71166d35eb5f44fecd5782c8d3fe6e7f4df1 100644 (file)
@@ -44,6 +44,9 @@
 #include "libgomp.h"
 #include <stdlib.h>
 
+#if __PTX_ISA_VERSION_MAJOR__ > 4                                      \
+    || (__PTX_ISA_VERSION_MAJOR__ == 4 && __PTX_ISA_VERSION_MINOR >= 1)
+
 #define BASIC_ALLOC_PREFIX __nvptx_lowlat
 #include "../../basic-allocator.c"
 
@@ -51,6 +54,8 @@
    express this magic extern sizeless array in C so use asm.  */
 asm (".extern .shared .u8 __nvptx_lowlat_pool[];\n");
 
+#endif
+
 static void *
 nvptx_memspace_alloc (omp_memspace_handle_t memspace, size_t size)
 {
index cd72673817079a8c2746f1d3dc4d82f12e8efae3..138fb4a3d90edccc8d04b7da5d6d6394a5f3ec3b 100644 (file)
@@ -39,6 +39,9 @@ int __gomp_team_num __attribute__((shared,nocommon));
 
 static void gomp_thread_start (struct gomp_thread_pool *);
 
+#if __PTX_ISA_VERSION_MAJOR__ > 4 \
+    || (__PTX_ISA_VERSION_MAJOR__ == 4 && __PTX_ISA_VERSION_MINOR__ >= 1)
+
 /* There should be some .shared space reserved for us.  There's no way to
    express this magic extern sizeless array in C so use asm.  */
 asm (".extern .shared .u8 __nvptx_lowlat_pool[];\n");
@@ -46,6 +49,8 @@ asm (".extern .shared .u8 __nvptx_lowlat_pool[];\n");
 /* Defined in basic-allocator.c via config/nvptx/allocator.c.  */
 void __nvptx_lowlat_init (void *heap, size_t size);
 
+#endif
+
 /* This externally visible function handles target region entry.  It
    sets up a per-team thread pool and transfers control by calling FN (FN_DATA)
    in the master thread or gomp_thread_start in other threads.
@@ -79,16 +84,16 @@ gomp_nvptx_main (void (*fn) (void *), void *fn_data)
       if (UNLIKELY (GOMP_INDIRECT_ADDR_MAP != NULL && block_id == 0))
        build_indirect_map ();
 
+#if __PTX_ISA_VERSION_MAJOR__ > 4 \
+    || (__PTX_ISA_VERSION_MAJOR__ == 4 && __PTX_ISA_VERSION_MINOR__ >= 1)
       /* Find the low-latency heap details ....  */
       uint32_t *shared_pool;
       uint32_t shared_pool_size = 0;
       asm ("cvta.shared.u64\t%0, __nvptx_lowlat_pool;" : "=r"(shared_pool));
-#if __PTX_ISA_VERSION_MAJOR__ > 4 \
-    || (__PTX_ISA_VERSION_MAJOR__ == 4 && __PTX_ISA_VERSION_MINOR__ >= 1)
       asm ("mov.u32\t%0, %%dynamic_smem_size;\n"
           : "=r"(shared_pool_size));
-#endif
       __nvptx_lowlat_init (shared_pool, shared_pool_size);
+#endif
 
       /* Initialize the thread pool.  */
       struct gomp_thread_pool *pool = alloca (sizeof (*pool));