diff options
author | Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | 2019-05-30 09:06:48 +0000 |
---|---|---|
committer | Rainer Orth <ro@gcc.gnu.org> | 2019-05-30 09:06:48 +0000 |
commit | a7155c2e0b061212722faf5744cb3781e9a18aa3 (patch) | |
tree | 85909d95bf4225e5242b1334f4f28f777989c56f /libgomp | |
parent | b8148c42da02357784830917421d6091fbe69a83 (diff) | |
download | gcc-a7155c2e0b061212722faf5744cb3781e9a18aa3.zip gcc-a7155c2e0b061212722faf5744cb3781e9a18aa3.tar.gz gcc-a7155c2e0b061212722faf5744cb3781e9a18aa3.tar.bz2 |
Generalize getconf _NPROCESSORS_ONLN
libgomp:
* configure.ac: Call AX_COUNT_CPUS.
Substitute CPU_COUNT.
* testsuite/Makefile.am (check-am): Use CPU_COUNT as processor
count fallback.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* Makefile.in, testsuite/Makefile.in: Regenerate.
config:
* ax_count_cpus.m4: New file.
From-SVN: r271769
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 10 | ||||
-rw-r--r-- | libgomp/Makefile.in | 4 | ||||
-rw-r--r-- | libgomp/aclocal.m4 | 1 | ||||
-rwxr-xr-x | libgomp/configure | 105 | ||||
-rw-r--r-- | libgomp/configure.ac | 4 | ||||
-rw-r--r-- | libgomp/testsuite/Makefile.am | 4 | ||||
-rw-r--r-- | libgomp/testsuite/Makefile.in | 6 |
7 files changed, 124 insertions, 10 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index b9bf097..2e1a00e 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,13 @@ +2019-05-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * configure.ac: Call AX_COUNT_CPUS. + Substitute CPU_COUNT. + * testsuite/Makefile.am (check-am): Use CPU_COUNT as processor + count fallback. + * aclocal.m4: Regenerate. + * configure: Regenerate. + * Makefile.in, testsuite/Makefile.in: Regenerate. + 2019-05-29 Jakub Jelinek <jakub@redhat.com> * testsuite/libgomp.c-c++-common/lastprivate_conditional_4.c: Rename diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in index 1e2fa89f..5abf7d4 100644 --- a/libgomp/Makefile.in +++ b/libgomp/Makefile.in @@ -16,7 +16,7 @@ # Plugins for offload execution, Makefile.am fragment. # -# Copyright (C) 2014-2018 Free Software Foundation, Inc. +# Copyright (C) 2014-2019 Free Software Foundation, Inc. # # Contributed by Mentor Embedded. # @@ -124,6 +124,7 @@ target_triplet = @target@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/ax_count_cpus.m4 \ $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/enable.m4 \ $(top_srcdir)/../config/futex.m4 \ @@ -365,6 +366,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CPU_COUNT = @CPU_COUNT@ CUDA_DRIVER_INCLUDE = @CUDA_DRIVER_INCLUDE@ CUDA_DRIVER_LIB = @CUDA_DRIVER_LIB@ CYGPATH_W = @CYGPATH_W@ diff --git a/libgomp/aclocal.m4 b/libgomp/aclocal.m4 index 252d5fc..9d3a4ec 100644 --- a/libgomp/aclocal.m4 +++ b/libgomp/aclocal.m4 @@ -1168,6 +1168,7 @@ AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([../config/acx.m4]) +m4_include([../config/ax_count_cpus.m4]) m4_include([../config/depstand.m4]) m4_include([../config/enable.m4]) m4_include([../config/futex.m4]) diff --git a/libgomp/configure b/libgomp/configure index b4bc4f4..fd7394b 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -653,6 +653,7 @@ link_gomp XLDFLAGS XCFLAGS config_path +CPU_COUNT LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_FALSE LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_FALSE @@ -11393,7 +11394,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11396 "configure" +#line 11397 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11499,7 +11500,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11502 "configure" +#line 11503 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15376,7 +15377,7 @@ fi # Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*- # -# Copyright (C) 2014-2018 Free Software Foundation, Inc. +# Copyright (C) 2014-2019 Free Software Foundation, Inc. # # Contributed by Mentor Embedded. # @@ -15824,8 +15825,7 @@ for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -16905,6 +16905,101 @@ $as_echo "#define LIBGOMP_GNU_SYMBOL_VERSIONING 1" >>confdefs.h fi +# Determine cpu count to limit testsuite parallelism. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking the number of available CPUs" >&5 +$as_echo_n "checking the number of available CPUs... " >&6; } + CPU_COUNT="0" + + # Try generic methods + + # 'getconf' is POSIX utility, but '_NPROCESSORS_ONLN' and + # 'NPROCESSORS_ONLN' are platform-specific + command -v getconf >/dev/null 2>&1 && \ + CPU_COUNT=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null` || CPU_COUNT="0" + if test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v nproc >/dev/null 2>&1; then : + : # empty +else + # 'nproc' is part of GNU Coreutils and is widely available + CPU_COUNT=`OMP_NUM_THREADS='' nproc 2>/dev/null` || CPU_COUNT=`nproc 2>/dev/null` || CPU_COUNT="0" + +fi + if test "$CPU_COUNT" -gt "0" 2>/dev/null; then : + : # empty +else + # Try platform-specific preferred methods + case $host_os in #( + *linux*) : + CPU_COUNT=`lscpu -p 2>/dev/null | $EGREP -e '^[0-9]+,' -c` || CPU_COUNT="0" ;; #( + *darwin*) : + CPU_COUNT=`sysctl -n hw.logicalcpu 2>/dev/null` || CPU_COUNT="0" ;; #( + freebsd*) : + command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n kern.smp.cpus 2>/dev/null` || CPU_COUNT="0" ;; #( + netbsd*) : + command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n hw.ncpuonline 2>/dev/null` || CPU_COUNT="0" ;; #( + solaris*) : + command -v psrinfo >/dev/null 2>&1 && CPU_COUNT=`psrinfo 2>/dev/null | $EGREP -e '^[0-9].*on-line' -c 2>/dev/null` || CPU_COUNT="0" ;; #( + mingw*) : + CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( + msys*) : + CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( + cygwin*) : + CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( + *) : + ;; +esac +fi + if test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v sysctl >/dev/null 2>&1; then : + : # empty +else + # Try less preferred generic method + # 'hw.ncpu' exist on many platforms, but not on GNU/Linux + CPU_COUNT=`sysctl -n hw.ncpu 2>/dev/null` || CPU_COUNT="0" + +fi + if test "$CPU_COUNT" -gt "0" 2>/dev/null; then : + : # empty +else + # Try platform-specific fallback methods + # They can be less accurate and slower then preferred methods + case $host_os in #( + *linux*) : + CPU_COUNT=`$EGREP -e '^processor' -c /proc/cpuinfo 2>/dev/null` || CPU_COUNT="0" ;; #( + *darwin*) : + CPU_COUNT=`system_profiler SPHardwareDataType 2>/dev/null | $EGREP -i -e 'number of cores:'|cut -d : -f 2 -s|tr -d ' '` || CPU_COUNT="0" ;; #( + freebsd*) : + CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu[0-9]+: '|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0" ;; #( + netbsd*) : + CPU_COUNT=`command -v cpuctl >/dev/null 2>&1 && cpuctl list 2>/dev/null| $EGREP -e '^[0-9]+ .* online ' -c` || \ + CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu[0-9]+ at'|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0" ;; #( + solaris*) : + command -v kstat >/dev/null 2>&1 && CPU_COUNT=`kstat -m cpu_info -s state -p 2>/dev/null | $EGREP -c -e 'on-line'` || \ + CPU_COUNT=`kstat -m cpu_info 2>/dev/null | $EGREP -c -e 'module: cpu_info'` || CPU_COUNT="0" ;; #( + mingw*) : + if CPU_COUNT=`reg query 'HKLM\\Hardware\\Description\\System\\CentralProcessor' 2>/dev/null | $EGREP -e '\\\\[0-9]+$' -c`; then : + : # empty +else + test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" +fi ;; #( + msys*) : + test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" ;; #( + cygwin*) : + test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" ;; #( + *) : + ;; +esac +fi + if test "x$CPU_COUNT" != "x0" && test "$CPU_COUNT" -gt 0 2>/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPU_COUNT" >&5 +$as_echo "$CPU_COUNT" >&6; } + +else + CPU_COUNT="1" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to detect (assuming 1)" >&5 +$as_echo "unable to detect (assuming 1)" >&6; } + +fi + + # Get target configury. . ${srcdir}/configure.tgt CFLAGS="$save_CFLAGS $XCFLAGS" diff --git a/libgomp/configure.ac b/libgomp/configure.ac index f75c622..707d5cd 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -318,6 +318,10 @@ if test $enable_symvers = gnu; then [Define to 1 if GNU symbol versioning is used for libgomp.]) fi +# Determine cpu count to limit testsuite parallelism. +AX_COUNT_CPUS +AC_SUBST(CPU_COUNT) + # Get target configury. . ${srcdir}/configure.tgt CFLAGS="$save_CFLAGS $XCFLAGS" diff --git a/libgomp/testsuite/Makefile.am b/libgomp/testsuite/Makefile.am index 2100f49..62b1855 100644 --- a/libgomp/testsuite/Makefile.am +++ b/libgomp/testsuite/Makefile.am @@ -69,11 +69,11 @@ distclean-DEJAGNU: distclean-am: distclean-DEJAGNU check-am: @if test -n "$(filter -j%, $(MFLAGS))"; then \ - num_cpus=1; \ + num_cpus=@CPU_COUNT@; \ if type -p getconf 2>/dev/null >/dev/null; then \ num_cpus=`getconf _NPROCESSORS_ONLN 2>/dev/null`; \ case "$$num_cpus" in \ - '' | 0* | *[!0-9]*) num_cpus=1;; \ + '' | 0* | *[!0-9]*) num_cpus=@CPU_COUNT@;; \ esac; \ fi; \ if test $$num_cpus -gt 8 && test -z "$$OMP_NUM_THREADS"; then \ diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in index 80315b1..0161041 100644 --- a/libgomp/testsuite/Makefile.in +++ b/libgomp/testsuite/Makefile.in @@ -91,6 +91,7 @@ target_triplet = @target@ subdir = testsuite ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/ax_count_cpus.m4 \ $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/enable.m4 \ $(top_srcdir)/../config/futex.m4 \ @@ -143,6 +144,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CPU_COUNT = @CPU_COUNT@ CUDA_DRIVER_INCLUDE = @CUDA_DRIVER_INCLUDE@ CUDA_DRIVER_LIB = @CUDA_DRIVER_LIB@ CYGPATH_W = @CYGPATH_W@ @@ -521,11 +523,11 @@ distclean-DEJAGNU: distclean-am: distclean-DEJAGNU check-am: @if test -n "$(filter -j%, $(MFLAGS))"; then \ - num_cpus=1; \ + num_cpus=@CPU_COUNT@; \ if type -p getconf 2>/dev/null >/dev/null; then \ num_cpus=`getconf _NPROCESSORS_ONLN 2>/dev/null`; \ case "$$num_cpus" in \ - '' | 0* | *[!0-9]*) num_cpus=1;; \ + '' | 0* | *[!0-9]*) num_cpus=@CPU_COUNT@;; \ esac; \ fi; \ if test $$num_cpus -gt 8 && test -z "$$OMP_NUM_THREADS"; then \ |