From: Thomas Schwinge Date: Wed, 1 Jul 2026 21:24:46 +0000 (+0200) Subject: OpenMP: support for uses_allocators clause: Fix libgomp build for PTX < 4.1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=675abe8b1494048a643b3f229499a5a7cbfb466d;p=thirdparty%2Fgcc.git OpenMP: support for uses_allocators clause: Fix libgomp build for PTX < 4.1 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. --- diff --git a/libgomp/config/nvptx/allocator.c b/libgomp/config/nvptx/allocator.c index 577ebb7d1a5..5c6f71166d3 100644 --- a/libgomp/config/nvptx/allocator.c +++ b/libgomp/config/nvptx/allocator.c @@ -44,6 +44,9 @@ #include "libgomp.h" #include +#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) { diff --git a/libgomp/config/nvptx/team.c b/libgomp/config/nvptx/team.c index cd726738170..138fb4a3d90 100644 --- a/libgomp/config/nvptx/team.c +++ b/libgomp/config/nvptx/team.c @@ -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));