https://gcc.gnu.org/g:803dfda7bed667c1993430138eab1c264b7d9528
commit r17-2011-g803dfda7bed667c1993430138eab1c264b7d9528 Author: Thomas Schwinge <[email protected]> Date: Tue Jun 30 14:42:21 2026 +0200 OpenMP: support for uses_allocators clause: Fix build and test case regressions Fix-up for commit 7a8f98b48104ccf10c6dceccc51b70de69288eaa "OpenMP: support for uses_allocators clause". As was already pointed out, 'libgomp/config.h.in' was not regenerated. In a configuration with: checking whether the target supports __sync_*_compare_and_swap... (cached) no ..., I see: configure: error: offload hosts require __sync_val_compare_and_swap to build libgomp. make[1]: *** [Makefile:17208: configure-target-libgomp] Error 1 Fixed the inverted condition. Next, I see: ../../../source-gcc/libgomp/config/linux/../../allocator.c: In function ‘omp_init_allocator’: ../../../source-gcc/libgomp/config/linux/../../allocator.c:619:28: error: passing argument 1 of ‘gomp_mutex_init’ makes pointer from integer without a cast [-Wint-conversion] 619 | gomp_mutex_init (data->lock); | ~~~~^~~~~~ | | | gomp_mutex_t {aka int} ../../../source-gcc/libgomp/config/linux/../../allocator.c:619:28: note: possible fix: take the address with ‘&’ 619 | gomp_mutex_init (data->lock); | ~~~~^~~~~~ | & In file included from ../../../source-gcc/libgomp/libgomp.h:209, from ../../../source-gcc/libgomp/config/linux/allocator.c:31: ../../../source-gcc/libgomp/config/linux/mutex.h:41:32: note: expected ‘gomp_mutex_t *’ {aka ‘int *’} but argument is of type ‘gomp_mutex_t’ {aka ‘int’} 41 | gomp_mutex_init (gomp_mutex_t *mutex) | ~~~~~~~~~~~~~~^~~~~ ../../../source-gcc/libgomp/config/linux/../../allocator.c: In function ‘gomp_map_omp_init_allocator’: ../../../source-gcc/libgomp/config/linux/../../allocator.c:1587:68: error: passing argument 1 of ‘gomp_mutex_init’ makes pointer from integer without a cast [-Wint-conversion] 1587 | (((struct omp_allocator_data *) allocator_data_devaddr)->lock); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ | | | gomp_mutex_t {aka int} ../../../source-gcc/libgomp/config/linux/../../allocator.c:1587:68: note: possible fix: take the address with ‘&’ 1587 | (((struct omp_allocator_data *) allocator_data_devaddr)->lock); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ | & ../../../source-gcc/libgomp/config/linux/mutex.h:41:32: note: expected ‘gomp_mutex_t *’ {aka ‘int *’} but argument is of type ‘gomp_mutex_t’ {aka ‘int’} 41 | gomp_mutex_init (gomp_mutex_t *mutex) | ~~~~~~~~~~~~~~^~~~~ make[4]: *** [Makefile:819: allocator.lo] Error 1 Fixed. Testing (with as well as without 'HAVE_SYNC_BUILTINS'): I see: PASS: g++.dg/gomp/deprecate-2.C -std=c++20 at line 31 (test for warnings, line 22) PASS: g++.dg/gomp/deprecate-2.C -std=c++20 at line 43 (test for warnings, line 34) PASS: g++.dg/gomp/deprecate-2.C -std=c++20 expected multiline pattern lines 24-27 PASS: g++.dg/gomp/deprecate-2.C -std=c++20 expected multiline pattern lines 36-39 [-XFAIL:-]{+XPASS:+} g++.dg/gomp/deprecate-2.C -std=c++20 (test for excess errors) [Etc.] ..., due to: { dg-excess-errors "sorry, unimplemented: 'uses_allocators' clause" } Removed. I see: {+PASS: libgomp.c++/../libgomp.c-c++-common/uses_allocators-2.c (test for errors, line 9)+} {+FAIL: libgomp.c++/../libgomp.c-c++-common/uses_allocators-2.c (test for excess errors)+} ..., due to: [...]/libgomp.c++/../libgomp.c-c++-common/uses_allocators-2.c:7:34: error: invalid conversion from 'int' to 'omp_alloctrait_key_t' [-fpermissive] [...]/libgomp.c++/../libgomp.c-c++-common/uses_allocators-2.c:16:40: error: invalid conversion from 'int' to 'omp_alloctrait_key_t' [-fpermissive] Replaced '1' by 'omp_atk_sync_hint'. I see: {+FAIL: libgomp.c++/../libgomp.c-c++-common/uses_allocators-9.c (test for excess errors)+} {+UNRESOLVED: libgomp.c++/../libgomp.c-c++-common/uses_allocators-9.c compilation failed to produce executable+} ..., due to: [...]/libgomp.c++/../libgomp.c-c++-common/uses_allocators-9.c:11:24: error: invalid conversion from 'void*' to 'int*' [-fpermissive] [...]/libgomp.c++/../libgomp.c-c++-common/uses_allocators-9.c:21:24: error: invalid conversion from 'void*' to 'int*' [-fpermissive] [...]/libgomp.c++/../libgomp.c-c++-common/uses_allocators-9.c:33:32: error: invalid conversion from 'void*' to 'int*' [-fpermissive] Added type casts. I see: [-PASS:-]{+FAIL:+} libgomp.fortran/dep-uses-allocators.f90 -O at line 12 (test for warnings, line 11) PASS: libgomp.fortran/dep-uses-allocators.f90 -O at line 2 (test for warnings, line 11) PASS: libgomp.fortran/dep-uses-allocators.f90 -O (test for excess errors) ..., due to: { dg-message "sorry, unimplemented: 'uses_allocators' clause [...] Removed. I see: PASS: libgomp.fortran/uses_allocators-7.f90 -O (test for excess errors) {+PASS: libgomp.fortran/uses_allocators-7.f90 -O execution test+} {+PASS: libgomp.fortran/uses_allocators-7.f90 -O scan-tree-dump-times gimple "#pragma omp target .*uses_allocators\\(memspace\\(\\), traits\\(trait\\) : my_alloc\\)" 1+} {+PASS: libgomp.fortran/uses_allocators-7.f90 -O scan-tree-dump-times gimple "#pragma omp target .*uses_allocators\\(memspace\\(\\), traits\\(\\) : my_alloc\\)" 1+} {+FAIL: libgomp.fortran/uses_allocators-7.f90 -O scan-tree-dump-times original "#pragma omp target .*uses_allocators\\(memspace\\(1\\), traits\\(\\) : my4\\) uses_allocators\\(memspace\\(\\), traits\\(t2\\) : my3\\) uses_allocators\\(memspace\\(\\), traits\\(\\) : my2\\) uses_allocators\\(memspace\\(3\\), traits\\(t\\) : my\\)" 1+} XFAILed (for now.) gcc/testsuite/ * g++.dg/gomp/deprecate-2.C: Remove obsolete 'dg-excess-errors'. libgomp/ * config.h.in: Regenerate. * configure.ac [x$libgomp_cv_have_sync_builtins = xno]: Fix check. * configure: Regenerate. * allocator.c (omp_init_allocator, gomp_map_omp_init_allocator) [!HAVE_SYNC_BUILTINS]: Fix build. * testsuite/libgomp.c-c++-common/uses_allocators-2.c: Fix for C++ testing. * testsuite/libgomp.c-c++-common/uses_allocators-9.c: Likewise. * testsuite/libgomp.fortran/dep-uses-allocators.f90: Remove obsolete "sorry, unimplemented: [...]" diagnostic check. * testsuite/libgomp.fortran/uses_allocators-7.f90: XFAIL one 'scan-tree-dump-times' check. Diff: --- gcc/testsuite/g++.dg/gomp/deprecate-2.C | 3 --- libgomp/allocator.c | 4 ++-- libgomp/config.h.in | 3 +++ libgomp/configure | 2 +- libgomp/configure.ac | 2 +- libgomp/testsuite/libgomp.c-c++-common/uses_allocators-2.c | 4 ++-- libgomp/testsuite/libgomp.c-c++-common/uses_allocators-9.c | 6 +++--- libgomp/testsuite/libgomp.fortran/dep-uses-allocators.f90 | 1 - libgomp/testsuite/libgomp.fortran/uses_allocators-7.f90 | 2 +- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gcc/testsuite/g++.dg/gomp/deprecate-2.C b/gcc/testsuite/g++.dg/gomp/deprecate-2.C index 46d286141ef2..b7689dd1554d 100644 --- a/gcc/testsuite/g++.dg/gomp/deprecate-2.C +++ b/gcc/testsuite/g++.dg/gomp/deprecate-2.C @@ -42,6 +42,3 @@ void f() // { dg-warning "42: the specification of arguments to 'uses_allocators' where each item is of the form 'allocator\\(traits\\)' is deprecated since OpenMP 5.2 \\\[-Wdeprecated-openmp\\\]" "" { target *-*-* } 34 } } - -// { dg-excess-errors "sorry, unimplemented: 'uses_allocators' clause" } -// { dg-excess-errors "sorry, unimplemented: 'uses_allocators' clause" } diff --git a/libgomp/allocator.c b/libgomp/allocator.c index 5576d92e21d2..dc1b79d9b83a 100644 --- a/libgomp/allocator.c +++ b/libgomp/allocator.c @@ -616,7 +616,7 @@ omp_init_allocator (omp_memspace_handle_t memspace, int ntraits, else { #ifndef HAVE_SYNC_BUILTINS - gomp_mutex_init (data->lock); + gomp_mutex_init (&data->lock); #endif } @@ -1584,7 +1584,7 @@ gomp_map_omp_init_allocator (struct gomp_device_descr *devicep, sizeof (struct omp_allocator_data)); #ifndef HAVE_SYNC_BUILTINS gomp_mutex_init - (((struct omp_allocator_data *) allocator_data_devaddr)->lock); + (&((struct omp_allocator_data *) allocator_data_devaddr)->lock); #endif } ret = (omp_allocator_handle_t) allocator_data_devaddr; diff --git a/libgomp/config.h.in b/libgomp/config.h.in index 46d3eac1e610..0522c50d34a4 100644 --- a/libgomp/config.h.in +++ b/libgomp/config.h.in @@ -133,6 +133,9 @@ /* Define to 1 if building libgomp for an accelerator-only target. */ #undef LIBGOMP_OFFLOADED_ONLY +/* Define to 1 if building libgomp for a offload host */ +#undef LIBGOMP_OFFLOAD_HOST + /* Define to 1 if libgomp should use POSIX threads. */ #undef LIBGOMP_USE_PTHREADS diff --git a/libgomp/configure b/libgomp/configure index 7877089755a5..2f395a883f2a 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -17134,7 +17134,7 @@ if test x$libgomp_cv_have_sync_builtins = xno; then as_fn_error $? "accelerator targets require __sync_val_compare_and_swap to build libgomp." "$LINENO" 5 fi # Same for offload hosts. - if test x"$offload_plugins" = x; then + if test x"$offload_plugins" != x; then as_fn_error $? "offload hosts require __sync_val_compare_and_swap to build libgomp." "$LINENO" 5 fi fi diff --git a/libgomp/configure.ac b/libgomp/configure.ac index 917079bc95bc..057debe92141 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -378,7 +378,7 @@ if test x$libgomp_cv_have_sync_builtins = xno; then AC_MSG_ERROR([accelerator targets require __sync_val_compare_and_swap to build libgomp.]) fi # Same for offload hosts. - if test x"$offload_plugins" = x; then + if test x"$offload_plugins" != x; then AC_MSG_ERROR([offload hosts require __sync_val_compare_and_swap to build libgomp.]) fi fi diff --git a/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-2.c b/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-2.c index 2babb11018e2..30fae752a33a 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-2.c +++ b/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-2.c @@ -4,7 +4,7 @@ void f () { - omp_alloctrait_t trait[1] = {{1,1}}; + omp_alloctrait_t trait[1] = {{omp_atk_sync_hint, 1}}; omp_allocator_handle_t my_alloc; #pragma omp target uses_allocators(traits(trait) : my_alloc) /* { dg-error "traits array 'trait' must be of 'const omp_alloctrait_t \\\[\\\]' type" } */ ; @@ -13,7 +13,7 @@ f () void g () { - const omp_alloctrait_t trait[1] = {{1,1}}; + const omp_alloctrait_t trait[1] = {{omp_atk_sync_hint, 1}}; omp_allocator_handle_t my_alloc; #pragma omp target uses_allocators(traits(trait) : my_alloc) ; diff --git a/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-9.c b/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-9.c index 258dba10ebd8..00f01fc71496 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-9.c +++ b/libgomp/testsuite/libgomp.c-c++-common/uses_allocators-9.c @@ -8,7 +8,7 @@ int main (void) #pragma omp target uses_allocators (traits (trait): my_alloc) { - int *x = omp_alloc (sizeof (int), my_alloc); + int *x = (int *) omp_alloc (sizeof (int), my_alloc); if ((uintptr_t) x % 128 != 0) __builtin_abort (); omp_free (x, my_alloc); @@ -18,7 +18,7 @@ int main (void) #pragma omp target uses_allocators (traits (trait): my_alloc) { - int *x = omp_alloc (sizeof (int), my_alloc); + int *x = (int *) omp_alloc (sizeof (int), my_alloc); if ((uintptr_t) x % 128 != 0) __builtin_abort (); omp_free (x, my_alloc); @@ -30,7 +30,7 @@ int main (void) /* The following creates an allocator with empty traits + default mem space. */ #pragma omp target uses_allocators (my_alloc) { - int *x = omp_aligned_alloc (128, sizeof (int), my_alloc); + int *x = (int *) omp_aligned_alloc (128, sizeof (int), my_alloc); if ((uintptr_t) x % 128 != 0) __builtin_abort (); omp_free (x, my_alloc); diff --git a/libgomp/testsuite/libgomp.fortran/dep-uses-allocators.f90 b/libgomp/testsuite/libgomp.fortran/dep-uses-allocators.f90 index ab81ffb910d9..2c0b8af7337d 100644 --- a/libgomp/testsuite/libgomp.fortran/dep-uses-allocators.f90 +++ b/libgomp/testsuite/libgomp.fortran/dep-uses-allocators.f90 @@ -9,6 +9,5 @@ program test type(omp_alloctrait), parameter :: trait(0) = [omp_alloctrait :: ] !$omp target uses_allocators(omp_default_mem_alloc, a1(trait)) - ! { dg-message "sorry, unimplemented: 'uses_allocators' clause with traits and memory spaces" "" { target *-*-* } .-1 } block; end block end program diff --git a/libgomp/testsuite/libgomp.fortran/uses_allocators-7.f90 b/libgomp/testsuite/libgomp.fortran/uses_allocators-7.f90 index 64ac5ca189e4..d0a603b5ced1 100644 --- a/libgomp/testsuite/libgomp.fortran/uses_allocators-7.f90 +++ b/libgomp/testsuite/libgomp.fortran/uses_allocators-7.f90 @@ -55,4 +55,4 @@ end ! { dg-final { scan-tree-dump-times "#pragma omp target .*uses_allocators\\(memspace\\(\\), traits\\(trait\\) : my_alloc\\)" 1 "gimple" } } ! { dg-final { scan-tree-dump-times "#pragma omp target .*uses_allocators\\(memspace\\(\\), traits\\(\\) : my_alloc\\)" 1 "gimple" } } -! { dg-final { scan-tree-dump-times "#pragma omp target .*uses_allocators\\(memspace\\(1\\), traits\\(\\) : my4\\) uses_allocators\\(memspace\\(\\), traits\\(t2\\) : my3\\) uses_allocators\\(memspace\\(\\), traits\\(\\) : my2\\) uses_allocators\\(memspace\\(3\\), traits\\(t\\) : my\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target .*uses_allocators\\(memspace\\(1\\), traits\\(\\) : my4\\) uses_allocators\\(memspace\\(\\), traits\\(t2\\) : my3\\) uses_allocators\\(memspace\\(\\), traits\\(\\) : my2\\) uses_allocators\\(memspace\\(3\\), traits\\(t\\) : my\\)" 1 "original" { xfail *-*-* } } }
