From 4f3031ce17a79be45ef5f38a7f711c972bf17cd4 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 09:45:07 -0700 Subject: [PATCH 01/38] Remove remaining AIX support code --- config/ac_prog_cc_c99.m4 | 3 +-- config/ac_use_system_extensions.m4 | 1 - config/ax_openmp.m4 | 4 ++-- config/qthread_check_assembly.m4 | 5 +---- src/fastcontext/context.c | 5 ----- 5 files changed, 4 insertions(+), 14 deletions(-) diff --git a/config/ac_prog_cc_c99.m4 b/config/ac_prog_cc_c99.m4 index cb08b432b..4099f66a2 100644 --- a/config/ac_prog_cc_c99.m4 +++ b/config/ac_prog_cc_c99.m4 @@ -237,14 +237,13 @@ test_varargs (const char *format, ...) ]], dnl Try dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) -dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99) dnl Intel ICC -c99 dnl IRIX -c99 dnl Solaris (unused because it causes the compiler to assume C99 semantics for dnl library functions, and this is invalid before Solaris 10: -xc99) dnl Tru64 -c99 dnl with extended modes being tried first. -[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl +[[-std=gnu99 -c99]], [$1], [$2])[]dnl ])# _AC_PROG_CC_C99 # AC_PROG_CC_C99 diff --git a/config/ac_use_system_extensions.m4 b/config/ac_use_system_extensions.m4 index d91de1742..bb4c8f810 100644 --- a/config/ac_use_system_extensions.m4 +++ b/config/ac_use_system_extensions.m4 @@ -66,7 +66,6 @@ AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], AC_BEFORE([$0], [AC_RUN_IFELSE]) AC_REQUIRE([AC_GNU_SOURCE]) - AC_REQUIRE([AC_AIX]) AC_REQUIRE([AC_MINIX]) AH_VERBATIM([__EXTENSIONS__], diff --git a/config/ax_openmp.m4 b/config/ax_openmp.m4 index 72bc809e6..e4a28f8eb 100644 --- a/config/ax_openmp.m4 +++ b/config/ax_openmp.m4 @@ -73,8 +73,8 @@ AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown # Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI), -# -omp (Tru64), -qsmp=omp (AIX), none -ax_openmp_flags="-fopenmp -openmp -mp -omp -qsmp=omp none" +# -omp (Tru64), none +ax_openmp_flags="-fopenmp -openmp -mp -omp none" if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags" fi diff --git a/config/qthread_check_assembly.m4 b/config/qthread_check_assembly.m4 index da7cdcc16..834ab8db6 100644 --- a/config/qthread_check_assembly.m4 +++ b/config/qthread_check_assembly.m4 @@ -107,7 +107,6 @@ AC_DEFUN([QTHREAD_CHECK_ASSEMBLY],[ [qthread_cv_asm_arch="POWERPC32"], [qthread_cv_asm_arch="POWERPC64"]) qthread_ppc_abi="QTHREAD_PPC_ABI_UNKNOWN" - _QTHREAD_CHECK_IFDEF([_CALL_AIX],[qthread_ppc_abi=QTHREAD_PPC_ABI_AIX]) AS_IF([test "$qthread_ppc_abi" = QTHREAD_PPC_ABI_UNKNOWN], [_QTHREAD_CHECK_IFDEF([_CALL_DARWIN],[qthread_ppc_abi=QTHREAD_PPC_ABI_DARWIN])]) AS_IF([test "$qthread_ppc_abi" = QTHREAD_PPC_ABI_UNKNOWN], @@ -116,12 +115,10 @@ AC_DEFUN([QTHREAD_CHECK_ASSEMBLY],[ [_QTHREAD_CHECK_IFDEF([__APPLE__],[qthread_ppc_abi=QTHREAD_PPC_ABI_DARWIN])]) AS_IF([test "$qthread_ppc_abi" = QTHREAD_PPC_ABI_UNKNOWN], [_QTHREAD_CHECK_IFDEF([__linux__], - [_QTHREAD_CHECK_IFDEF([__PPC__],[qthread_ppc_abi=QTHREAD_PPC_ABI_SYSV]) - _QTHREAD_CHECK_IFDEF([__PPC64__],[qthread_ppc_abi=QTHREAD_PPC_ABI_AIX])])]) + [_QTHREAD_CHECK_IFDEF([__PPC__],[qthread_ppc_abi=QTHREAD_PPC_ABI_SYSV])])]) AC_DEFINE([QTHREAD_PPC_ABI_UNKNOWN], [0], [Constant for an unknown PPC ABI]) AC_DEFINE([QTHREAD_PPC_ABI_DARWIN], [1], [Constant for the Darwin PPC ABI]) AC_DEFINE([QTHREAD_PPC_ABI_SYSV], [2], [Constant for the SysV PPC ABI]) - AC_DEFINE([QTHREAD_PPC_ABI_AIX], [3], [Constant for the AIX PPC ABI]) AC_DEFINE_UNQUOTED([QTHREAD_PPC_ABI],[$qthread_ppc_abi],[Define to specify the PPC ABI]) qthread_gcc_inline_assign='"A_%=: li %0,0" : "=&r"(ret)' ;; diff --git a/src/fastcontext/context.c b/src/fastcontext/context.c index 89456dd7a..7f2f2c3b2 100644 --- a/src/fastcontext/context.c +++ b/src/fastcontext/context.c @@ -27,12 +27,7 @@ void INTERNAL qt_makectxt(uctxt_t *ucp, void (*func)(void), int argc, ...) { tos = (unsigned long *)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size / sizeof(unsigned long); sp = tos - 16; -#if (QTHREAD_PPC_ABI == QTHREAD_PPC_ABI_AIX) - ucp->mc.pc = *(long *)func; -#elif (QTHREAD_PPC_ABI == QTHREAD_PPC_ABI_SYSV) || \ - (QTHREAD_PPC_ABI == QTHREAD_PPC_ABI_DARWIN) ucp->mc.pc = (long)func; -#endif ucp->mc.sp = (long)sp; va_start(arg, argc); ucp->mc.r3 = va_arg(arg, long); From db3c9681f795688a561a2036adfe651102c80095 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 09:48:22 -0700 Subject: [PATCH 02/38] Remove some old openmp flags for compilers we no longer support. --- config/ax_openmp.m4 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/ax_openmp.m4 b/config/ax_openmp.m4 index e4a28f8eb..2915a2ef6 100644 --- a/config/ax_openmp.m4 +++ b/config/ax_openmp.m4 @@ -72,9 +72,8 @@ AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown -# Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI), -# -omp (Tru64), none -ax_openmp_flags="-fopenmp -openmp -mp -omp none" +# Flags to try: -fopenmp (gcc), -openmp (icc), none +ax_openmp_flags="-fopenmp -openmp none" if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags" fi From b3a8597081005f27537cae5a5e3c513286d3c632 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:04:09 -0700 Subject: [PATCH 03/38] Drop checks for abnormal behavior from sed. --- config/ac_prog_sed.m4 | 172 ------------------------------------------ configure.ac | 1 - 2 files changed, 173 deletions(-) delete mode 100644 config/ac_prog_sed.m4 diff --git a/config/ac_prog_sed.m4 b/config/ac_prog_sed.m4 deleted file mode 100644 index c225bd4d5..000000000 --- a/config/ac_prog_sed.m4 +++ /dev/null @@ -1,172 +0,0 @@ -# -*- Autoconf -*- -# -# This file includes functions from Autoconf 2.61, for compatibility with older -# Autoconfs. Original copyright below. -# Remove this file when we drop support for AC 2.59 and older - -# This file is part of Autoconf. -*- Autoconf -*- -# Macros that test for specific, unclassified, features. -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception, the Free Software Foundation gives unlimited -# permission to copy, distribute and modify the configure scripts that -# are the output of Autoconf. You need not follow the terms of the GNU -# General Public License when using or distributing such scripts, even -# though portions of the text of Autoconf appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the Autoconf program. -# -# Certain portions of the Autoconf source text are designed to be copied -# (in certain cases, depending on the input) into the output of -# Autoconf. We call these the "data" portions. The rest of the Autoconf -# source text consists of comments plus executable code that decides which -# of the data portions to output in any given case. We call these -# comments and executable code the "non-data" portions. Autoconf never -# copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of Autoconf -# released by the Free Software Foundation. When you make and -# distribute a modified version of Autoconf, you may extend this special -# exception to the GPL to apply to your modified version as well, *unless* -# your modified version has the potential to copy into its output some -# of the text that was the non-data portion of the version that you started -# with. (In other words, unless your change moves or copies text from -# the non-data portions to the data portions.) If your modification has -# such potential, you must delete any notice of this special exception -# to the GPL from your modified version. -# -# Written by David MacKenzie, with help from -# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, -# Roland McGrath, Noah Friedman, david d zuhn, and many others. - -# AC_PROG_SED -# ----------- -# Check for a fully functional sed program that truncates -# as few characters as possible. Prefer GNU sed if found. -AC_DEFUN([AC_PROG_SED], -[AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED, - [dnl ac_script should not contain more than 99 commands (for HP-UX sed), - dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed. - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" | sed 99q >conftest.sed - $as_unset ac_script || ac_script= - _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed], - [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED], - ["$ac_path_SED" -f conftest.sed])])]) - SED="$ac_cv_path_SED" - AC_SUBST([SED])dnl - rm -f conftest.sed -])# AC_PROG_SED - -# _AC_PATH_PROG_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST, [PATH]) -# -------------------------------------------------------------------------- -# FEATURE-TEST is called repeatedly with $ac_path_VARIABLE set to the -# name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST must set -# $ac_cv_path_VARIABLE to the path of an acceptable program, or else -# _AC_PATH_PROG_FEATURE_CHECK will report that no acceptable program -# was found, and abort. If a suitable $ac_path_VARIABLE is found in the -# FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':' to accept -# that value without any further checks. -m4_define([_AC_PATH_PROG_FEATURE_CHECK], -[# Extract the first word of "$2" to use in msg output -if test -z "$$1"; then -set dummy $2; ac_prog_name=$[2] -AC_CACHE_VAL([ac_cv_path_$1], -[ac_path_$1_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -_AS_PATH_WALK([$4], -[for ac_prog in $2; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_$1="$as_dir/$ac_prog$ac_exec_ext" - AS_EXECUTABLE_P(["$ac_path_$1"]) || continue - $3 - $ac_path_$1_found && break 3 - done -done -]) -]) -$1="$ac_cv_path_$1" -if test -z "$$1"; then - AC_MSG_ERROR([no acceptable $ac_prog_name could be found in dnl -m4_default([$4], [\$PATH])]) -fi -AC_SUBST([$1]) -else - ac_cv_path_$1=$$1 -fi -]) - - -# _AC_FEATURE_CHECK_LENGTH(PROGPATH, CACHE-VAR, CHECK-CMD, [MATCH-STRING]) -# ------------------------------------------------------------------------ -# For use as the FEATURE-TEST argument to _AC_PATH_PROG_FEATURE_TEST. -# On each iteration run CHECK-CMD on an input file, storing the value -# of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds. The input file -# is always one line, starting with only 10 characters, and doubling -# in length at each iteration until approx 10000 characters or the -# feature check succeeds. The feature check is called at each -# iteration by appending (optionally, MATCH-STRING and) a newline -# to the file, and using the result as input to CHECK-CMD. -m4_define([_AC_FEATURE_CHECK_LENGTH], -[# Check for GNU $1 and select it if it is found. - _AC_PATH_PROG_FLAVOR_GNU([$$1], - [$2="$$1" $1_found=:], - [ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo '$4' >> "conftest.nl" - $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${$1_max-0}; then - # Best one so far, save it but keep looking for a better one - $2="$$1" -dnl # Using $1_max so that each tool feature checked gets its -dnl # own variable. Don't reset it otherwise the implied search -dnl # for best performing tool in a list breaks down. - $1_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out]) -]) - - -# _AC_PATH_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE]) -# ---------------------------------------------------------------- -m4_define([_AC_PATH_PROG_FLAVOR_GNU], -[# Check for GNU $1 -case `"$1" --version 2>&1` in -*GNU*) - $2;; -m4_ifval([$3], -[*) - $3;; -])esac -])# _AC_PATH_PROG_FLAVOR_GNU - diff --git a/configure.ac b/configure.ac index 777637194..bce0cd5c1 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,6 @@ CLEANFILES="*~ .\#* .gdb_history" AC_SUBST(CLEANFILES) AC_CANONICAL_HOST -AC_PROG_SED AC_PATH_PROG([timelimit_path],[timelimit]) ## ----------------- ## From 050df123d87329dabaa6029cf4ccc3a9412f6651 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:20:49 -0700 Subject: [PATCH 04/38] Drop support for Solaris as well as various Solaris-specific options. --- Makefile.am | 1 - acinclude.m4 | 1 - config/ac_prog_cc_c99.m4 | 2 -- config/ac_use_system_extensions.m4 | 5 +---- config/qthread_check_liblgrp.m4 | 19 ------------------- config/qthread_check_swapcontext.m4 | 13 ------------- configure.ac | 9 ++------- src/affinity/shepcomp.h | 6 ------ src/qthread.c | 12 ------------ 9 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 config/qthread_check_liblgrp.m4 diff --git a/Makefile.am b/Makefile.am index 845024426..6c58aef7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,6 @@ # want them distributed in case someone with AC 2.59 wants to run autoreconf EXTRA_DIST = \ config/ac_prog_cc_c99.m4 \ - config/ac_prog_sed.m4 \ config/ac_use_system_extensions.m4 \ README.md \ README.affinity \ diff --git a/acinclude.m4 b/acinclude.m4 index dbc40beae..e83253bde 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -6,5 +6,4 @@ dnl Only include this if we're using an old Autoconf. Remove when we dnl finally drop support for AC 2.59 m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [2.60]), -1, [m4_include([config/ac_prog_cc_c99.m4]) - m4_include([config/ac_prog_sed.m4]) m4_include([config/ac_use_system_extensions.m4])]) diff --git a/config/ac_prog_cc_c99.m4 b/config/ac_prog_cc_c99.m4 index 4099f66a2..0042ab076 100644 --- a/config/ac_prog_cc_c99.m4 +++ b/config/ac_prog_cc_c99.m4 @@ -239,8 +239,6 @@ dnl Try dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) dnl Intel ICC -c99 dnl IRIX -c99 -dnl Solaris (unused because it causes the compiler to assume C99 semantics for -dnl library functions, and this is invalid before Solaris 10: -xc99) dnl Tru64 -c99 dnl with extended modes being tried first. [[-std=gnu99 -c99]], [$1], [$2])[]dnl diff --git a/config/ac_use_system_extensions.m4 b/config/ac_use_system_extensions.m4 index bb4c8f810..cac3ac4dd 100644 --- a/config/ac_use_system_extensions.m4 +++ b/config/ac_use_system_extensions.m4 @@ -69,10 +69,7 @@ AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], AC_REQUIRE([AC_MINIX]) AH_VERBATIM([__EXTENSIONS__], -[/* Enable extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif +[ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif diff --git a/config/qthread_check_liblgrp.m4 b/config/qthread_check_liblgrp.m4 deleted file mode 100644 index 77597466f..000000000 --- a/config/qthread_check_liblgrp.m4 +++ /dev/null @@ -1,19 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2009 Sandia Corporation -# - -# QTHREAD_CHECK_LIBLGRP([action-if-found], [action-if-not-found]) -# ------------------------------------------------------------------------------ -AC_DEFUN([QTHREAD_CHECK_LIBLGRP], [ - qt_allgoodsofar=yes - AC_CHECK_HEADERS([sys/lgrp_user.h],[], - [qt_allgoodsofar=no]) - AS_IF([test "x$qt_allgoodsofar" = xyes], - [AC_SEARCH_LIBS([lgrp_init], [lgrp], [], - [qt_allgoodsofar=no])]) - AS_IF([test "x$qt_allgoodsofar" = xyes], - [AC_DEFINE([QTHREAD_HAVE_LGRP],[1],[if the machine has a Solaris-style liblgrp topology interface]) - $1], - [$2]) -]) diff --git a/config/qthread_check_swapcontext.m4 b/config/qthread_check_swapcontext.m4 index bb939a3d5..5d57d4628 100644 --- a/config/qthread_check_swapcontext.m4 +++ b/config/qthread_check_swapcontext.m4 @@ -15,19 +15,6 @@ AC_ARG_ENABLE([fastcontext], version.])]) AC_MSG_CHECKING([whether we have a fast context swap for this system]) case "$host" in - *-solaris2.8) - AC_DEFINE([EXTRA_MAKECONTEXT_ARGC], [1], - [solaris 8 requires argc be one larger than the actual count of - arguments]) - AC_DEFINE([INVERSE_STACK_POINTER], [1], - [make the ss_sp member of uc_stack be the high-address of the - stack, rather than the low-address of the stack]) - qt_host_based_enable_fastcontext=no - ;; - *-solaris2.9|*-solaris2.10) - AC_DEFINE([__MAKECONTEXT_V2_SOURCE], [1], [force the Sun makecontext to behave correctly]) - qt_host_based_enable_fastcontext=no - ;; powerpc-*|powerpc64-*|x86-*|x86_64-*|tile-*) # Yes, we have these platforms qt_host_based_enable_fastcontext=yes diff --git a/configure.ac b/configure.ac index bce0cd5c1..3e516d0ba 100644 --- a/configure.ac +++ b/configure.ac @@ -292,12 +292,12 @@ AC_ARG_ENABLE([64bit-alignment], AC_ARG_WITH([topology], [AS_HELP_STRING([--with-topology=[[topologylib]]], [specify which topology interface to use. Supported - interfaces include no, hwloc, hwloc_v2, binders, lgrp, libnuma, + interfaces include no, hwloc, hwloc_v2, binders, libnuma, libnumaV2, mach, plpa, and sys.])], [AS_IF([test "x$with_topology" = xyes], [with_topology=none_specified]) case "$with_topology" in - hwloc|binders|hwloc_v2|lgrp|libnuma|libnumaV2|mach|no|plpa|sys) ;; + hwloc|binders|hwloc_v2|libnuma|libnumaV2|mach|no|plpa|sys) ;; none_specified) ;; *) AC_MSG_ERROR([Unsupported topology library ($with_topology)]) @@ -938,11 +938,6 @@ AS_IF([test "x$qthread_topo" != xno], [qthread_topo=hwloc])], [AS_IF([test "x$qthread_topo" != xno], [AC_MSG_ERROR([Specified topology library ($qthread_topo) does not work.])])])]) - # Second, check for the ones that will give me distance information - AS_IF([test "x$qthread_topo" = xno -o "x$qthread_topo" = xlgrp], - [QTHREAD_CHECK_LIBLGRP([qthread_topo=lgrp], - [AS_IF([test "x$qthread_topo" != xno], - [AC_MSG_ERROR([Specified topology library ($qthread_topo) does not work.])])])]) AS_IF([test "x$qthread_topo" = xno -o "x$qthread_topo" = xlibnuma -o "x$qthread_topo" = xlibnumaV2], [QTHREAD_CHECK_LIBNUMA([qthread_topo=libnuma], [qthread_topo=libnumaV2], diff --git a/src/affinity/shepcomp.h b/src/affinity/shepcomp.h index db6e40bb5..d2474b2fd 100644 --- a/src/affinity/shepcomp.h +++ b/src/affinity/shepcomp.h @@ -16,13 +16,7 @@ static int qthread_internal_shepcomp(void const *a, void const *b, void *src) #else static qthread_shepherd_id_t shepcomp_src; -#ifndef __SUN__ -/* this cannot be static, because Sun's idiotic gccfss compiler sometimes (at - * optimization levels > -O3) refuses to compile it if it is - note that this - * doesn't seem to be something that can be detected with a configure script, - * because it WORKS on small programs */ static -#endif int qthread_internal_shepcomp(void const *a, void const *b) { int a_dist = qthread_distance(shepcomp_src, *(qthread_shepherd_id_t *)a); diff --git a/src/qthread.c b/src/qthread.c index 23e75f9a7..f0bbc4fc0 100644 --- a/src/qthread.c +++ b/src/qthread.c @@ -1379,11 +1379,7 @@ static QINLINE void qthread_makecontext(qt_context_t *const c, /* Several other libraries that do this reserve a few words on either end * of the stack for some reason. To avoid problems, I'll also do this (even * though I have no idea why they do this). */ -#ifdef INVERSE_STACK_POINTER - c->uc_stack.ss_sp = (char *)(stack) + stacksize - 8; -#else c->uc_stack.ss_sp = (uint8_t *)(stack) + 8; -#endif c->uc_stack.ss_size = stacksize - 64; #ifdef UCSTACK_HAS_SSFLAGS c->uc_stack.ss_flags = 0; @@ -1395,17 +1391,9 @@ static QINLINE void qthread_makecontext(qt_context_t *const c, #endif #ifdef HAVE_NATIVE_MAKECONTEXT #ifdef QTHREAD_MAKECONTEXT_SPLIT -#ifdef EXTRA_MAKECONTEXT_ARGC - makecontext(c, func, 3, high, low); -#else makecontext(c, func, 2, high, low); -#endif /* EXTRA_MAKECONTEXT_ARGC */ #else /* QTHREAD_MAKECONTEXT_SPLIT */ -#ifdef EXTRA_MAKECONTEXT_ARGC - makecontext(c, func, 2, arg); -#else makecontext(c, func, 1, arg); -#endif /* EXTRA_MAKECONTEXT_ARGC */ #endif /* QTHREAD_MAKECONTEXT_SPLIT */ assert((void *)c->uc_link == (void *)returnc); #else /* ifdef HAVE_NATIVE_MAKECONTEXT */ From 3db0270780a429956245d98f68693505955a3712 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:33:46 -0700 Subject: [PATCH 05/38] Drop detection for nonstandard TLS keyword. --- config/ax_tls.m4 | 80 ------------------------------------------------ configure.ac | 1 - 2 files changed, 81 deletions(-) delete mode 100644 config/ax_tls.m4 diff --git a/config/ax_tls.m4 b/config/ax_tls.m4 deleted file mode 100644 index 7c3681b16..000000000 --- a/config/ax_tls.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_tls.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_TLS([action-if-found], [action-if-not-found]) -# -# DESCRIPTION -# -# Provides a test for the compiler support of thread local storage (TLS) -# extensions. Defines TLS if it is found. Currently knows about GCC/ICC -# and MSVC. I think SunPro uses the same as GCC, and Borland apparently -# supports either. -# -# LICENSE -# -# Copyright (c) 2008 Alan Woodland -# Copyright (c) 2010 Diego Elio Petteno` -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 10 - -AC_DEFUN([AX_TLS], [ - AC_ARG_ENABLE([native-tls], - [AS_HELP_STRING([--disable-native-tls], - [Prevent use of compiler-based thread-local - storage. This is sometimes necessary when - compiler-based thread-local storage does not - provide zero-based initialization (something - that pthread_key_t *does* provide).])]) - AC_MSG_CHECKING(for thread local storage (TLS) class) - AC_CACHE_VAL([ac_cv_tls], [ - AS_IF([test "x$enable_native_tls" != xno], [ - ax_tls_keywords="__thread __declspec(thread) none" - for ax_tls_keyword in $ax_tls_keywords; do - AS_IF([test "$ax_tls_keyword" = "none"], - [ac_cv_tls=none - break], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[ static ] $ax_tls_keyword [ int bar; - exit(1);]])], - [ac_cv_tls=$ax_tls_keyword ; break], - [ac_cv_tls=none])]) - done], - [ac_cv_tls=none]) - ]) - AC_MSG_RESULT($ac_cv_tls) - - AS_IF([test "$ac_cv_tls" != "none"], - [AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here]) - $1], - [$2]) -]) diff --git a/configure.ac b/configure.ac index 3e516d0ba..d7adb84f2 100644 --- a/configure.ac +++ b/configure.ac @@ -616,7 +616,6 @@ case "$qthread_cv_c_compiler_type" in enable_native_tls=no ;; esac -AX_TLS # Figure out whether the compiler has builtin atomic operations AS_IF([test "x$enable_hardware_atomics" != xno], From 5da94995d8dacf9b6708591a8b29422fb5f50d51 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:48:03 -0700 Subject: [PATCH 06/38] Get rid of the system extensions check automake file. --- Makefile.am | 1 - acinclude.m4 | 3 +- config/ac_use_system_extensions.m4 | 91 ------------------------------ 3 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 config/ac_use_system_extensions.m4 diff --git a/Makefile.am b/Makefile.am index 6c58aef7d..d85c81b74 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,6 @@ # want them distributed in case someone with AC 2.59 wants to run autoreconf EXTRA_DIST = \ config/ac_prog_cc_c99.m4 \ - config/ac_use_system_extensions.m4 \ README.md \ README.affinity \ README.multinode \ diff --git a/acinclude.m4 b/acinclude.m4 index e83253bde..b2b774f48 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -5,5 +5,4 @@ dnl Copyright (c) 2008 Sandia Corporation dnl Only include this if we're using an old Autoconf. Remove when we dnl finally drop support for AC 2.59 m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [2.60]), -1, - [m4_include([config/ac_prog_cc_c99.m4]) - m4_include([config/ac_use_system_extensions.m4])]) + [m4_include([config/ac_prog_cc_c99.m4])]) diff --git a/config/ac_use_system_extensions.m4 b/config/ac_use_system_extensions.m4 deleted file mode 100644 index cac3ac4dd..000000000 --- a/config/ac_use_system_extensions.m4 +++ /dev/null @@ -1,91 +0,0 @@ -# -*- Autoconf -*- -# -# This file is from Autoconf 2.61, for compatibility with older -# Autoconfs. Original copyright below. -# Remove this file when we drop support for AC 2.59 and older - -# This file is part of Autoconf. -*- Autoconf -*- -# Macros that test for specific, unclassified, features. -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception, the Free Software Foundation gives unlimited -# permission to copy, distribute and modify the configure scripts that -# are the output of Autoconf. You need not follow the terms of the GNU -# General Public License when using or distributing such scripts, even -# though portions of the text of Autoconf appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the Autoconf program. -# -# Certain portions of the Autoconf source text are designed to be copied -# (in certain cases, depending on the input) into the output of -# Autoconf. We call these the "data" portions. The rest of the Autoconf -# source text consists of comments plus executable code that decides which -# of the data portions to output in any given case. We call these -# comments and executable code the "non-data" portions. Autoconf never -# copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of Autoconf -# released by the Free Software Foundation. When you make and -# distribute a modified version of Autoconf, you may extend this special -# exception to the GPL to apply to your modified version as well, *unless* -# your modified version has the potential to copy into its output some -# of the text that was the non-data portion of the version that you started -# with. (In other words, unless your change moves or copies text from -# the non-data portions to the data portions.) If your modification has -# such potential, you must delete any notice of this special exception -# to the GPL from your modified version. -# -# Written by David MacKenzie, with help from -# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, -# Roland McGrath, Noah Friedman, david d zuhn, and many others. - -# AC_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], -[ - AC_BEFORE([$0], [AC_COMPILE_IFELSE]) - AC_BEFORE([$0], [AC_RUN_IFELSE]) - - AC_REQUIRE([AC_GNU_SOURCE]) - AC_REQUIRE([AC_MINIX]) - - AH_VERBATIM([__EXTENSIONS__], -[ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif]) - AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], - [ac_cv_safe_to_define___extensions__], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ -# define __EXTENSIONS__ 1 - AC_INCLUDES_DEFAULT])], - [ac_cv_safe_to_define___extensions__=yes], - [ac_cv_safe_to_define___extensions__=no])]) - test $ac_cv_safe_to_define___extensions__ = yes && - AC_DEFINE([__EXTENSIONS__]) - AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) - AC_DEFINE([_TANDEM_SOURCE]) -]) From bfc24ee68714f0e6b216feefa3c993bad292e19a Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:52:24 -0700 Subject: [PATCH 07/38] Remove any mention of HPUX since it's no longer supported. --- README.affinity | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.affinity b/README.affinity index 0bbdc8080..aba594646 100644 --- a/README.affinity +++ b/README.affinity @@ -4,7 +4,7 @@ machine, the better decisions can be made about affinity. The best-supported library is hwloc, which provides a full set of topology querying and thread- and memory-pinning functions on the widest variety of -platforms, including Linux, BSD, HP-UX, and more. When using hwloc, the default +platforms, including Linux, BSD, and more. When using hwloc, the default arrangement is to pin each worker thread to a PU (the lowest level computational processing unit), and to group them (for the Sherwood scheduler) by the top-level cache. From 8eec89a23c4dd8602b81666ca60d98e10ae9cfa6 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 10:59:37 -0700 Subject: [PATCH 08/38] Remove unused type size detection config file. --- config/ac_compile_check_sizeof.m4 | 116 ------------------------------ 1 file changed, 116 deletions(-) delete mode 100644 config/ac_compile_check_sizeof.m4 diff --git a/config/ac_compile_check_sizeof.m4 b/config/ac_compile_check_sizeof.m4 deleted file mode 100644 index 2d64a141c..000000000 --- a/config/ac_compile_check_sizeof.m4 +++ /dev/null @@ -1,116 +0,0 @@ -##### http://autoconf-archive.cryp.to/ac_compile_check_sizeof.html -# -# SYNOPSIS -# -# AC_COMPILE_CHECK_SIZEOF(TYPE [, HEADERS [, EXTRA_SIZES...]]) -# -# DESCRIPTION -# -# This macro checks for the size of TYPE using compile checks, not -# run checks. You can supply extra HEADERS to look into. the check -# will cycle through 1 2 4 8 16 and any EXTRA_SIZES the user -# supplies. If a match is found, it will #define SIZEOF_`TYPE' to -# that value. Otherwise it will emit a configure time error -# indicating the size of the type could not be determined. -# -# The trick is that C will not allow duplicate case labels. While -# this is valid C code: -# -# switch (0) case 0: case 1:; -# -# The following is not: -# -# switch (0) case 0: case 0:; -# -# Thus, the AC_TRY_COMPILE will fail if the currently tried size does -# not match. -# -# Here is an example skeleton configure.in script, demonstrating the -# macro's usage: -# -# AC_PROG_CC -# AC_CHECK_HEADERS(stddef.h unistd.h) -# AC_TYPE_SIZE_T -# AC_CHECK_TYPE(ssize_t, int) -# -# headers='#ifdef HAVE_STDDEF_H -# #include -# #endif -# #ifdef HAVE_UNISTD_H -# #include -# #endif -# ' -# -# AC_COMPILE_CHECK_SIZEOF(char) -# AC_COMPILE_CHECK_SIZEOF(short) -# AC_COMPILE_CHECK_SIZEOF(int) -# AC_COMPILE_CHECK_SIZEOF(long) -# AC_COMPILE_CHECK_SIZEOF(unsigned char *) -# AC_COMPILE_CHECK_SIZEOF(void *) -# AC_COMPILE_CHECK_SIZEOF(size_t, $headers) -# AC_COMPILE_CHECK_SIZEOF(ssize_t, $headers) -# AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers) -# AC_COMPILE_CHECK_SIZEOF(off_t, $headers) -# -# LAST MODIFICATION -# -# 2007-07-31 -# -# COPYLEFT -# -# Copyright (c) 2007 Kaveh Ghazi -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see -# . -# -# As a special exception, the respective Autoconf Macro's copyright -# owner gives unlimited permission to copy, distribute and modify the -# configure scripts that are the output of Autoconf when processing -# the Macro. You need not follow the terms of the GNU General Public -# License when using or distributing such scripts, even though -# portions of the text of the Macro appear in them. The GNU General -# Public License (GPL) does govern all other use of the material that -# constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the -# Autoconf Macro released by the Autoconf Macro Archive. When you -# make and distribute a modified version of the Autoconf Macro, you -# may extend this special exception to the GPL to apply to your -# modified version as well. - -AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(size of $1) -AC_CACHE_VAL(AC_CV_NAME, -[for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence. - AC_TRY_COMPILE([#include "confdefs.h" -#include -$2 -], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) - if test x$AC_CV_NAME != x ; then break; fi -done -]) -if test x$AC_CV_NAME = x ; then - AC_MSG_ERROR([cannot determine a size for $1]) -fi -AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) -undefine([AC_TYPE_NAME])dnl -undefine([AC_CV_NAME])dnl -]) From e2e0ead6ea19bfef22d30c021799b016602c1dd8 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 11:09:15 -0700 Subject: [PATCH 09/38] Drop c99 checking config file. All compilers we support default to a later standard at this point anyway. --- Makefile.am | 4 - acinclude.m4 | 8 -- config/ac_prog_cc_c99.m4 | 252 --------------------------------------- 3 files changed, 264 deletions(-) delete mode 100644 acinclude.m4 delete mode 100644 config/ac_prog_cc_c99.m4 diff --git a/Makefile.am b/Makefile.am index d85c81b74..7e4394b84 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,11 +3,7 @@ # Copyright (c) 2008 Sandia Corporation # -# The config files here are included because, if I build the distribution -# tarball with AC 2.60 or better, they aren't included by acinclude.m4; but I -# want them distributed in case someone with AC 2.59 wants to run autoreconf EXTRA_DIST = \ - config/ac_prog_cc_c99.m4 \ README.md \ README.affinity \ README.multinode \ diff --git a/acinclude.m4 b/acinclude.m4 deleted file mode 100644 index b2b774f48..000000000 --- a/acinclude.m4 +++ /dev/null @@ -1,8 +0,0 @@ -dnl -*- autoconf -*- -dnl -dnl Copyright (c) 2008 Sandia Corporation - -dnl Only include this if we're using an old Autoconf. Remove when we -dnl finally drop support for AC 2.59 -m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [2.60]), -1, - [m4_include([config/ac_prog_cc_c99.m4])]) diff --git a/config/ac_prog_cc_c99.m4 b/config/ac_prog_cc_c99.m4 deleted file mode 100644 index 0042ab076..000000000 --- a/config/ac_prog_cc_c99.m4 +++ /dev/null @@ -1,252 +0,0 @@ -# -*- Autoconf -*- -# -# This file is from Autoconf 2.61, for compatibility with older -# Autoconfs. Original copyright below. -# Remove this file when we drop support for AC 2.59 and older - -# This file is part of Autoconf. -*- Autoconf -*- -# Programming languages support. -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception, the Free Software Foundation gives unlimited -# permission to copy, distribute and modify the configure scripts that -# are the output of Autoconf. You need not follow the terms of the GNU -# General Public License when using or distributing such scripts, even -# though portions of the text of Autoconf appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the Autoconf program. -# -# Certain portions of the Autoconf source text are designed to be copied -# (in certain cases, depending on the input) into the output of -# Autoconf. We call these the "data" portions. The rest of the Autoconf -# source text consists of comments plus executable code that decides which -# of the data portions to output in any given case. We call these -# comments and executable code the "non-data" portions. Autoconf never -# copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of Autoconf -# released by the Free Software Foundation. When you make and -# distribute a modified version of Autoconf, you may extend this special -# exception to the GPL to apply to your modified version as well, *unless* -# your modified version has the potential to copy into its output some -# of the text that was the non-data portion of the version that you started -# with. (In other words, unless your change moves or copies text from -# the non-data portions to the data portions.) If your modification has -# such potential, you must delete any notice of this special exception -# to the GPL from your modified version. -# -# Written by David MacKenzie, with help from -# Akim Demaille, Paul Eggert, -# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, -# Roland McGrath, Noah Friedman, david d zuhn, and many others. - - -# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, -# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) -# -------------------------------------------------------------- -# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99') -# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails, -# try again with each compiler option in the space-separated OPTION-LIST; if one -# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE, -# else ACTION-IF-UNAVAILABLE. -AC_DEFUN([_AC_C_STD_TRY], -[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C])) -AC_CACHE_VAL(ac_cv_prog_cc_$1, -[ac_cv_prog_cc_$1=no -ac_save_CC=$CC -AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) -for ac_arg in '' $4 -do - CC="$ac_save_CC $ac_arg" - _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) - test "x$ac_cv_prog_cc_$1" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -])# AC_CACHE_VAL -case "x$ac_cv_prog_cc_$1" in - x) - AC_MSG_RESULT([none needed]) ;; - xno) - AC_MSG_RESULT([unsupported]) ;; - *) - CC="$CC $ac_cv_prog_cc_$1" - AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;; -esac -AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6]) -])# _AC_C_STD_TRY - - -# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) -# ---------------------------------------------------------------- -# If the C compiler is not in ISO C99 mode by default, try to add an -# option to output variable CC to make it so. This macro tries -# various options that select ISO C99 on some system or another. It -# considers the compiler to be in ISO C99 mode if it handles _Bool, -# // comments, flexible array members, inline, long long int, mixed -# code and declarations, named initialization of structs, restrict, -# va_copy, varargs macros, variable declarations in for loops and -# variable length arrays. -AC_DEFUN([_AC_PROG_CC_C99], -[_AC_C_STD_TRY([c99], -[[#include -#include -#include -#include -#include - -// Check varargs macros. These examples are taken from C99 6.10.3.5. -#define debug(...) fprintf (stderr, __VA_ARGS__) -#define showlist(...) puts (#__VA_ARGS__) -#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) -static void -test_varargs_macros (void) -{ - int x = 1234; - int y = 5678; - debug ("Flag"); - debug ("X = %d\n", x); - showlist (The first, second, and third items.); - report (x>y, "x is %d but y is %d", x, y); -} - -// Check long long types. -#define BIG64 18446744073709551615ull -#define BIG32 4294967295ul -#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) -#if !BIG_OK - your preprocessor is broken; -#endif -#if BIG_OK -#else - your preprocessor is broken; -#endif -static long long int bignum = -9223372036854775807LL; -static unsigned long long int ubignum = BIG64; - -struct incomplete_array -{ - int datasize; - double data[]; -}; - -struct named_init { - int number; - const wchar_t *name; - double average; -}; - -typedef const char *ccp; - -static inline int -test_restrict (ccp restrict text) -{ - // See if C++-style comments work. - // Iterate through items via the restricted pointer. - // Also check for declarations in for loops. - for (unsigned int i = 0; *(text+i) != '\0'; ++i) - continue; - return 0; -} - -// Check varargs and va_copy. -static void -test_varargs (const char *format, ...) -{ - va_list args; - va_start (args, format); - va_list args_copy; - va_copy (args_copy, args); - - const char *str; - int number; - float fnumber; - - while (*format) - { - switch (*format++) - { - case 's': // string - str = va_arg (args_copy, const char *); - break; - case 'd': // int - number = va_arg (args_copy, int); - break; - case 'f': // float - fnumber = va_arg (args_copy, double); - break; - default: - break; - } - } - va_end (args_copy); - va_end (args); -} -]], -[[ - // Check bool. - _Bool success = false; - - // Check restrict. - if (test_restrict ("String literal") == 0) - success = true; - char *restrict newvar = "Another string"; - - // Check varargs. - test_varargs ("s, d' f .", "string", 65, 34.234); - test_varargs_macros (); - - // Check flexible array members. - struct incomplete_array *ia = - malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); - ia->datasize = 10; - for (int i = 0; i < ia->datasize; ++i) - ia->data[i] = i * 1.234; - - // Check named initializers. - struct named_init ni = { - .number = 34, - .name = L"Test wide string", - .average = 543.34343, - }; - - ni.number = 58; - - int dynamic_array[ni.number]; - dynamic_array[ni.number - 1] = 543; - - // work around unused variable warnings - return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' - || dynamic_array[ni.number - 1] != 543); -]], -dnl Try -dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) -dnl Intel ICC -c99 -dnl IRIX -c99 -dnl Tru64 -c99 -dnl with extended modes being tried first. -[[-std=gnu99 -c99]], [$1], [$2])[]dnl -])# _AC_PROG_CC_C99 - -# AC_PROG_CC_C99 -# -------------- -AC_DEFUN([AC_PROG_CC_C99], -[ AC_REQUIRE([AC_PROG_CC])dnl - _AC_PROG_CC_C99 -]) From d9ad16c61ff0adf4f8fe20d115e4e54f2de9b0cb Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 11:25:11 -0700 Subject: [PATCH 10/38] Remove detection config for the restrict keyword. This can be done easily in the preprocessor instead. --- config/ax_c_restrict.m4 | 102 ------------------------------------ configure.ac | 1 - include/qthread/common.h.in | 11 ++-- 3 files changed, 6 insertions(+), 108 deletions(-) delete mode 100644 config/ax_c_restrict.m4 diff --git a/config/ax_c_restrict.m4 b/config/ax_c_restrict.m4 deleted file mode 100644 index 9bfe58d59..000000000 --- a/config/ax_c_restrict.m4 +++ /dev/null @@ -1,102 +0,0 @@ -# -*- Autoconf -*- -# -# This file contains a function from Autoconf 2.64 (renamed AX_C_RESTRICT from -# AC_C_RESTRICT, to avoid conflicts), for compatibility with older Autoconfs. -# Original copyright below. -# Remove this file when we drop support for AC 2.59 and older - -# This file is part of Autoconf. -*- Autoconf -*- -# Programming languages support. -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception, the Free Software Foundation gives unlimited -# permission to copy, distribute and modify the configure scripts that -# are the output of Autoconf. You need not follow the terms of the GNU -# General Public License when using or distributing such scripts, even -# though portions of the text of Autoconf appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the Autoconf program. -# -# Certain portions of the Autoconf source text are designed to be copied -# (in certain cases, depending on the input) into the output of -# Autoconf. We call these the "data" portions. The rest of the Autoconf -# source text consists of comments plus executable code that decides which -# of the data portions to output in any given case. We call these -# comments and executable code the "non-data" portions. Autoconf never -# copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of Autoconf -# released by the Free Software Foundation. When you make and -# distribute a modified version of Autoconf, you may extend this special -# exception to the GPL to apply to your modified version as well, *unless* -# your modified version has the potential to copy into its output some -# of the text that was the non-data portion of the version that you started -# with. (In other words, unless your change moves or copies text from -# the non-data portions to the data portions.) If your modification has -# such potential, you must delete any notice of this special exception -# to the GPL from your modified version. -# -# Written by David MacKenzie, with help from -# Akim Demaille, Paul Eggert, -# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, -# Roland McGrath, Noah Friedman, david d zuhn, and many others. - -# AC_C_RESTRICT -# ------------- -# based on acx_restrict.m4, from the GNU Autoconf Macro Archive at: -# http://autoconf-archive.cryp.to/acx_restrict.html -# -# Determine whether the C/C++ compiler supports the "restrict" keyword -# introduced in ANSI C99, or an equivalent. Define "restrict" to the alternate -# spelling, if any; these are more likely to work in both C and C++ compilers of -# the same family, and in the presence of varying compiler options. If only -# plain "restrict" works, do nothing. Here are some variants: -# - GCC supports both __restrict and __restrict__ -# Otherwise, define "restrict" to be empty. -AN_IDENTIFIER([restrict], [AX_C_RESTRICT]) -AC_DEFUN([AX_C_RESTRICT], -[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, - [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; - }]], - [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t)]])], - [ac_cv_c_restrict=$ac_kw]) - test "$ac_cv_c_restrict" != no && break - done - ]) - AH_VERBATIM([restrict], -[/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#undef restrict -]) - case $ac_cv_c_restrict in - restrict) ;; - no) AC_DEFINE([restrict], []) ;; - *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; - esac -])# AC_C_RESTRICT diff --git a/configure.ac b/configure.ac index d7adb84f2..1ce0397cc 100644 --- a/configure.ac +++ b/configure.ac @@ -591,7 +591,6 @@ AS_IF([test "x$qthread_cv_cxx_compiler_type" = "xIntel"], AC_C_CONST AC_C_INLINE -AX_C_RESTRICT AC_C_VOLATILE AS_IF([test "x$enable_third_party_benchmarks" = xyes], [AX_OPENMP([have_openmp=yes], [have_openmp=no]) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index f75ffe142..9e0ac5a07 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -71,11 +71,12 @@ /* Last resort, if no function name macros can be found */ #undef __FUNCTION__ -/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#ifndef restrict -#undef restrict +#ifdef __cplusplus +#ifdef __GNUC__ +#define restrict __restrict +#else +#define restrict +#endif #endif /* If __builtin_trap can be used */ From b889c399b7db50ba55faa96ea2ff45fd2d12d1eb Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 11:36:30 -0700 Subject: [PATCH 11/38] Get rid of config check for 16 byte aligned malloc. All current implementations do this. --- config/ax_check_16aligned_malloc.m4 | 66 ----------------------------- configure.ac | 2 - src/alloc/base.c | 4 -- 3 files changed, 72 deletions(-) delete mode 100644 config/ax_check_16aligned_malloc.m4 diff --git a/config/ax_check_16aligned_malloc.m4 b/config/ax_check_16aligned_malloc.m4 deleted file mode 100644 index 8cd54c222..000000000 --- a/config/ax_check_16aligned_malloc.m4 +++ /dev/null @@ -1,66 +0,0 @@ -dnl based on http://autoconf-archive.cryp.to/ax_check_page_aligned_malloc.html -dnl but different (obviously) -AC_DEFUN([AX_CHECK_16ALIGNED_MALLOC], -[AC_CACHE_CHECK([if mallocs guarantee 16-byte alignment], - [ax_cv_func_malloc_16aligned], - [AC_TRY_RUN([ -#include -#include -#if HAVE_UNISTD_H -# include -#endif - -int main() -{ - int i; - - for (i=0; i<100; i++) - if ((unsigned long)malloc(17) & (15)) - exit (1); - for (i=0; i<100; i++) - if ((unsigned long)malloc(1) & (15)) - exit (1); - exit (0); -} - ], - [ax_cv_func_malloc_16aligned=yes], - [ax_cv_func_malloc_16aligned=no], - [ax_cv_func_malloc_16aligned=no]) - ]) -if test "$ax_cv_func_malloc_16aligned" = yes ; then - AC_DEFINE([HAVE_16ALIGNED_MALLOC], [1], - [Define if `malloc'ing more than 16 bytes always returns a 16-byte-aligned address (common practice on MacOS X).]) -fi -]) -AC_DEFUN([AX_CHECK_16ALIGNED_CALLOC], -[AC_CACHE_CHECK([if callocs guarantee 16-byte alignment], - [ax_cv_func_calloc_16aligned], - [AC_TRY_RUN([ -#include -#include -#if HAVE_UNISTD_H -# include -#endif - -int main() -{ - int i; - - for (i=0; i<100; i++) - if ((unsigned long)calloc(1,17) & (15)) - exit (1); - for (i=0; i<100; i++) - if ((unsigned long)calloc(1,1) & (15)) - exit (1); - exit (0); -} - ], - [ax_cv_func_calloc_16aligned=yes], - [ax_cv_func_calloc_16aligned=no], - [ax_cv_func_calloc_16aligned=no]) - ]) -if test "$ax_cv_func_calloc_16aligned" = yes ; then - AC_DEFINE([HAVE_16ALIGNED_CALLOC], [1], - [Define if `calloc'ing more than 16 bytes always returns a 16-byte-aligned address (common practice on MacOS X).]) -fi -]) diff --git a/configure.ac b/configure.ac index 1ce0397cc..085b191f7 100644 --- a/configure.ac +++ b/configure.ac @@ -669,8 +669,6 @@ QTHREAD_CHECK_QSORT AC_CHECK_DECLS([MADV_ACCESS_LWP],[],[],[[#include #include ]]) AX_CHECK_PAGE_ALIGNED_MALLOC -AX_CHECK_16ALIGNED_MALLOC -AX_CHECK_16ALIGNED_CALLOC QTHREAD_CHECK_WORKING_VALLOC QTHREAD_CHECK_ASSERT([],[AC_MSG_ERROR([assert() does not seem to work])]) diff --git a/src/alloc/base.c b/src/alloc/base.c index f959038c2..1bf3eb215 100644 --- a/src/alloc/base.c +++ b/src/alloc/base.c @@ -39,12 +39,10 @@ void *qt_internal_aligned_alloc(size_t alloc_size, uint_fast16_t alignment) { assert(alloc_size > 0); switch (alignment) { case 0: ret = MALLOC(alloc_size); break; -#if defined(HAVE_16ALIGNED_MALLOC) case 16: case 8: case 4: case 2: ret = MALLOC(alloc_size); break; -#endif default: #if defined(HAVE_WORKING_VALLOC) if (alignment == pagesize) { @@ -80,12 +78,10 @@ void qt_internal_aligned_free(void *ptr, uint_fast16_t alignment) { assert(ptr); switch (alignment) { case 0: qt_free(ptr); break; -#if defined(HAVE_16ALIGNED_MALLOC) case 16: case 8: case 4: case 2: qt_free(ptr); break; -#endif default: #if defined(HAVE_WORKING_VALLOC) || defined(HAVE_PAGE_ALIGNED_MALLOC) if (alignment == pagesize) { From 78c7aece22a807d65bc0b5ac6fefb46c85afbdfa Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 12:39:47 -0700 Subject: [PATCH 12/38] Remove configure code checking for various malloc alignments. Just use aligned_alloc internally instead. Fixes #278. --- config/ax_check_page_aligned_malloc.m4 | 36 --------------- config/qthread_check_working_valloc.m4 | 41 ----------------- configure.ac | 2 - src/alloc/base.c | 61 +------------------------- 4 files changed, 2 insertions(+), 138 deletions(-) delete mode 100644 config/ax_check_page_aligned_malloc.m4 delete mode 100644 config/qthread_check_working_valloc.m4 diff --git a/config/ax_check_page_aligned_malloc.m4 b/config/ax_check_page_aligned_malloc.m4 deleted file mode 100644 index 0292bc54e..000000000 --- a/config/ax_check_page_aligned_malloc.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl from http://autoconf-archive.cryp.to/ax_check_page_aligned_malloc.html -dnl Copyright © 2008 Scott Pakin -dnl -dnl Copying and distribution of this file, with or without modification, are -dnl permitted in any medium without royalty provided the copyright notice and -dnl this notice are preserved. -AC_DEFUN([AX_CHECK_PAGE_ALIGNED_MALLOC], -[AC_CACHE_CHECK([if large mallocs guarantee page-alignment], - [ax_cv_func_malloc_aligned], - [AC_TRY_RUN([ -#include -#include -#if HAVE_UNISTD_H -# include -#endif - -int main() -{ - int pagesize = getpagesize(); - int i; - - for (i=0; i<100; i++) - if ((unsigned long)malloc(pagesize+1) & (pagesize-1)) - exit (1); - exit (0); -} - ], - [ax_cv_func_malloc_aligned=yes], - [ax_cv_func_malloc_aligned=no], - [ax_cv_func_malloc_aligned=no]) - ]) -if test "$ax_cv_func_malloc_aligned" = yes ; then - AC_DEFINE([HAVE_PAGE_ALIGNED_MALLOC], [1], - [Define if `malloc'ing more than one page always returns a page-aligned address.]) -fi -]) diff --git a/config/qthread_check_working_valloc.m4 b/config/qthread_check_working_valloc.m4 deleted file mode 100644 index 8ebdd3586..000000000 --- a/config/qthread_check_working_valloc.m4 +++ /dev/null @@ -1,41 +0,0 @@ -dnl -*- Autoconf -*- -dnl -dnl Copyright (c) 2009 Sandia Corporation -dnl -dnl valloc'd memory cannot safely be freed on all operating systems. (Some -dnl flavors of BSD are the troublemakers.) It's best to avoid using valloc in -dnl favor of posix_memalign, memalign, or an aligned malloc as detected by -dnl AX_CHECK_PAGE_ALIGNED_MALLOC, but if we really want page-aligned memory, -dnl we'll need to avoid freeing it. -AC_DEFUN([QTHREAD_CHECK_WORKING_VALLOC], -[AC_CACHE_CHECK([if valloc()'d memory can be free()'d], - [qthread_cv_working_valloc], - [AC_TRY_RUN([ -#include -#include -#if HAVE_UNISTD_H -# include -#endif - -int main(void) -{ - int i; - char * allocs[100]; - int pg = getpagesize(); - - for (i=0;i<100;i++) - allocs[i] = valloc(pg); - for (i=0;i<100;i++) - free(allocs[i]); - - exit (0); -} - ], - [qthread_cv_working_valloc=yes], - [qthread_cv_working_valloc=no], - [qthread_cv_working_valloc=no]) - ]) -AS_IF([test "x$qthread_cv_working_valloc" = xyes], - [AC_DEFINE([HAVE_WORKING_VALLOC], [1], - [Define if `valloc'ed memory can be `free'd.])]) -]) diff --git a/configure.ac b/configure.ac index 085b191f7..61c2c7daf 100644 --- a/configure.ac +++ b/configure.ac @@ -668,8 +668,6 @@ AC_CHECK_FUNCS([strtol memalign posix_memalign memset memmove munmap memcpy fsta QTHREAD_CHECK_QSORT AC_CHECK_DECLS([MADV_ACCESS_LWP],[],[],[[#include #include ]]) -AX_CHECK_PAGE_ALIGNED_MALLOC -QTHREAD_CHECK_WORKING_VALLOC QTHREAD_CHECK_ASSERT([],[AC_MSG_ERROR([assert() does not seem to work])]) AC_CACHE_SAVE diff --git a/src/alloc/base.c b/src/alloc/base.c index 1bf3eb215..f0b8381da 100644 --- a/src/alloc/base.c +++ b/src/alloc/base.c @@ -34,68 +34,11 @@ void *qt_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void qt_internal_alignment_init(void) { _pagesize = getpagesize(); } void *qt_internal_aligned_alloc(size_t alloc_size, uint_fast16_t alignment) { - void *ret; - - assert(alloc_size > 0); - switch (alignment) { - case 0: ret = MALLOC(alloc_size); break; - case 16: - case 8: - case 4: - case 2: ret = MALLOC(alloc_size); break; - default: -#if defined(HAVE_WORKING_VALLOC) - if (alignment == pagesize) { - ret = valloc(alloc_size); - break; - } -#elif defined(HAVE_PAGE_ALIGNED_MALLOC) - if (alignment == pagesize) { - ret = MALLOC(alloc_size); - break; - } -#endif -#if defined(HAVE_MEMALIGN) - ret = memalign(alignment, alloc_size); -#elif defined(HAVE_POSIX_MEMALIGN) - posix_memalign(&(ret), alignment, alloc_size); -#else - { - uint8_t *tmp = MALLOC((alloc_size + alignment - 1) + sizeof(void *)); - if (!tmp) { return NULL; } - ret = (void *)(((uintptr_t)(tmp + sizeof(void *) + alignment - 1)) & - ~(alignment - 1)); - *((void **)ret - 1) = tmp; - } break; -#endif /* if defined(HAVE_MEMALIGN) */ - } - assert(ret); - assert(((uintptr_t)ret & (alignment - 1)) == 0); - return ret; + return aligned_alloc((size_t) alignment, alloc_size); } void qt_internal_aligned_free(void *ptr, uint_fast16_t alignment) { - assert(ptr); - switch (alignment) { - case 0: qt_free(ptr); break; - case 16: - case 8: - case 4: - case 2: qt_free(ptr); break; - default: -#if defined(HAVE_WORKING_VALLOC) || defined(HAVE_PAGE_ALIGNED_MALLOC) - if (alignment == pagesize) { - qt_free(ptr); - break; - } -#endif -#if defined(HAVE_MEMALIGN) || defined(HAVE_POSIX_MEMALIGN) - qt_free(ptr); -#else - assert((uintptr_t) * ((void **)ptr - 1) > 4096); - qt_free(*((void **)ptr - 1)); -#endif - } + qt_free(ptr); } /* vim:set expandtab: */ From c3d1f596e992d6771817fe63a0c89e3948133f67 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 13:32:54 -0700 Subject: [PATCH 13/38] Remove old qthread multinode code. It hasn't been tested or maintained in many many years. --- Makefile.am | 4 - README.multinode | 54 --- config/ompi_check_package.m4 | 170 ------- configure.ac | 26 +- include/Makefile.am | 4 - include/net/net.h | 42 -- include/qt_debug.h | 11 - include/qt_multinode_innards.h | 8 - include/qthread/Makefile.am | 6 - include/qthread/multinode.h | 28 -- src/Makefile.am | 7 - src/net/Makefile.inc | 8 - src/net/net.c | 463 ------------------ src/net/portals4/Makefile.inc | 10 - src/net/portals4/portals4.c | 612 ------------------------ src/net/portals4/runtime-pmi.c | 237 --------- src/net/portals4/runtime.h | 23 - src/qthread.c | 9 - src/shepherds.c | 2 - src/spr.c | 435 ----------------- test/Makefile.am | 10 +- test/multinode/Makefile.am | 88 ---- test/multinode/broadcast.c | 89 ---- test/multinode/env_qthread_initialize.c | 61 --- test/multinode/get.c | 164 ------- test/multinode/hello_world.c | 37 -- test/multinode/in_edges.c | 124 ----- test/multinode/latency.c | 125 ----- test/multinode/put.c | 173 ------- test/multinode/qthread_fork_remote.c | 140 ------ test/multinode/ring.c | 49 -- test/multinode/spmd.c | 41 -- test/multinode/spr_init.c | 60 --- test/multinode/uts.c | 415 ---------------- 34 files changed, 3 insertions(+), 3732 deletions(-) delete mode 100644 README.multinode delete mode 100644 config/ompi_check_package.m4 delete mode 100644 include/net/net.h delete mode 100644 include/qt_multinode_innards.h delete mode 100644 include/qthread/multinode.h delete mode 100644 src/net/Makefile.inc delete mode 100644 src/net/net.c delete mode 100644 src/net/portals4/Makefile.inc delete mode 100644 src/net/portals4/portals4.c delete mode 100644 src/net/portals4/runtime-pmi.c delete mode 100644 src/net/portals4/runtime.h delete mode 100644 src/spr.c delete mode 100644 test/multinode/Makefile.am delete mode 100644 test/multinode/broadcast.c delete mode 100644 test/multinode/env_qthread_initialize.c delete mode 100644 test/multinode/get.c delete mode 100644 test/multinode/hello_world.c delete mode 100644 test/multinode/in_edges.c delete mode 100644 test/multinode/latency.c delete mode 100644 test/multinode/put.c delete mode 100644 test/multinode/qthread_fork_remote.c delete mode 100644 test/multinode/ring.c delete mode 100644 test/multinode/spmd.c delete mode 100644 test/multinode/spr_init.c delete mode 100644 test/multinode/uts.c diff --git a/Makefile.am b/Makefile.am index 7e4394b84..3f3ea6dd0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,6 @@ EXTRA_DIST = \ README.md \ README.affinity \ - README.multinode \ README.performance-monitoring.md \ SCHEDULING \ TODO.md \ @@ -37,9 +36,6 @@ featuretests: core stresstests: core $(MAKE) -C test stresstests -multinodetests: core - $(MAKE) -C test multinodetests - buildtests: tests tests: diff --git a/README.multinode b/README.multinode deleted file mode 100644 index 9a5bfa6b8..000000000 --- a/README.multinode +++ /dev/null @@ -1,54 +0,0 @@ -Multinode Qthreads -================== - -A rather terse introduction to multinode Qthreads. - -Configuring and Building ------------------------- - - ./configure --enable-multinode \ - --with-portals4[=DIR] - [...] - make - -Running a Test -------------- - - make -C test/multinode hello_world - -Launching with SLURM and `mpi`: - - env VERBOSE=1 salloc --node=4-4 --ntasks=1 mpirun hello_world - Hello from locale 003! - Hello from locale 001! - Hello from locale 004! - Hello from locale 002! - -Launching with SLURM and `pmi`: - - env VERBOSE=1 srun -n 4 hello_world - Hello from locale 003! - Hello from locale 001! - Hello from locale 004! - Hello from locale 002! - -Launching with YOD (provided with Portals4): - - env VERBOSE=1 yod.hydra -c 4 hello_world - Hello from locale 003! - Hello from locale 001! - Hello from locale 004! - Hello from locale 002! - -Further Reading ---------------- - -Related code: - -- `include/qthread/multinode.h`, `include/qt_multinode_innards.h`, `src/net` -- `include/qthread/spr.h`, `src/spr.c` - -Related tests: - -- `test/multinode` - diff --git a/config/ompi_check_package.m4 b/config/ompi_check_package.m4 deleted file mode 100644 index d8d322af9..000000000 --- a/config/ompi_check_package.m4 +++ /dev/null @@ -1,170 +0,0 @@ -# -*- shell-script -*- -# -# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana -# University Research and Technology -# Corporation. All rights reserved. -# Copyright (c) 2004-2005 The University of Tennessee and The University -# of Tennessee Research Foundation. All rights -# reserved. -# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, -# University of Stuttgart. All rights reserved. -# Copyright (c) 2004-2005 The Regents of the University of California. -# All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -# _OMPI_CHECK_PACKAGE_HEADER(prefix, header, dir-prefix, -# [action-if-found], [action-if-not-found]) -# -------------------------------------------------------------------- -AC_DEFUN([_OMPI_CHECK_PACKAGE_HEADER], [ - # This is stolen from autoconf to peek under the covers to get the - # cache variable for the library check. one should not copy this - # code into other places unless you want much pain and suffering - AS_VAR_PUSHDEF([ompi_Header], [ac_cv_header_$2]) - - # so this sucks, but there's no way to get through the progression - # of header includes without killing off the cache variable and trying - # again... - unset ompi_Header - - ompi_check_package_header_happy="no" - AS_IF([test "$3" = "/usr" -o "$3" = "/usr/local"], - [ # try as is... - AC_VERBOSE([looking for header without includes]) - AC_CHECK_HEADER([$2], [ompi_check_package_header_happy="yes"], - [ompi_check_package_header_happy="no"]) - AS_IF([test "$ompi_check_package_header_happy" = "no"], - [# no go on the as is - reset the cache and try again - unset ompi_Header])]) - - AS_IF([test "$ompi_check_package_header_happy" = "no"], - [AS_IF([test "$3" != ""], - [$1_CPPFLAGS="$$1_CPPFLAGS -I$3/include -I$3" - CPPFLAGS="$CPPFLAGS -I$3/include -I$3"]) - AC_CHECK_HEADER([$2], [$4], [$5])], - [$4]) - unset ompi_check_package_header_happy]) - - dnl AS_VAR_POPDEF([ompi_Header])dnl -]) - - -# _OMPI_CHECK_PACKAGE_LIB(prefix, library, function, extra-libraries, -# dir-prefix, libdir, -# [action-if-found], [action-if-not-found]]) -# -------------------------------------------------------------------- -AC_DEFUN([_OMPI_CHECK_PACKAGE_LIB], [ - # This is stolen from autoconf to peek under the covers to get the - # cache variable for the library check. one should not copy this - # code into other places unless you want much pain and suffering - AS_LITERAL_IF([$2], - [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2_$3])], - [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2''_$3])])dnl - - # see comment above - unset ompi_Lib - ompi_check_package_lib_happy="no" - AS_IF([test "$6" != ""], - [ # libdir was specified - search only there - $1_LDFLAGS="$$1_LDFLAGS -L$6" - LDFLAGS="$LDFLAGS -L$6" - AC_CHECK_LIB([$2], [$3], - [ompi_check_package_lib_happy="yes"], - [ompi_check_package_lib_happy="no"], [$4]) - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [LDFLAGS="$ompi_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS" - unset ompi_Lib])], - [ # libdir was not specified - go through search path - ompi_check_package_libdir="$5" - AS_IF([test "$ompi_check_package_libdir" = "" -o "$ompi_check_package_libdir" = "/usr" -o "$ompi_check_package_libdir" = "/usr/local"], - [ # try as is... - AC_VERBOSE([looking for library without search path]) - AC_CHECK_LIB([$2], [$3], - [ompi_check_package_lib_happy="yes"], - [ompi_check_package_lib_happy="no"], [$4]) - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [ # no go on the as is.. see what happens later... - LDFLAGS="$ompi_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS" - unset ompi_Lib])]) - - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [AS_IF([test "$ompi_check_package_libdir" != ""], - [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib" - LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib" - AC_VERBOSE([looking for library in lib]) - AC_CHECK_LIB([$2], [$3], - [ompi_check_package_lib_happy="yes"], - [ompi_check_package_lib_happy="no"], [$4]) - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [ # no go on the as is.. see what happens later... - LDFLAGS="$ompi_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS" - unset ompi_Lib])])]) - - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [AS_IF([test "$ompi_check_package_libdir" != ""], - [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib64" - LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib64" - AC_VERBOSE([looking for library in lib64]) - AC_CHECK_LIB([$2], [$3], - [ompi_check_package_lib_happy="yes"], - [ompi_check_package_lib_happy="no"], [$4]) - AS_IF([test "$ompi_check_package_lib_happy" = "no"], - [ # no go on the as is.. see what happens later... - LDFLAGS="$ompi_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS" - unset ompi_Lib])])])]) - - AS_IF([test "$ompi_check_package_lib_happy" = "yes"], - [$1_LIBS="-l$2 $4" - $7], [$8]) - - AS_VAR_POPDEF([ompi_Lib])dnl -]) - - -# OMPI_CHECK_PACKAGE(prefix, -# header, -# library, -# function, -# extra-libraries, -# dir-prefix, -# libdir-prefix, -# [action-if-found], [action-if-not-found] -# ----------------------------------------------------------- -# check for package defined by header and libs, and probably -# located in dir-prefix, possibly with libs in libdir-prefix. -# Both dir-prefix and libdir-prefix can be empty. Will set -# prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed -AC_DEFUN([OMPI_CHECK_PACKAGE],[ - ompi_check_package_$1_save_CPPFLAGS="$CPPFLAGS" - ompi_check_package_$1_save_LDFLAGS="$LDFLAGS" - ompi_check_package_$1_save_LIBS="$LIBS" - - ompi_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS" - ompi_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS" - ompi_check_package_$1_orig_LIBS="$$1_LIBS" - - _OMPI_CHECK_PACKAGE_HEADER([$1], [$2], [$6], - [_OMPI_CHECK_PACKAGE_LIB([$1], [$3], [$4], [$5], [$6], [$7], - [ompi_check_package_happy="yes"], - [ompi_check_package_happy="no"])], - [ompi_check_package_happy="no"]) - - AS_IF([test "$ompi_check_package_happy" = "yes"], - [$8], - [$1_CPPFLAGS="$ompi_check_package_$1_orig_CPPFLAGS" - $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS" - $1_LIBS="$ompi_check_package_$1_orig_LIBS" - $9]) - - CPPFLAGS="$ompi_check_package_$1_save_CPPFLAGS" - LDFLAGS="$ompi_check_package_$1_save_LDFLAGS" - LIBS="$ompi_check_package_$1_save_LIBS" -]) diff --git a/configure.ac b/configure.ac index 61c2c7daf..2326ae7db 100644 --- a/configure.ac +++ b/configure.ac @@ -171,7 +171,6 @@ AC_ARG_ENABLE([debug], io, loops, mpool, - multinode, qarray, shepherd, syncvars, @@ -181,7 +180,7 @@ AC_ARG_ENABLE([debug], threadqueues, xomp])], [AS_IF([test "x$enable_debug" = "xyes"], - [enable_debug="affinity,threadqueues,thread,shepherd,core,team,mpool,syscalls,febs,syncvars,io,loops,barrier,qarray,futurelib,xomp,multinode"]) + [enable_debug="affinity,threadqueues,thread,shepherd,core,team,mpool,syscalls,febs,syncvars,io,loops,barrier,qarray,futurelib,xomp"]) for area in $(echo "$enable_debug" | sed 's/,/ /g') ; do case "$area" in affinity) enable_debug_affinity=yes ;; @@ -200,7 +199,6 @@ AC_ARG_ENABLE([debug], qarray|qarrays) enable_debug_qarray=yes ;; futurelib) enable_debug_futurelib=yes ;; xomp) enable_debug_xomp=yes ;; - multinode) enable_debug_multinode=yes ;; *) AC_MSG_ERROR([Unrecognized debug category ($area).]) ;; esac done], @@ -383,10 +381,6 @@ AC_ARG_WITH([cacheline-width], [], [with_cacheline_width=256]) -AC_ARG_ENABLE([multinode], - [AS_HELP_STRING([--enable-multinode], - [Enable experimental support for multi-node qthreads applications])]) - AC_ARG_VAR([MPICC], [Path to the MPI C compiler-wrapper.]) AC_ARG_VAR([MPICXX], [Path to the MPI C++ compiler-wrapper.]) @@ -860,8 +854,6 @@ AS_IF([test "x$enable_debug" = x -o "x$enable_debug" = xno], [QTHREAD_DEBUG_FUTURELIB], [prints out futurelib debugging information at runtime]) QT_COND_DEFINE([$enable_debug_xomp], [QTHREAD_DEBUG_XOMP], [prints out xomp debugging information at runtime]) - QT_COND_DEFINE([$enable_debug_multinode], - [QTHREAD_DEBUG_MULTINODE], [prints out multinode debugging information at runtime]) ]) AS_IF([test "x$enable_hardware_timer" != "xno"], @@ -953,16 +945,6 @@ AS_IF([test "x$qthread_topo" != xno], [AC_MSG_ERROR([Specified topology library ($qthread_topo) does not work.])])])]) ]) -AS_IF([test "x$enable_multinode" = "xyes"], - [AC_DEFINE([QTHREAD_MULTINODE], [1], [Defined if multinode support desired]) - QTHREAD_CHECK_PORTALS4([], [AC_MSG_ERROR([Could not find Portals 4 library])]) - CPPFLAGS="$CPPFLAGS $portals4_CPPFLAGS $portals4_runtime_CPPFLAGS" - LDFLAGS="$LDFLAGS $portals4_LDFLAGS $portals4_runtime_LDFLAGS" - LIBS="$LIBS $portals4_LIBS $portals4_runtime_LIBS" - ]) - - - AS_IF([test "x$enable_lf_febs" == "xyes"], [AC_DEFINE([LOCK_FREE_FEBS], [1], [Define to use a lock-free hash table for FEB metadata.])], [enable_lf_febs=no]) @@ -993,7 +975,6 @@ AM_CONDITIONAL([COMPILE_SPAWNCACHE], [test "x$enable_spawn_cache" = "xyes"]) AM_CONDITIONAL([COMPILE_EUREKAS], [test "x$enable_eurekas" = "xyes"]) AM_CONDITIONAL([HAVE_GUARD_PAGES], [test "x$enable_guard_pages" = "xyes"]) AM_CONDITIONAL([HAVE_PROG_TIMELIMIT], [test "x$timelimit_path" != "x"]) -AM_CONDITIONAL([COMPILE_MULTINODE], [test "$enable_multinode" = "yes"]) AM_CONDITIONAL([QTHREAD_PERFORMANCE], [test "$enable_performance_monitoring" = "yes"]) AM_CONDITIONAL([WANT_SINGLE_WORKER_SCHEDULER], [test "x$with_scheduler" = "xnemesis" -o "x$with_scheduler" = "xlifo" -o "x$with_scheduler" = "xmutexfifo" -o "x$with_scheduler" = "xmtsfifo" -o "x$with_scheduler" = "xmdlifo"]) AM_CONDITIONAL([COMPILE_OMP_BENCHMARKS], [test "x$have_openmp" = "xyes"]) @@ -1016,7 +997,6 @@ AC_CONFIG_FILES([Makefile test/utils/rng/Makefile test/basics/Makefile test/features/Makefile - test/multinode/Makefile test/stress/Makefile test/benchmarks/Makefile test/benchmarks/mantevo/Makefile @@ -1045,13 +1025,9 @@ case "$qthread_cv_stack_size" in 2096) stack_string="2kB" ;; *) stack_string="${qthread_cv_stack_size} bytes" ;; esac -AS_IF([test "x$enable_multinode" = "xyes"], - [multinode_string="$enable_multinode, $with_multinode_runtime"], - [multinode_string="no"]) echo "" echo "System Characteristics:" echo " Target Style: $qthread_implementation" -echo " Multi-node: $multinode_string" echo " Topology API: ${qthread_topo:-none}" echo " Qtimer type: ${qthread_timer_type:-none}" echo " Aligned_t size: $sizeof_aligned_t (aligned on $align_aligned_t byte boundaries)" diff --git a/include/Makefile.am b/include/Makefile.am index 50929a7a3..8442e37fe 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -10,7 +10,6 @@ noinst_HEADERS = \ fastcontext/taskimpl.h \ fastcontext/power-ucontext.h \ fastcontext/386-ucontext.h \ - net/net.h \ qthread_innards.h \ qloop_innards.h \ qt_asserts.h \ @@ -61,6 +60,3 @@ if COMPILE_EUREKAS noinst_HEADERS += qt_eurekas.h endif -if COMPILE_MULTINODE -noinst_HEADERS += qt_multinode_innards.h -endif diff --git a/include/net/net.h b/include/net/net.h deleted file mode 100644 index e1124a2f7..000000000 --- a/include/net/net.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef QTHREAD_NET_NET_H -#define QTHREAD_NET_NET_H - -#include - -#include - -int qthread_internal_net_driver_initialize(void); - -int qthread_internal_net_driver_get_rank(void); -int qthread_internal_net_driver_get_size(void); - -int qthread_internal_net_driver_send(int peer, - int tag, - void *start, - size_t len); - -int qthread_internal_net_driver_put(int peer, - void *restrict dest_addr, - void const *restrict src_addr, - size_t size, - aligned_t *restrict feb); -int qthread_internal_net_driver_get(void *restrict dest_addr, - int peer, - void const *restrict src_addr, - size_t size, - aligned_t *restrict feb); - -typedef void (*qthread_internal_net_driver_handler)(int tag, - void *start, - size_t len); -int qthread_internal_net_driver_register( - int tag, qthread_internal_net_driver_handler handler); - -int qthread_internal_net_driver_finalize(void); - -int qthread_internal_net_driver_run(void); - -int qthread_internal_net_driver_barrier(void); - -#endif // ifndef QTHREAD_NET_NET_H -/* vim:set expandtab: */ diff --git a/include/qt_debug.h b/include/qt_debug.h index 3d13aed4d..9924633bb 100644 --- a/include/qt_debug.h +++ b/include/qt_debug.h @@ -248,17 +248,6 @@ extern enum qthread_debug_levels debuglevel; #define XOMP_BEHAVIOR NO_DEBUG_OUTPUT #define XOMP_DETAILS NO_DEBUG_OUTPUT #endif -#ifdef QTHREAD_DEBUG_MULTINODE -#define MULTINODE_CALLS DEBUG_CALLS -#define MULTINODE_FUNCTIONS DEBUG_FUNCTIONS -#define MULTINODE_BEHAVIOR DEBUG_BEHAVIOR -#define MULTINODE_DETAILS DEBUG_DETAILS -#else -#define MULTINODE_CALLS NO_DEBUG_OUTPUT -#define MULTINODE_FUNCTIONS NO_DEBUG_OUTPUT -#define MULTINODE_BEHAVIOR NO_DEBUG_OUTPUT -#define MULTINODE_DETAILS NO_DEBUG_OUTPUT -#endif extern QTHREAD_FASTLOCK_TYPE output_lock; diff --git a/include/qt_multinode_innards.h b/include/qt_multinode_innards.h deleted file mode 100644 index 034a57f2a..000000000 --- a/include/qt_multinode_innards.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef QT_MULTINODE_INNARDS_H -#define QT_MULTINODE_INNARDS_H - -#include "qt_visibility.h" - -int INTERNAL qthread_multinode_initialize(void); - -#endif /* #ifndef QT_MULTINODE_INNARDS_H */ diff --git a/include/qthread/Makefile.am b/include/qthread/Makefile.am index 8580d3efe..9788b3d63 100644 --- a/include/qthread/Makefile.am +++ b/include/qthread/Makefile.am @@ -40,12 +40,6 @@ nodist_pkginclude_HEADERS = \ noinst_HEADERS = \ omp_defines.h -if COMPILE_MULTINODE -pkginclude_HEADERS += \ - multinode.h \ - spr.h -endif - # ensure that this happens after the rest of the uninstall is done uninstall-hook: test -d "$(pkgincludedir)" && rmdir $(pkgincludedir) || true diff --git a/include/qthread/multinode.h b/include/qthread/multinode.h deleted file mode 100644 index 724ed5d36..000000000 --- a/include/qthread/multinode.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef QTHREAD_QTHREAD_MULTINODE_H -#define QTHREAD_QTHREAD_MULTINODE_H - -#include - -#include "qthread.h" - -Q_STARTCXX /* */ - -#define FORK_MSG_PAYLOAD 44 - -int qthread_multinode_run(void); -int qthread_multinode_multistart(void); -int qthread_multinode_multistop(void); -int qthread_multinode_rank(void); -int qthread_multinode_size(void); - -int qthread_multinode_register(uint32_t tag, qthread_f f); -int qthread_multinode_action_uid(qthread_f f, uint32_t *tag); -int qthread_multinode_action_ptr(uint32_t tag, qthread_f *ptr); - -int qthread_fork_remote( - qthread_f f, void const *arg, aligned_t *ret, int rank, size_t arg_len); - -Q_ENDCXX /* */ - -#endif // ifndef QTHREAD_QTHREAD_MULTINODE_H - /* vim:set expandtab: */ diff --git a/src/Makefile.am b/src/Makefile.am index 982cdb7f1..86813209e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,13 +62,6 @@ include ds/Makefile.inc include patterns/Makefile.inc include syscalls/Makefile.inc -if COMPILE_MULTINODE -libqthread_la_SOURCES += spr.c - -include net/Makefile.inc -include net/portals4/Makefile.inc -endif - # version-info fields are: # 1. the current interface revision number (i.e. whenever arguments of existing # functions change, increment this number) diff --git a/src/net/Makefile.inc b/src/net/Makefile.inc deleted file mode 100644 index f598909fb..000000000 --- a/src/net/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# -*- Makefile -*- -# vim:ft=automake -# -# Copyright (c) 2011 Sandia Corporation -# - -libqthread_la_SOURCES += \ - net/net.c diff --git a/src/net/net.c b/src/net/net.c deleted file mode 100644 index 5883fcef0..000000000 --- a/src/net/net.c +++ /dev/null @@ -1,463 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* System Headers */ -#include -#include - -/* Public Headers */ -#include "qthread/multinode.h" -#include "qthread/qthread.h" - -/* Internal Headers */ -#include "qt_multinode_innards.h" -// #include "qthread_innards.h" -#include "net/net.h" -#include "qt_asserts.h" -#include "qt_atomics.h" -#include "qt_debug.h" -#include "qt_hash.h" /* for qt_hash */ -#include "qt_subsystems.h" - -static int my_rank; -static int world_size; -static qt_hash uid_to_ptr_hash; -static qt_hash ptr_to_uid_hash; -static aligned_t num_ended = 0; -static aligned_t time_to_die = 0; -static int initialized = 0; - -struct fork_msg_t { - uint64_t return_addr; - uint32_t uid; - int32_t origin_node; - int32_t arg_len; - char args[FORK_MSG_PAYLOAD]; -}; - -struct fork_long_msg_t { - uint64_t return_addr; - uint32_t uid; - int32_t origin_node; - int32_t arg_len; - char args[]; -}; - -struct return_msg_t { - uint64_t return_addr; - uint64_t return_val; -}; - -struct die_msg_t { - uint64_t my_rank; -}; - -#define SHORT_MSG_TAG 0x1 -#define LONG_MSG_TAG 0x6 -#define RETURN_MSG_TAG 0x4 -#define RETURN_LONG_MSG_TAG 0x7 -#define DIE_MSG_TAG 0x3 - -static void net_cleanup(void) { - qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin net_cleanup\n", my_rank); - - if (my_rank == 0) { - int i; - for (i = 1; i < world_size; ++i) { - struct die_msg_t msg; - - msg.my_rank = my_rank; - qthread_debug( - MULTINODE_DETAILS, "[%d] sending die message to %d\n", my_rank, i); - qthread_internal_net_driver_send(i, DIE_MSG_TAG, &msg, sizeof(msg)); - } - - while (num_ended != world_size - 1) SPINLOCK_BODY(); - } - - qthread_internal_net_driver_finalize(); - - qt_hash_destroy(uid_to_ptr_hash); - qt_hash_destroy(ptr_to_uid_hash); - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end net_cleanup\n", my_rank); -} - -static aligned_t fork_helper(void *info) { - struct fork_msg_t *msg = (struct fork_msg_t *)info; - aligned_t ret; - qthread_f f; - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin fork_helper\n", my_rank); - - f = qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)msg->uid); - if (NULL != f) { - ret = f(msg->args); - - if (0 != msg->return_addr) { - struct return_msg_t ret_msg; - ret_msg.return_addr = msg->return_addr; - ret_msg.return_val = ret; - qthread_debug(MULTINODE_DETAILS, - "[%d] sending return msg 0x%lx, %ld\n", - my_rank, - ret_msg.return_addr, - ret_msg.return_val); - qthread_internal_net_driver_send( - msg->origin_node, RETURN_MSG_TAG, &ret_msg, sizeof(ret_msg)); - } - } else { - fprintf(stderr, "action uid %d not registered at destination\n", msg->uid); - abort(); - } - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end fork_helper\n", my_rank); - - return 0; -} - -static aligned_t fork_long_helper(void *info) { - struct fork_long_msg_t *msg = (struct fork_long_msg_t *)info; - aligned_t ret; - qthread_f f; - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin fork_helper\n", my_rank); - - f = qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)msg->uid); - if (NULL != f) { - ret = f(msg->args); - - if (0 != msg->return_addr) { - struct return_msg_t ret_msg; - ret_msg.return_addr = msg->return_addr; - ret_msg.return_val = ret; - qthread_debug(MULTINODE_DETAILS, - "[%d] sending return msg 0x%lx, %ld\n", - my_rank, - ret_msg.return_addr, - ret_msg.return_val); - qthread_internal_net_driver_send( - msg->origin_node, RETURN_MSG_TAG, &ret_msg, sizeof(ret_msg)); - } - } else { - fprintf(stderr, "action uid %d not registered at destination\n", msg->uid); - abort(); - } - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end fork_helper\n", my_rank); - - return 0; -} - -static void fork_msg_handler(int tag, void *start, size_t len) { - qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin fork_msg_handler\n", my_rank); - - if (sizeof(struct fork_msg_t) > len) { abort(); } - - qthread_fork_copyargs(fork_helper, start, len, NULL); - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end fork_msg_handler\n", my_rank); -} - -static void fork_long_msg_handler(int tag, void *start, size_t len) { - qthread_debug( - MULTINODE_FUNCTIONS, "[%d] begin fork_long_msg_handler\n", my_rank); - - qthread_fork_copyargs(fork_long_helper, start, len, NULL); - - qthread_debug( - MULTINODE_FUNCTIONS, "[%d] end fork_long_msg_handler\n", my_rank); -} - -static void return_msg_handler(int tag, void *start, size_t len) { - struct return_msg_t *msg = (struct return_msg_t *)start; - - qthread_debug(MULTINODE_FUNCTIONS, - "[%d] begin return_msg_handler 0x%lx, %ld\n", - my_rank, - (unsigned long)msg->return_addr, - msg->return_val); - - qthread_writeF_const((aligned_t *)msg->return_addr, msg->return_val); - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end return_msg_handler\n", my_rank); -} - -static void return_long_msg_handler(int tag, void *start, size_t len) { - struct return_msg_t *msg = (struct return_msg_t *)start; - - qthread_debug(MULTINODE_FUNCTIONS, - "[%d] begin return_long_msg_handler 0x%lx, %ld\n", - my_rank, - (unsigned long)msg->return_addr, - msg->return_val); - - qthread_writeF_const((aligned_t *)msg->return_addr, msg->return_val); - - // TODO: figure out how to free long message. This is only called when there - // is - // a return value. - - qthread_debug( - MULTINODE_FUNCTIONS, "[%d] end return_long_msg_handler\n", my_rank); -} - -static void die_msg_handler(int tag, void *start, size_t len) { - qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin die_msg_handler\n", my_rank); - - if (my_rank == 0) { - num_ended++; - } else { - qthread_writeF_const(&time_to_die, 1); - } - - qthread_debug(MULTINODE_FUNCTIONS, "[%d] end die_msg_handler\n", my_rank); -} - -int qthread_multinode_initialize(void) { - int ret; - - qthread_debug(MULTINODE_CALLS, "begin qthread_multinode_initialize\n"); - - /* initialize structures */ - initialized = 1; - my_rank = world_size = -1; - uid_to_ptr_hash = qt_hash_create(0); - ptr_to_uid_hash = qt_hash_create(0); - - qthread_internal_net_driver_register(SHORT_MSG_TAG, fork_msg_handler); - qthread_internal_net_driver_register(LONG_MSG_TAG, fork_long_msg_handler); - qthread_internal_net_driver_register(RETURN_MSG_TAG, return_msg_handler); - qthread_internal_net_driver_register(RETURN_LONG_MSG_TAG, - return_long_msg_handler); - qthread_internal_net_driver_register(DIE_MSG_TAG, die_msg_handler); - - /* initialize the network driver and provie barrier */ - ret = qthread_internal_net_driver_initialize(); - if (0 != ret) { - qthread_debug(MULTINODE_FUNCTIONS, - "qthread_internal_net_driver_init failed: %d\n", - ret); - return ret; - } - - my_rank = qthread_internal_net_driver_get_rank(); - world_size = qthread_internal_net_driver_get_size(); - - if (0 != my_rank) { qthread_empty(&time_to_die); } - - /* make sure we can clean up */ - qthread_internal_cleanup_early(net_cleanup); - - qthread_debug( - MULTINODE_CALLS, "[%d] end qthread_multinode_initialize\n", my_rank); - - return QTHREAD_SUCCESS; -} - -int qthread_multinode_run(void) { - aligned_t val; - - if (0 == initialized) { return 1; } - - qthread_debug(MULTINODE_CALLS, "[%d] begin qthread_multinode_run\n", my_rank); - - qthread_internal_net_driver_barrier(); - - if (0 != my_rank) { - struct die_msg_t msg; - - qthread_readFF(&val, &time_to_die); - qthread_debug(MULTINODE_DETAILS, "[%d] time to die\n", my_rank); - msg.my_rank = my_rank; - qthread_internal_net_driver_send(0, DIE_MSG_TAG, &msg, sizeof(msg)); - qthread_finalize(); - exit(0); - } - - qthread_debug(MULTINODE_CALLS, "[%d] end qthread_multinode_run\n", my_rank); - - return QTHREAD_SUCCESS; -} - -int qthread_multinode_multistart(void) { - if (0 == initialized) { return 1; } - - qthread_debug( - MULTINODE_CALLS, "[%d] begin qthread_multinode_multistart\n", my_rank); - - qthread_internal_net_driver_barrier(); - - qthread_debug( - MULTINODE_CALLS, "[%d] end qthread_multinode_multistart\n", my_rank); - - return QTHREAD_SUCCESS; -} - -int qthread_multinode_multistop(void) { - aligned_t val; - - qthread_debug( - MULTINODE_CALLS, "[%d] begin qthread_multinode_multistop\n", my_rank); - - if (0 != my_rank) { - struct die_msg_t msg; - - qthread_readFF(&val, &time_to_die); - qthread_debug(MULTINODE_DETAILS, "[%d] time to die\n", my_rank); - msg.my_rank = my_rank; - qthread_internal_net_driver_send(0, DIE_MSG_TAG, &msg, sizeof(msg)); - - exit(0); // triggers atexit(net_cleanup) - } - - qthread_debug( - MULTINODE_CALLS, "[%d] end qthread_multinode_multistop\n", my_rank); - - return QTHREAD_SUCCESS; -} - -int qthread_multinode_rank(void) { return my_rank; } - -int qthread_multinode_size(void) { return world_size; } - -int qthread_multinode_register(uint32_t uid, qthread_f f) { - int ret = 0; - - if (0 == initialized) { return 1; } - - qthread_debug(MULTINODE_CALLS, - "[%d] begin qthread_multinode_register(uid=%d, ptr=0x%lx)\n", - my_rank, - uid, - (unsigned long)f); - - // Check that UID is strictly positive - if (0 == uid) { - fprintf(stderr, "invalid action id %d: must be > 0", uid); - return 1; - } - - // Check that UID is not used more than once - if (NULL != qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid)) { - fprintf(stderr, "duplicate registration of action uid %d\n", uid); - return 1; - } - - ret = qt_hash_put(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid, f); - if (ret != 1) { - qthread_debug( - MULTINODE_DETAILS, "[%d] uid -> ptr registration failed\n", my_rank); - return 1; - } - - // Check that function pointer is not used more than once - if (NULL != qt_hash_get(ptr_to_uid_hash, f)) { - fprintf(stderr, - "duplicate registration of action function 0x%lx\n", - (unsigned long)f); - return 1; - } - - ret = qt_hash_put(ptr_to_uid_hash, f, (void *)(uintptr_t)uid); - if (ret != 1) { - qthread_debug( - MULTINODE_DETAILS, "[%d] ptr -> uid registration failed\n", my_rank); - return 1; - } - - qthread_debug( - MULTINODE_CALLS, "[%d] end qthread_multinode_register\n", my_rank); - - return 0; -} - -int qthread_multinode_action_uid(qthread_f f, uint32_t *uid) { - int ret = 0; - - if (0 == initialized) { return 1; } - - *uid = (uint64_t)qt_hash_get(ptr_to_uid_hash, f); - - return ret; -} - -int qthread_multinode_action_ptr(uint32_t uid, qthread_f *f) { - int ret = 0; - - if (0 == initialized) { return 1; } - - *f = qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid); - - return ret; -} - -int qthread_fork_remote( - qthread_f f, void const *arg, aligned_t *ret, int rank, size_t arg_len) { - qthread_debug( - MULTINODE_CALLS, - "[%d] begin f=0x%lx, arg=0x%lx, ret=0x%lx, rank=%d, arg_len=%ld)\n", - my_rank, - (unsigned long)f, - (unsigned long)arg, - (unsigned long)ret, - rank, - arg_len); - - uint64_t const uid = (uint64_t)qt_hash_get(ptr_to_uid_hash, f); - if (qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid) != f) { - fprintf(stderr, "action not registered at source\n"); - abort(); - } - - if (NULL != ret) { qthread_empty(ret); } - - if (arg_len <= FORK_MSG_PAYLOAD) { - struct fork_msg_t msg; - - msg.uid = uid; - msg.return_addr = (uint64_t)ret; - msg.origin_node = my_rank; - msg.arg_len = arg_len; - memcpy(msg.args, arg, arg_len); - qthread_debug(MULTINODE_DETAILS, - "[%d] remote fork %d %d 0x%lx %d\n", - my_rank, - rank, - msg.uid, - msg.return_addr, - msg.arg_len); - return qthread_internal_net_driver_send( - rank, SHORT_MSG_TAG, &msg, sizeof(msg)); - } else { - struct fork_long_msg_t *long_msg; - - size_t long_msg_size = sizeof(struct fork_long_msg_t) + arg_len; - long_msg = qt_malloc(long_msg_size); - assert(NULL != long_msg); - - long_msg->uid = uid; - long_msg->return_addr = (uint64_t)ret; - long_msg->origin_node = my_rank; - long_msg->arg_len = arg_len; - memcpy(&long_msg->args, arg, arg_len); - - qthread_debug( - MULTINODE_DETAILS, - "[%d] remote long fork rank=%d uid=%d return_addr=0x%lx arg_len=%d\n", - my_rank, - rank, - long_msg->uid, - long_msg->return_addr, - long_msg->arg_len); - int const rc = qthread_internal_net_driver_send( - rank, LONG_MSG_TAG, long_msg, long_msg_size); - - qt_free(long_msg); - - return rc; - } -} - -/* vim:set expandtab: */ diff --git a/src/net/portals4/Makefile.inc b/src/net/portals4/Makefile.inc deleted file mode 100644 index f853df97b..000000000 --- a/src/net/portals4/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Makefile -*- -# vim:ft=automake -# -# Copyright (c) 2016 Sandia Corporation -# - -libqthread_la_SOURCES += \ - net/portals4/portals4.c \ - net/portals4/runtime-pmi.c \ - net/portals4/runtime.h diff --git a/src/net/portals4/portals4.c b/src/net/portals4/portals4.c deleted file mode 100644 index b7501954d..000000000 --- a/src/net/portals4/portals4.c +++ /dev/null @@ -1,612 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - -#include "net/net.h" -#include "qt_asserts.h" -#include "qt_debug.h" -#include "qt_envariables.h" -#include "qt_mpool.h" -#include "runtime.h" - -struct recv_block_t { - void *start; - ptl_handle_me_t me_h; -}; - -struct net_pkt_t { - int peer; - int tag; - void *start; - size_t len; -}; - -static void *qt_progress_function(void *data); -static void exit_handler(int tag, void *start, size_t len); -static void repost_recv_block(struct recv_block_t *); -static inline int transmit_packet(struct net_pkt_t *pkt); - -static qthread_internal_net_driver_handler handlers[256]; -static struct recv_block_t *recv_blocks = NULL; -static int num_recv_blocks = 0; -static int size_recv_block = 0; -static int max_msg_size = 0; -static ptl_handle_ni_t ni_h; -static ptl_handle_eq_t eq_h; -static ptl_handle_md_t md_h; -static ptl_handle_me_t overflow_me_h; -static ptl_pt_index_t data_pt; -static pthread_t qt_progress_thread; -static qt_mpool mpool; -static int shutdown_msg = 1; - -/* No-matching NI for one-sided comm. */ -static ptl_handle_ni_t nm_ni_h; -static ptl_handle_eq_t nm_eq_h; -static ptl_handle_md_t nm_md_h; -static ptl_handle_le_t nm_le_h; -static ptl_pt_index_t nm_data_pt; - -static inline int qthread_internal_net_driver_initialize_matching(void) { - int ret, i; - ptl_process_t *desired = NULL; - ptl_uid_t uid = PTL_UID_ANY; - ptl_ni_limits_t ni_limits, ni_req_limits; - ptl_md_t md; - ptl_me_t me; - - ni_req_limits.max_entries = 1024; - ni_req_limits.max_unexpected_headers = 1024; - ni_req_limits.max_mds = 1024; - ni_req_limits.max_eqs = 1024; - ni_req_limits.max_cts = 1024; - ni_req_limits.max_pt_index = 64; - ni_req_limits.max_iovecs = 1024; - ni_req_limits.max_list_size = 1024; - ni_req_limits.max_triggered_ops = 1024; - ni_req_limits.max_msg_size = LONG_MAX; - ni_req_limits.max_atomic_size = 512; - ni_req_limits.max_fetch_atomic_size = 512; - ni_req_limits.max_waw_ordered_size = 512; - ni_req_limits.max_war_ordered_size = 512; - ni_req_limits.max_volatile_size = 512; - ni_req_limits.features = 0; - - ret = PtlNIInit(PTL_IFACE_DEFAULT, - PTL_NI_MATCHING | PTL_NI_LOGICAL, - PTL_PID_ANY, - &ni_req_limits, - &ni_limits, - &ni_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlNIInit: %d\n", ret); - return ret; - } - - desired = qthread_internal_net_driver_runtime_get_mapping(ni_h); - if (NULL == desired) { - fprintf(stderr, "internal_net_driver_runtime_get_mapping: %d\n", errno); - return -1; - } - - ret = PtlSetMap(ni_h, qthread_internal_net_driver_get_size(), desired); - if ((PTL_OK != ret) && (PTL_IGNORED != ret)) { - fprintf(stderr, "PtlSetMap: %d\n", ret); - return ret; - } - - ret = PtlGetUid(ni_h, &uid); - if (PTL_OK != ret) { - fprintf(stderr, "PtlGetUid: %d\n", ret); - return ret; - } - - /* create completion EQ/CT and portal table entry */ - ret = PtlEQAlloc(ni_h, 1 * 1024 * 1024, &eq_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlEQAlloc: %d\n", ret); - return ret; - } - - ret = PtlPTAlloc(ni_h, 0, eq_h, 19, &data_pt); - if (PTL_OK != ret) { - fprintf(stderr, "PtlPTAlloc: %d\n", ret); - return ret; - } - - /* post truncating me */ - me.start = NULL; - me.length = 0; - me.ct_handle = PTL_CT_NONE; - me.min_free = 0; - me.uid = PTL_UID_ANY; - me.options = PTL_ME_OP_PUT | PTL_ME_EVENT_SUCCESS_DISABLE | - PTL_ME_UNEXPECTED_HDR_DISABLE; - me.match_id.rank = PTL_RANK_ANY; - me.match_bits = 0x0; - me.ignore_bits = ~(0x0ULL); - ret = - PtlMEAppend(ni_h, data_pt, &me, PTL_OVERFLOW_LIST, NULL, &overflow_me_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlMEAppend: %d\n", ret); - return ret; - } - - /* post receive mes */ - recv_blocks = MALLOC(sizeof(struct recv_block_t) * num_recv_blocks); - if (NULL == recv_blocks) { return -1; } - for (i = 0; i < num_recv_blocks; ++i) { - recv_blocks[i].start = MALLOC(size_recv_block); - if (NULL == recv_blocks[i].start) { return -1; } - recv_blocks[i].me_h = PTL_INVALID_HANDLE; - repost_recv_block(&recv_blocks[i]); - } - - md.start = 0; - md.length = SIZE_MAX; - md.options = PTL_MD_UNORDERED; - md.eq_handle = eq_h; - md.ct_handle = PTL_CT_NONE; - ret = PtlMDBind(ni_h, &md, &md_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlMDBind: %d\n", ret); - return ret; - } - - handlers[0] = exit_handler; - - return ret; -} - -static inline int qthread_internal_net_driver_initialize_no_matching(void) { - int ret, i; - ptl_process_t *desired = NULL; - ptl_uid_t uid = PTL_UID_ANY; - ptl_ni_limits_t ni_limits, ni_req_limits; - ptl_md_t md; - ptl_le_t le; - - ni_req_limits.max_entries = 1024; - ni_req_limits.max_unexpected_headers = 1024; - ni_req_limits.max_mds = 1024; - ni_req_limits.max_eqs = 1024; - ni_req_limits.max_cts = 1024; - ni_req_limits.max_pt_index = 64; - ni_req_limits.max_iovecs = 1024; - ni_req_limits.max_list_size = 1024; - ni_req_limits.max_triggered_ops = 1024; - ni_req_limits.max_msg_size = LONG_MAX; - ni_req_limits.max_atomic_size = 512; - ni_req_limits.max_fetch_atomic_size = 512; - ni_req_limits.max_waw_ordered_size = 512; - ni_req_limits.max_war_ordered_size = 512; - ni_req_limits.max_volatile_size = 512; - ni_req_limits.features = 0; - - ret = PtlNIInit(PTL_IFACE_DEFAULT, - PTL_NI_NO_MATCHING | PTL_NI_LOGICAL, - PTL_PID_ANY, - &ni_req_limits, - &ni_limits, - &nm_ni_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlNIInit: %d\n", ret); - return ret; - } - - desired = qthread_internal_net_driver_runtime_get_mapping(nm_ni_h); - if (NULL == desired) { - fprintf(stderr, "internal_net_driver_runtime_get_mapping: %d\n", errno); - return -1; - } - - ret = PtlSetMap(nm_ni_h, qthread_internal_net_driver_get_size(), desired); - if ((PTL_OK != ret) && (PTL_IGNORED != ret)) { - fprintf(stderr, "PtlSetMap: %d\n", ret); - return ret; - } - - ret = PtlGetUid(nm_ni_h, &uid); - if (PTL_OK != ret) { - fprintf(stderr, "PtlGetUid: %d\n", ret); - return ret; - } - - /* create completion EQ/CT and portal table entry */ - ret = PtlEQAlloc(nm_ni_h, 1 * 1024 * 1024, &nm_eq_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlEQAlloc: %d\n", ret); - return ret; - } - - ret = PtlPTAlloc(nm_ni_h, 0, nm_eq_h, 20, &nm_data_pt); - if (PTL_OK != ret) { - fprintf(stderr, "PtlPTAlloc: %d\n", ret); - return ret; - } - - le.start = 0; - le.length = SIZE_MAX; - le.uid = PTL_UID_ANY; - le.options = (PTL_LE_OP_PUT | PTL_LE_OP_GET); - - ret = PtlCTAlloc(nm_ni_h, &le.ct_handle); - if (PTL_OK != ret) { - fprintf(stderr, "PtlCTAlloc: %d\n", ret); - return ret; - } - - ret = PtlLEAppend(nm_ni_h, 20, &le, PTL_PRIORITY_LIST, NULL, &nm_le_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlLEAppend: %d\n", ret); - return ret; - } - - md.start = 0; - md.length = SIZE_MAX; - md.options = PTL_MD_UNORDERED; - md.eq_handle = nm_eq_h; - - ret = PtlCTAlloc(nm_ni_h, &md.ct_handle); - if (PTL_OK != ret) { - fprintf(stderr, "PtlCTAlloc: %d\n", ret); - return ret; - } - - ret = PtlMDBind(nm_ni_h, &md, &nm_md_h); - if (PTL_OK != ret) { - fprintf(stderr, "PtlMDBind: %d\n", ret); - return ret; - } - - return ret; -} - -int qthread_internal_net_driver_initialize(void) { - int ret; - - qthread_debug(MULTINODE_CALLS, "begin internal_net_driver_initialize\n"); - - num_recv_blocks = qt_internal_get_env_num("PORTALS_RECV_BLOCKS", 3, 3); - size_recv_block = qt_internal_get_env_num( - "PORTALS_RECV_BLOCK_SIZE", 1024 * 1024, 1024 * 1024); - max_msg_size = qt_internal_get_env_num("PORTALS_MAX_MSG_SIZE", 4096, 4096); - - mpool = qt_mpool_create(sizeof(struct net_pkt_t)); - - ret = PtlInit(); - if (PTL_OK != ret) { - fprintf(stderr, "PtlInit: %d\n", ret); - return ret; - } - - /* initialize runtime */ - ret = qthread_internal_net_driver_runtime_init(); - if (0 != ret) { - fprintf(stderr, "internal_net_driver_runtime_init: %d\n", ret); - return ret; - } - - qthread_internal_net_driver_initialize_matching(); - qthread_internal_net_driver_initialize_no_matching(); - - /* spawn the management thread */ - ret = pthread_create(&qt_progress_thread, NULL, qt_progress_function, NULL); - if (0 != ret) { - fprintf(stderr, "pthread_create: %d\n", ret); - return ret; - } - - /* finish up */ - qthread_internal_net_driver_runtime_barrier(); - - qthread_debug(MULTINODE_CALLS, "end internal_net_driver_initialize\n"); - - return 0; -} - -int qthread_internal_net_driver_send(int peer, - int tag, - void *start, - size_t len) { - struct net_pkt_t *pkt; - - if ((tag <= 0) || (tag >= 256)) { return -1; } - - pkt = qt_mpool_alloc(mpool); - pkt->peer = peer; - pkt->tag = tag; - pkt->start = start; - pkt->len = len; - - return transmit_packet(pkt); -} - -int qthread_internal_net_driver_put(int peer, - void *restrict dest_addr, - void const *restrict src_addr, - size_t size, - aligned_t *restrict feb) { - aligned_t ret = 0; - - ptl_ct_event_t ctc; - ptl_process_t dest = {.rank = peer}; - - ret = PtlPut(nm_md_h, - (ptl_size_t)src_addr, - size, - PTL_ACK_REQ, - dest, - 20, - 0, - (ptl_size_t)dest_addr, - feb, - 0); - if (PTL_OK != ret) { - fprintf(stderr, "PtlPut failed: %d\n", (int)ret); - - return (int)ret; - } - - return (int)ret; -} - -int qthread_internal_net_driver_get(void *restrict dest_addr, - int peer, - void const *restrict src_addr, - size_t size, - aligned_t *restrict feb) { - aligned_t ret = 0; - - ptl_ct_event_t ctc; - ptl_process_t dest = {.rank = peer}; - - ret = PtlGet(nm_md_h, - (ptl_size_t)dest_addr, - size, - dest, - 20, - 0, - (ptl_size_t)src_addr, - feb); - if (PTL_OK != ret) { - fprintf(stderr, "PtlGet failed: %d\n", (int)ret); - - return (int)ret; - } - - return (int)ret; -} - -int qthread_internal_net_driver_register( - int tag, qthread_internal_net_driver_handler handler) { - if ((tag <= 0) || (tag >= 256)) { return -1; } - handlers[tag] = handler; - return 0; -} - -int qthread_internal_net_driver_barrier(void) { - qthread_internal_net_driver_runtime_barrier(); - return 0; -} - -int qthread_internal_net_driver_finalize(void) { - int ret, i; - struct net_pkt_t *pkt; - void *dummy; - - /* mark qt_progress thread as time to go away, notify it, and wait */ - pkt = qt_mpool_alloc(mpool); - pkt->peer = qthread_internal_net_driver_get_rank(); - pkt->tag = 0; - pkt->start = &shutdown_msg; - pkt->len = sizeof(shutdown_msg); - - ret = transmit_packet(pkt); - if (0 != ret) { - qthread_debug(MULTINODE_DETAILS, "shutdown internal send: %d\n", ret); - return ret; - } - - /* shut down the progress thread */ - qthread_debug(MULTINODE_DETAILS, "begin waiting on progress thread\n", ret); - ret = pthread_join(qt_progress_thread, &dummy); - qthread_debug(MULTINODE_DETAILS, "end waiting on progress thread\n", ret); - if (0 != ret) { - qthread_debug(MULTINODE_DETAILS, "pthread_join: %d\n", ret); - return ret; - } - - for (i = 0; i < num_recv_blocks; ++i) { - ret = PtlMEUnlink(recv_blocks[i].me_h); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_DETAILS, "PtlMEUnlink returned %d\n", ret); - } - } - -#if 0 - /* there's a cleanup bug in either this code or Portals4 when - * messages are in flight (including acks). Don't clean up for - * now */ - ret = PtlMEUnlink(overflow_me_h); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_DETAILS, "PtlMEUnlink returned %d\n", ret); - } - - ret = PtlMDRelease(md_h); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_DETAILS, "PtlMDRelease returned %d\n", ret); - } - - ret = PtlPTFree(ni_h, data_pt); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_DETAILS, "PtlPTFree returned %d\n", ret); - } - - ret = PtlEQFree(eq_h); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_DETAILS, "PtlEQFree returned %d\n", ret); - } -#endif /* if 0 */ - - qthread_internal_net_driver_runtime_fini(); - - qthread_debug(MULTINODE_DETAILS, "begin finalizing Portals4\n", ret); - - PtlNIFini(ni_h); - PtlNIFini(nm_ni_h); - PtlFini(); - - qthread_debug(MULTINODE_DETAILS, "end finalizing Portals4\n", ret); - - qthread_debug(MULTINODE_DETAILS, "begin destroying memory pool\n", ret); - qt_mpool_destroy(mpool); - qthread_debug(MULTINODE_DETAILS, "end destroying memory pool\n", ret); - - return 0; -} - -static void *qt_progress_function(void *data) { - int ret; - ptl_event_t ev; - - qthread_debug(MULTINODE_CALLS, "begin progress function\n"); - while (1) { - ret = PtlEQGet(eq_h, &ev); - if ((PTL_OK == ret) || (PTL_EQ_DROPPED == ret)) { - switch (ev.type) { - case PTL_EVENT_PUT: - assert(ev.mlength == ev.rlength); - if (NULL == handlers[ev.hdr_data]) { - qthread_debug(MULTINODE_CALLS, - "Got message with unregistered tag %ld, ignoring\n", - (long unsigned)ev.hdr_data); - } else { - handlers[ev.hdr_data](ev.hdr_data, ev.start, ev.mlength); - } - break; - case PTL_EVENT_SEND: - if (PTL_NI_OK != ev.ni_fail_type) { - qthread_debug(MULTINODE_CALLS, - "SEND event with fail type %d\n", - ev.ni_fail_type); - } - break; - case PTL_EVENT_ACK: - if (PTL_NI_OK != ev.ni_fail_type) { - qthread_debug(MULTINODE_CALLS, - "SEND event with fail type %d\n", - ev.ni_fail_type); - } else { - struct net_pkt_t *pkt = (struct net_pkt_t *)ev.user_ptr; - if (ev.mlength != pkt->len) { - if (PTL_OK != ret) { - qthread_debug( - MULTINODE_CALLS, "transmit packet failed: %d\n", ret); - } - } else { - qt_mpool_free(mpool, pkt); - } - } - break; - case PTL_EVENT_AUTO_UNLINK: { - struct recv_block_t *block = (struct recv_block_t *)ev.user_ptr; - repost_recv_block(block); - break; - } - default: break; - } - } - - /* Non-matching interface */ - ret = PtlEQGet(nm_eq_h, &ev); - if ((PTL_OK == ret) || (PTL_EQ_DROPPED == ret)) { - switch (ev.type) { - case PTL_EVENT_REPLY: - /* Get complete at initiator. */ - if (ev.user_ptr) { - qthread_writeF_const((aligned_t *)ev.user_ptr, PTL_OK); - fflush(stderr); - } - break; - case PTL_EVENT_ACK: - /* Put at remote is complete. */ - if (ev.user_ptr) { - qthread_writeF_const((aligned_t *)ev.user_ptr, PTL_OK); - } - break; - case PTL_EVENT_SEND: - /* Put or atomic operation completed at initiator, local buffer - * may be reused, but remote operation not necessarily - * complete. */ - break; - default: - if (ev.user_ptr) { - qthread_writeEF_const((aligned_t *)ev.user_ptr, PTL_OK); - } - break; - break; - } - } else if (PTL_EQ_EMPTY == ret) { - } else { - fprintf(stderr, "Error getting event off of non-matching NI: %d\n", ret); - abort(); - } - } - return NULL; -} - -static void exit_handler(int tag, void *start, size_t len) { - qthread_debug(MULTINODE_CALLS, "end progress function\n"); - pthread_exit(NULL); -} - -static void repost_recv_block(struct recv_block_t *block) { - ptl_me_t me; - int ret; - - me.start = block->start; - me.length = size_recv_block; - me.ct_handle = PTL_CT_NONE; - me.min_free = max_msg_size; - me.uid = PTL_UID_ANY; - me.options = - PTL_ME_OP_PUT | PTL_ME_MANAGE_LOCAL | PTL_ME_NO_TRUNCATE | PTL_ME_MAY_ALIGN; - me.match_id.rank = PTL_RANK_ANY; - me.match_bits = 0; - me.ignore_bits = ~(0ULL); - - ret = PtlMEAppend(ni_h, data_pt, &me, PTL_PRIORITY_LIST, block, &block->me_h); - if (PTL_OK != ret) { abort(); } -} - -static inline int transmit_packet(struct net_pkt_t *pkt) { - int ret; - ptl_process_t peer; - - peer.rank = pkt->peer; - ret = PtlPut(md_h, - (ptl_size_t)pkt->start, - pkt->len, - PTL_ACK_REQ, - peer, - data_pt, - 0, - 0, - pkt, - pkt->tag); - if (PTL_OK != ret) { - qthread_debug(MULTINODE_CALLS, "PtlPut failed: %d\n", ret); - } - - return ret; -} - -/* vim:set expandtab: */ diff --git a/src/net/portals4/runtime-pmi.c b/src/net/portals4/runtime-pmi.c deleted file mode 100644 index bc3307791..000000000 --- a/src/net/portals4/runtime-pmi.c +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- C -*- - * - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Run-time support for the built-in runtime that is part of the - * shared memory implementation Portals - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifdef PMI_SLURM -#include -#else -#include -#endif - -#include - -#include "qt_debug.h" /* for malloc debug wrappers*/ - -#include "runtime.h" - -struct map_t { - ptl_handle_ni_t handle; - ptl_process_t *mapping; -}; - -static int rank = -1; -static int size = 0; -struct map_t maps[4] = {{PTL_INVALID_HANDLE, NULL}, - {PTL_INVALID_HANDLE, NULL}, - {PTL_INVALID_HANDLE, NULL}, - {PTL_INVALID_HANDLE, NULL}}; - -static int -encode(void const *inval, int invallen, char *outval, int outvallen) { - static unsigned char encodings[] = {'0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'a', - 'b', - 'c', - 'd', - 'e', - 'f'}; - int i; - - if (invallen * 2 + 1 > outvallen) { return 1; } - - for (i = 0; i < invallen; i++) { - outval[2 * i] = encodings[((unsigned char *)inval)[i] & 0xf]; - outval[2 * i + 1] = encodings[((unsigned char *)inval)[i] >> 4]; - } - - outval[invallen * 2] = '\0'; - - return 0; -} - -static int decode(char const *inval, void *outval, int outvallen) { - int i; - char *ret = (char *)outval; - - if (outvallen != strlen(inval) / 2) { return 1; } - - for (i = 0; i < outvallen; ++i) { - if (*inval >= '0' && *inval <= '9') { - ret[i] = *inval - '0'; - } else { - ret[i] = *inval - 'a' + 10; - } - inval++; - if (*inval >= '0' && *inval <= '9') { - ret[i] |= ((*inval - '0') << 4); - } else { - ret[i] |= ((*inval - 'a' + 10) << 4); - } - inval++; - } - - return 0; -} - -int qthread_internal_net_driver_runtime_init(void) { - int initialized; - - if (PMI_SUCCESS != PMI_Initialized(&initialized)) { return 1; } - - if (!initialized) { - if (PMI_SUCCESS != PMI_Init(&initialized)) { return 2; } - } - - if (PMI_SUCCESS != PMI_Get_rank(&rank)) { return 3; } - - if (PMI_SUCCESS != PMI_Get_size(&size)) { return 4; } - - return 0; -} - -int qthread_internal_net_driver_runtime_fini(void) { - int i; - - for (i = 0; i < 4; ++i) { - if (NULL != maps[i].mapping) { - FREE(maps[i].mapping, sizeof(ptl_process_t) * size); - } - } - - PMI_Finalize(); - - return 0; -} - -ptl_process_t * -qthread_internal_net_driver_runtime_get_mapping(ptl_handle_ni_t ni_h) { - int i, ret, max_name_len, max_key_len, max_val_len; - char *name, *key, *val; - ptl_process_t my_id; - struct map_t *map = NULL; - - for (i = 0; i < 4; ++i) { - if (maps[i].handle == ni_h) { return maps[i].mapping; } - } - - for (i = 0; i < 4; ++i) { - if (PTL_INVALID_HANDLE == maps[i].handle) { - map = &maps[i]; - break; - } - } - - if (NULL == map) return NULL; - - if (PMI_SUCCESS != PMI_KVS_Get_name_length_max(&max_name_len)) { - return NULL; - } - name = (char *)MALLOC(max_name_len); - if (NULL == name) return NULL; - - if (PMI_SUCCESS != PMI_KVS_Get_key_length_max(&max_key_len)) { return NULL; } - key = (char *)MALLOC(max_key_len); - if (NULL == key) return NULL; - - if (PMI_SUCCESS != PMI_KVS_Get_value_length_max(&max_val_len)) { - return NULL; - } - val = (char *)MALLOC(max_val_len); - if (NULL == val) return NULL; - - ret = PtlGetPhysId(ni_h, &my_id); - if (PTL_OK != ret) return NULL; - - if (PMI_SUCCESS != PMI_KVS_Get_my_name(name, max_name_len)) { return NULL; } - - /* put my information */ - snprintf(key, - max_key_len, - "qthreads-%lu-%lu-nid", - (long unsigned)ni_h, - (long unsigned)rank); - if (0 != encode(&my_id.phys.nid, sizeof(my_id.phys.nid), val, max_val_len)) { - return NULL; - } - if (PMI_SUCCESS != PMI_KVS_Put(name, key, val)) { return NULL; } - - snprintf(key, - max_key_len, - "qthreads-%lu-%lu-pid", - (long unsigned)ni_h, - (long unsigned)rank); - if (0 != encode(&my_id.phys.pid, sizeof(my_id.phys.pid), val, max_val_len)) { - return NULL; - } - if (PMI_SUCCESS != PMI_KVS_Put(name, key, val)) { return NULL; } - - if (PMI_SUCCESS != PMI_KVS_Commit(name)) { return NULL; } - - if (PMI_SUCCESS != PMI_Barrier()) { return NULL; } - - /* get everyone's information */ - map->mapping = MALLOC(sizeof(ptl_process_t) * size); - if (NULL == map->mapping) return NULL; - - for (i = 0; i < size; ++i) { - snprintf(key, - max_key_len, - "qthreads-%lu-%lu-nid", - (long unsigned)ni_h, - (long unsigned)i); - if (PMI_SUCCESS != PMI_KVS_Get(name, key, val, max_val_len)) { - return NULL; - } - if (0 != decode(val, - &(map->mapping)[i].phys.nid, - sizeof((map->mapping)[i].phys.nid))) { - return NULL; - } - - snprintf(key, - max_key_len, - "qthreads-%lu-%lu-pid", - (long unsigned)ni_h, - (long unsigned)i); - if (PMI_SUCCESS != PMI_KVS_Get(name, key, val, max_val_len)) { - return NULL; - } - if (0 != decode(val, - &(map->mapping)[i].phys.pid, - sizeof((map->mapping)[i].phys.pid))) { - return NULL; - } - } - - return map->mapping; -} - -void qthread_internal_net_driver_runtime_barrier(void) { PMI_Barrier(); } - -int qthread_internal_net_driver_get_rank(void) { return rank; } - -int qthread_internal_net_driver_get_size(void) { return size; } - diff --git a/src/net/portals4/runtime.h b/src/net/portals4/runtime.h deleted file mode 100644 index 930bd4bc7..000000000 --- a/src/net/portals4/runtime.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- C -*- - * - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Run-time support interface for portals - */ - -#ifndef NET_PORTALS4_RUNTIME_H -#define NET_PORTALS4_RUNTIME_H - -int qthread_internal_net_driver_runtime_init(void); -int qthread_internal_net_driver_runtime_fini(void); -/* note: get_mapping has barrier semantics */ -ptl_process_t * -qthread_internal_net_driver_runtime_get_mapping(ptl_handle_ni_t ni_h); -void qthread_internal_net_driver_runtime_barrier(void); - -int qthread_internal_net_driver_get_rank(void); -int qthread_internal_net_driver_get_size(void); - -#endif diff --git a/src/qthread.c b/src/qthread.c index f0bbc4fc0..5b0f4d0f0 100644 --- a/src/qthread.c +++ b/src/qthread.c @@ -73,9 +73,6 @@ #include "qt_syncvar.h" #include "qt_threadqueue_scheduler.h" #include "qt_threadqueues.h" -#ifdef QTHREAD_MULTINODE -#include "qt_multinode_innards.h" -#endif #include "qt_alloc.h" #include "qt_teams.h" #ifdef QTHREAD_USE_EUREKAS @@ -1344,12 +1341,6 @@ int API_FUNC qthread_initialize(void) { /*{{{ */ qthread_debug(CORE_DETAILS, "calling component init functions\n"); qt_barrier_internal_init(); -#ifdef QTHREAD_MULTINODE - if (NULL != qt_internal_get_env_str("MULTINODE", NULL)) { - qthread_multinode_initialize(); - } -#endif - qthread_debug(CORE_DETAILS, "finished.\n"); return QTHREAD_SUCCESS; } /*}}} */ diff --git a/src/shepherds.c b/src/shepherds.c index f174a1f14..81c1c4bff 100644 --- a/src/shepherds.c +++ b/src/shepherds.c @@ -36,7 +36,6 @@ int API_FUNC qthread_shep_ok(void) { /*{{{ */ void API_FUNC qthread_shep_next(qthread_shepherd_id_t *shep) { /*{{{*/ assert(qthread_library_initialized); - /* This will mean something slightly different in a multinode world. */ qthread_shepherd_id_t cur = *shep; assert(cur != NO_SHEPHERD); @@ -47,7 +46,6 @@ void API_FUNC qthread_shep_next(qthread_shepherd_id_t *shep) { /*{{{*/ void API_FUNC qthread_shep_prev(qthread_shepherd_id_t *shep) { /*{{{*/ assert(qthread_library_initialized); - /* This will mean something slightly different in a multinode world. */ qthread_shepherd_id_t cur = *shep; assert(cur != NO_SHEPHERD); diff --git a/src/spr.c b/src/spr.c deleted file mode 100644 index b7a7ce10a..000000000 --- a/src/spr.c +++ /dev/null @@ -1,435 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "qthread/qthread.h" - -#include "qthread/multinode.h" -#include "qthread/spr.h" -#include "spr_innards.h" - -#include "net/net.h" -#include "qt_asserts.h" -#include "qt_atomics.h" -#include "qt_debug.h" -#include "qt_multinode_innards.h" -#include "spr_innards.h" - -#include "qthread/barrier.h" - -/****************************************************************************** - * Internal SPR remote actions * - ******************************************************************************/ - -static int initialized_flags = -1; -static int spr_initialized = 0; - -static aligned_t spr_locale_barrier_op(void *arg_); -static qthread_f spr_remote_functions[2] = {spr_locale_barrier_op, NULL}; - -// Locale barrier -static qt_barrier_t *locale_barrier = NULL; - -static void call_fini(void) { spr_fini(); } - -int spr_init(unsigned int flags, qthread_f *regs) { - qassert(setenv("QT_MULTINODE", "1", 1), 0); - - // Validate flags - if (flags & ~(SPR_SPMD)) { return SPR_BADARGS; } - initialized_flags = flags; - - // Initialize Qthreads on this locale - qthread_initialize(); - - // Register actions - spr_register_actions(spr_remote_functions, 0, spr_internals_base); - if (regs) { spr_register_actions(regs, 0, spr_init_base); } - - if (0 == spr_locale_id()) { - // Create locale barrier - locale_barrier = qt_barrier_create(spr_num_locales(), REGION_BARRIER); - } - - spr_initialized = 1; - - atexit(call_fini); - if (flags & SPR_SPMD) { - qthread_multinode_multistart(); - } else { - qthread_multinode_run(); - } - return SPR_OK; -} - -int spr_fini(void) { - static int recursion_detection = 0; - - if (initialized_flags == -1) { return SPR_NOINIT; } - if (recursion_detection) { return SPR_OK; } - recursion_detection = 1; - - // Destroy locale barrier - if (NULL != locale_barrier) { qt_barrier_destroy(locale_barrier); } - - if (initialized_flags & SPR_SPMD) { qthread_multinode_multistop(); } - - recursion_detection = 0; - initialized_flags = -1; - return SPR_OK; -} - -int spr_register_actions(qthread_f *actions, size_t count, size_t base) { - int rc = SPR_OK; - - assert(actions); - - if (count == 0) { - qthread_f *cur_f = actions; - size_t tag = 0; - - while (*cur_f) { - qassert(qthread_multinode_register(tag + base, *cur_f), QTHREAD_SUCCESS); - ++tag; - cur_f = actions + tag; - } - } else { - for (int i = 0; i < count; i++) { - qassert(qthread_multinode_register(i + base, actions[i]), - QTHREAD_SUCCESS); - } - } - - return rc; -} - -int spr_unify(void) { - if (initialized_flags == -1) { return SPR_NOINIT; } - if (initialized_flags & ~(SPR_SPMD)) { return SPR_IGN; } - - if (0 != spr_locale_id()) { spr_fini(); } - return SPR_OK; -} - -int spr_num_locales(void) { - if (initialized_flags == -1) { return SPR_NOINIT; } - return qthread_multinode_size(); -} - -int spr_locale_id(void) { - if (initialized_flags == -1) { return SPR_NOINIT; } - return qthread_multinode_rank(); -} - -/****************************************************************************** - * Data Movement: One-sided Get * - ******************************************************************************/ - -/** - * Wait for the get operation to complete fully. - * - * This will cause the caller to block until acknowledgement is received - * that the entire memory segment is ready and available at the target locale. - * - * param hand The handle for the get operation. - * - * return int Returns SPR_OK on success. - */ -int spr_get_wait(spr_get_handle_t *const hand) { - int const rc = SPR_OK; - struct spr_get_handle_s *h = (struct spr_get_handle_s *)hand; - - qthread_readFF(&h->feb, &h->feb); - - return rc; -} - -/** - * Get the specified arbitrary-length remote memory segment. - * Note: this is a native implementation using SPR remote-spawning. - * - * This method blocks the calling task until the entire memory segment is - * available at the local destination. - * - * @param dest_addr The pointer to the local memory segment destination. - * - * @param src_loc The locale where the memory segment resides. - * - * @param src_addr The pointer to the memory segment on the specified locale. - * - * @param size The size of the memory segment. - * - * @return int Returns SPR_OK on success. - */ -int spr_get(void *restrict dest_addr, - int src_loc, - void const *restrict src_addr, - size_t size) { - int rc = SPR_OK; - - qthread_debug(MULTINODE_CALLS, - "[%d] begin spr_get(%d, %p, %p, %d)\n", - spr_locale_id(), - src_loc, - src_addr, - dest_addr, - size); - - struct spr_get_handle_s hand; - - spr_get_nb(dest_addr, src_loc, src_addr, size, (spr_get_handle_t *)&hand); - spr_get_wait((spr_get_handle_t *)&hand); - - qthread_debug(MULTINODE_CALLS, - "[%d] end spr_get(%d, %p, %p, %d)\n", - spr_locale_id(), - src_loc, - src_addr, - dest_addr, - size); - - return rc; -} - -/** - * Get the specified arbitrary-length remote memory segment. - * Note: this is a native implementation using SPR remote-spawning. - * - * This method returns after the data transfer was initiated; the handle - * must be used to synchronize on the completion of the transfer. - * - * @param dest_addr The pointer to the local memory segment destination. - * - * @param src_loc The locale where the memory segment resides. - * - * @param src_addr The pointer to the memory segment on the specified locale. - * - * @param size The size of the memory segment. - * - * @param hand The pointer to the handle that must be used later to - * synchronize on the completion of the operation. - * - * @return int Returns SPR_OK on success. - */ -int spr_get_nb(void *restrict dest_addr, - int src_loc, - void const *restrict src_addr, - size_t size, - spr_get_handle_t *restrict hand) { - int rc = SPR_OK; - int const here = spr_locale_id(); - struct spr_get_handle_s *h = (struct spr_get_handle_s *)hand; - - qthread_debug(MULTINODE_CALLS, - "[%d] begin spr_get_nb(%d, %p, %p, %d, %p)\n", - spr_locale_id(), - src_loc, - src_addr, - dest_addr, - size, - h); - assert(src_loc < qthread_multinode_size()); - assert(size > 0); - assert(dest_addr); - assert(src_addr); - assert(hand); - - qthread_empty(&h->feb); - rc = qthread_internal_net_driver_get( - dest_addr, src_loc, src_addr, size, &h->feb); - - qthread_debug(MULTINODE_CALLS, - "[%d] end spr_get_nb(%d, %p, %p, %d)\n", - spr_locale_id(), - src_loc, - src_addr, - dest_addr, - size); - - return rc; -} - -/****************************************************************************** - * Data Movement: One-sided Put * - ******************************************************************************/ - -/** - * Wait until all data is available at the destination. - * - * This will cause the caller to block until acknowledgement is received - * that the entire memory segment is ready and available at the target locale. - * - * param hand The handle for the get operation. - * - * return int Returns SPR_OK on success. - */ -int spr_put_wait(spr_put_handle_t *const hand) { - int const rc = SPR_OK; - struct spr_put_handle_s *h = (struct spr_put_handle_s *)hand; - - qthread_readFF(&h->feb, &h->feb); - - return rc; -} - -/** - * Put a copy of the arbitrary-length local memory segment at the specified - * location on the remote locale. - * - * This method blocks the calling task until the entire memory segment is - * available at the remote locale. - * - * @param dest_loc The locale where the remote memory segment resides. - * - * @param dest_addr The pointer to the memory segment on the specified locale. - * - * @param src_add The pointer to the local memory segment. - * - * @param size The size of the memory segment. - * - * @return int Returns SPR_OK on success. - */ -int spr_put(int dest_loc, - void *restrict dest_addr, - void const *restrict src_addr, - size_t size) { - int rc = SPR_OK; - - qthread_debug(MULTINODE_CALLS, - "[%d] begin spr_put(%d, %p, %p, %d)\n", - spr_locale_id(), - dest_loc, - dest_addr, - src_addr, - size); - - struct spr_put_handle_s hand; - - spr_put_nb(dest_loc, dest_addr, src_addr, size, (spr_put_handle_t *)&hand); - spr_put_wait((spr_put_handle_t *)&hand); - - qthread_debug(MULTINODE_CALLS, - "[%d] end spr_put(%d, %p, %p, %d)\n", - spr_locale_id(), - dest_loc, - dest_addr, - src_addr, - size); - - return rc; -} - -/** - * Put a copy of the arbitrary-length local memory segment at the specified - * location on the remote locale. - * - * This method returns after the data transfer was initiated; the handle - * must be used to synchronize on the completion of the transfer. - * - * @param dest_loc The locale where the remote memory segment resides. - * - * @param dest_addr The pointer to the memory segment on the specified locale. - * - * @param src_add The pointer to the local memory segment. - * - * @param size The size of the memory segment. - * - * @param hand The pointer to the handle that must be used later to - * synchronize on the completion of the operation. - * - * @return int Returns SPR_OK on success. - */ -int spr_put_nb(int dest_loc, - void *restrict dest_addr, - void const *restrict src_addr, - size_t size, - spr_put_handle_t *restrict hand) { - int rc = SPR_OK; - int const here = spr_locale_id(); - struct spr_put_handle_s *h = (struct spr_put_handle_s *)hand; - - qthread_debug(MULTINODE_CALLS, - "[%d] begin spr_put_nb(%d, %p, %p, %d)\n", - spr_locale_id(), - dest_loc, - dest_addr, - src_addr, - size); - assert(dest_loc < qthread_multinode_size()); - assert(size > 0); - assert(dest_addr); - assert(src_addr); - assert(hand); - - qthread_empty(&h->feb); - rc = qthread_internal_net_driver_put( - dest_loc, dest_addr, src_addr, size, &h->feb); - - qthread_debug(MULTINODE_CALLS, - "[%d] end spr_put_nb(%d, %p, %p, %d)\n", - spr_locale_id(), - dest_loc, - dest_addr, - src_addr, - size); - - return rc; -} - -/****************************************************************************** - * Locale-level Collectives: Barrier * - ******************************************************************************/ - -aligned_t spr_locale_barrier_op(void *arg_) { - aligned_t result = 0; - - qthread_debug( - MULTINODE_CALLS, "[%d] enter task-level barrier.\n", spr_locale_id()); - - assert(NULL != locale_barrier); // Must run on L0 - qt_barrier_enter(locale_barrier); - - qthread_debug( - MULTINODE_CALLS, "[%d] exit task-level barrier.\n", spr_locale_id()); - - return result; -} - -int spr_locale_barrier(void) { - int rc = SPR_OK; - - if (0 == spr_initialized) { - // Perform (thread-level) barrier using the network driver runtime - qthread_debug(MULTINODE_BEHAVIOR, - "[%d] enter network driver runtime barrier.\n", - spr_locale_id()); - - rc = qthread_internal_net_driver_barrier(); - - qthread_debug(MULTINODE_BEHAVIOR, - "[%d] exit network driver runtime barrier.\n", - spr_locale_id()); - } else { - // Perform task-level barrier - qthread_debug( - MULTINODE_BEHAVIOR, "[%d] enter task-level barrier.\n", spr_locale_id()); - - aligned_t ret; - qthread_fork_remote(spr_locale_barrier_op, - NULL, // arg - &ret, - 0, // rank - 0); // arg_len - qthread_readFF(&ret, &ret); - - qthread_debug( - MULTINODE_BEHAVIOR, "[%d] exit task-level barrier.\n", spr_locale_id()); - } - - return rc; -} - -/* vim:set expandtab: */ diff --git a/test/Makefile.am b/test/Makefile.am index 9f48bc6a0..6ad3c7890 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,11 +4,8 @@ # SUBDIRS = basics features stress utils -if COMPILE_MULTINODE -SUBDIRS += multinode -endif -DIST_SUBDIRS = $(SUBDIRS) multinode benchmarks +DIST_SUBDIRS = $(SUBDIRS) benchmarks basictests: $(MAKE) -C basics buildtests @@ -16,13 +13,10 @@ basictests: featuretests: $(MAKE) -C features buildtests -multinodetests: - $(MAKE) -C multinode buildtests - stresstests: $(MAKE) -C stress buildtests -tests: basictests featuretests stresstests multinodetests +tests: basictests featuretests stresstests buildtests: tests diff --git a/test/multinode/Makefile.am b/test/multinode/Makefile.am deleted file mode 100644 index 12bac7f0c..000000000 --- a/test/multinode/Makefile.am +++ /dev/null @@ -1,88 +0,0 @@ -# -*- Makefile -*- -# -# Copyright (c) 2012 Sandia Corporation -# - -.PHONY: buildall buildtests buildextra - -DIST_SUBDIRS = - -if COMPILE_MULTINODE - -general_multinode = \ - hello_world \ - spr_init \ - env_qthread_initialize \ - latency \ - broadcast \ - ring \ - spmd \ - put \ - get \ - qthread_fork_remote \ - in_edges - -if HAVE_LIBM -general_multinode += uts -endif - -multinode = \ - $(general_multinode) - -#EXTRA_PROGRAMS = $(multinode) - -TESTS = $(multinode) -check_PROGRAMS = $(TESTS) - -NP = 2 - -TESTS_ENVIRONMENT = yod.hydra -np $(NP) /usr/bin/env QT_STACK_SIZE=65536 - -EXTRA_DIST = - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/test/ -outputdir = $(top_builddir)/src -qthreadlib = $(outputdir)/libqthread.la -utils_rnglib = $(top_builddir)/test/utils/rng/librng.la - -LDADD = $(qthreadlib) - -buildall: $(multinode) -buildextra: $(multinode) -buildtests: $(multinode) - -$(qthreadlib): - $(MAKE) -C $(top_builddir)/src libqthread.la - -$(utils_rnglib): - $(MAKE) -C $(top_builddir)/test/utils/rng librng.la - -spr_init_SOURCES = spr_init.c - -env_qthread_initialize_SOURCES = env_qthread_initialize.c - -hello_world_SOURCES = hello_world.c - -latency_SOURCES = latency.c - -broadcast_SOURCES = broadcast.c - -ring_SOURCES = ring.c - -spmd_SOURCES = spmd.c - -put_SOURCES = put.c - -get_SOURCES = get.c - -qthread_fork_remote_SOURCES = qthread_fork_remote.c - -if HAVE_LIBM -uts_SOURCES = uts.c -uts_LDADD = $(LDADD) -lm $(utils_rnglib) -endif - -in_edges_SOURCES = in_edges.c -in_edges_LDADD = $(LDADD) $(utils_rnglib) - -endif diff --git a/test/multinode/broadcast.c b/test/multinode/broadcast.c deleted file mode 100644 index 37dbff871..000000000 --- a/test/multinode/broadcast.c +++ /dev/null @@ -1,89 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static size_t payload_size = 0; -static aligned_t *payload = NULL; -static aligned_t count = 1; -static aligned_t donecount = 0; -static int msgs = 1; - -static int size; -static int rank; - -static aligned_t pong(void *arg) { - iprintf("pong from %d\n", rank); - qthread_incr(&donecount, 1); - - return 0; -} - -static aligned_t ping(void *arg) { - iprintf("ping donecout %d msgs %d\n", donecount, msgs); - if (msgs - 1 == qthread_incr(&donecount, 1)) { - iprintf("\tping donecout %d msgs %d\n", donecount, msgs); - qthread_fork_remote(pong, NULL, NULL, 0, 0); - } - - return 0; -} - -int main(int argc, char *argv[]) { - qtimer_t timer; - qthread_f funcs[3] = {ping, pong, NULL}; - - CHECK_VERBOSE(); - - spr_init(SPR_SPMD, funcs); - - size = qthread_multinode_size(); - rank = qthread_multinode_rank(); - iprintf("rank %d size %d\n", rank, size); - - NUMARG(count, "COUNT"); - - if (size < 2) { - printf("Need more than one locale. Skipping test.\n"); - return 0; - } - - msgs = count / (size - 1); - - assert(spr_unify() == 0); - - NUMARG(payload_size, "SIZE"); - if (payload_size > 0) { - payload = calloc(payload_size, sizeof(aligned_t)); - assert(payload); - } - - timer = qtimer_create(); - - int next = 1; - qtimer_start(timer); - for (int i = 0; i < msgs * (size - 1); i++) { - iprintf("Spawned task %d to %d\n", i, next); - qthread_fork_remote(ping, payload, NULL, next, payload_size); - next = (next + 1 == size) ? 1 : next + 1; - } - iprintf("Waiting ...\n"); - while (donecount < size - 1) { qthread_yield(); } - iprintf("Done.\n"); - qtimer_stop(timer); - - iprintf("exec_time %f\n", qtimer_secs(timer)); - iprintf("msg_rate %f\n", (msgs * (size - 1)) / qtimer_secs(timer)); - - return 0; -} - diff --git a/test/multinode/env_qthread_initialize.c b/test/multinode/env_qthread_initialize.c deleted file mode 100644 index c3449955a..000000000 --- a/test/multinode/env_qthread_initialize.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "argparsing.h" -#include -#include -#include -#include -#include -#include - -int my_id, world_size; - -static aligned_t returner(void *arg) { - iprintf("(%03d) returner called, returning %ld\n", my_id, *((long *)arg)); - return *((long *)arg); -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - aligned_t tmp, ret = 0; - int retval; - long foobar = 1234567890; - - setenv("QT_MULTINODE", "yes", 1); - - qthread_initialize(); - - my_id = qthread_multinode_rank(); - world_size = qthread_multinode_size(); - - iprintf("(%03d) Rank %d of %d is alive\n", my_id, my_id, world_size); - - retval = qthread_multinode_register(2, returner); - if (retval != 0) { - fprintf(stderr, "(%03d) multinode_register returned %d\n", my_id, retval); - return 1; - } - - qthread_multinode_run(); - if (my_id != 0) return 2; - - int target = (world_size > 1) ? 1 : 0; - retval = qthread_fork_remote(returner, &foobar, &ret, target, sizeof(long)); - if (retval != 0) { - fprintf(stderr, "(%03d) fork_remote returned %d\n", my_id, retval); - return 3; - } - - retval = qthread_readFE(&tmp, &ret); - iprintf("(%03d) returner returned %ld\n", my_id, (long)tmp); - if (retval != 0) { - fprintf( - stderr, "(%03d) readFE returned %d (%d)\n", my_id, retval, (int)tmp); - return 4; - } - - qthread_finalize(); - - return (tmp == foobar) ? 0 : 5; -} - -/* vim:set expandtab */ diff --git a/test/multinode/get.c b/test/multinode/get.c deleted file mode 100644 index 216116c5e..000000000 --- a/test/multinode/get.c +++ /dev/null @@ -1,164 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - void *addr; - size_t size; -} getter_args_t; - -static aligned_t getter(void *args_) { - getter_args_t *args = (getter_args_t *)args_; - void *src_addr = args->addr; - size_t buf_size = args->size; - - int const here = spr_locale_id(); - int const there = (here == 0) ? spr_num_locales() - 1 : here - 1; - - iprintf("[%03d] remote buffer %p of size %lu on %03d\n", - here, - src_addr, - (unsigned long)buf_size, - there); - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - spr_get(buf, there, src_addr, buf_size); - - iprintf("[%03d] done getting\n", here); - - int success = 1; - - for (size_t i = 0; i < buf_size; i++) { - if ((char)(there + i) != buf[i]) { - success = 0; - break; - } - - if (i % 10 == 0) - iprintf( - "[%03d] reading local buffer (%p)[%d] = %d\n", here, buf, i, buf[i]); - } - - free(buf); - - return (0 == success); -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - size_t small_buf_size = 16; - size_t large_buf_size = 256; - size_t custom_buf_size = 0; - - NUMARG(custom_buf_size, "BUF_SIZE"); - - qthread_f actions[2] = {getter, NULL}; - assert(spr_init(SPR_SPMD, actions) == SPR_OK); - - int const num_locales = spr_num_locales(); - int const here = spr_locale_id(); - int const there = (here + 1 == num_locales) ? 0 : here + 1; - - int success = 1; - - /* Test small buffer size */ - if (0 == custom_buf_size) { - size_t buf_size = small_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] small local buffer %p\n", here, buf); - getter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(getter, &args, &ret, there, sizeof(getter_args_t)); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - /* Test large buffer size */ - if (success && (0 == custom_buf_size)) { - size_t buf_size = large_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] large local buffer %p\n", here, buf); - getter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(getter, &args, &ret, there, sizeof(getter_args_t)); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - /* Test custom buffer size */ - if (0 < custom_buf_size) { - size_t buf_size = custom_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] custom local buffer %p\n", here, buf); - getter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(getter, &args, &ret, there, sizeof(getter_args_t)); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - spr_fini(); - - if (success) { - iprintf("[%03d] SUCCESS\n", here); - return 0; - } else { - iprintf("[%03d] FAILURE\n", here); - return 1; - } -} - diff --git a/test/multinode/hello_world.c b/test/multinode/hello_world.c deleted file mode 100644 index 3848df4dc..000000000 --- a/test/multinode/hello_world.c +++ /dev/null @@ -1,37 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -static aligned_t say_hello(void *arg) { - int const rank = qthread_multinode_rank(); - - iprintf("Hello from locale %03d!\n", rank); - - return 0; -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - qthread_f funcs[2] = {say_hello, NULL}; - assert(spr_init(0, funcs) == SPR_OK); - - int const size = spr_num_locales(); - aligned_t rets[size]; - - for (int i = 0; i < size; i++) - qthread_fork_remote(say_hello, NULL, &rets[i], i, 0); - for (int i = 0; i < size; i++) qthread_readFF(NULL, &rets[i]); - - return 0; -} - diff --git a/test/multinode/in_edges.c b/test/multinode/in_edges.c deleted file mode 100644 index 999acef29..000000000 --- a/test/multinode/in_edges.c +++ /dev/null @@ -1,124 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" /* for _GNU_SOURCE */ -#endif - -#include "argparsing.h" -#include -#include /* for INT_MAX */ -#include /* for floor, log, sin */ -#include -#include -#include -#include -#include -#include -#include /* for time */ - -#define BRG_RNG // Select RNG -#include "../utils/rng/rng.h" - -#define NUM_VERTICES 4 - -typedef size_t vertex_id_t; - -typedef struct { - size_t lid; - vertex_id_t vid; -} vertex_t; - -static struct state_t rng_state; -static int here; -static size_t num_locales; -static vertex_id_t indices[NUM_VERTICES + 1]; -static vertex_id_t in_degrees[NUM_VERTICES]; - -size_t random_locale(void) { - int r = rng_nextrand(rng_state.state); - - return (size_t)(num_locales * ((double)r / (double)INT_MAX)); -} - -size_t random_vertex(void) { - int r = rng_nextrand(rng_state.state); - - return (size_t)(NUM_VERTICES * ((double)r / (double)INT_MAX)); -} - -aligned_t incr_in_degree(void *args_) { - vertex_id_t src = *((vertex_id_t *)args_); - - printf("[%03d] incrementing in-degree at %p\n", here, &(indices[src])); - qthread_incr(&(in_degrees[src]), 1); - - return 0; -} - -int main(int argc, char *argv[]) { - size_t num_edges; - aligned_t *rets; - vertex_t *edges; - - for (int i = 0; i < NUM_VERTICES; i++) { in_degrees[i] = 0; } - /* Initialize SPR in SPMD mode */ - qthread_f actions[2] = {incr_in_degree, NULL}; - spr_init(SPR_SPMD, actions); - here = spr_locale_id(); - num_locales = spr_num_locales(); - if (0 == here) { printf("Running with %d locales\n", num_locales); } - - rng_init(rng_state.state, time(NULL) * here); - - /* Create local portion of the graph */ - indices[0] = 0; - for (int i = 1; i < NUM_VERTICES + 1; i++) { - indices[i] = indices[i - 1] + random_vertex(); - } - for (int i = 0; i < NUM_VERTICES + 1; i++) { - printf("[%03d] indices[%d]: %lu\n", here, i, indices[i]); - } - - num_edges = indices[NUM_VERTICES]; - edges = malloc(num_edges * sizeof(vertex_t)); - for (int i = 0; i < num_edges; i++) { - edges[i].lid = random_locale(); - edges[i].vid = random_vertex(); - } - - for (int i = 0; i < num_edges; i++) { - printf( - "[%03d] edges[%d]: (%lu,%lu)\n", here, i, edges[i].lid, edges[i].vid); - } - - qt_global_barrier(); - - /* Fill in-degrees property map */ - rets = malloc(num_edges * sizeof(aligned_t)); - for (int i = 0; i < NUM_VERTICES; i++) { - for (int j = indices[i]; j < indices[i + 1]; j++) { - printf("[%03d] spawning incr of edge[%d] = (%lu,%lu)\n", - here, - j, - edges[j].lid, - edges[j].vid); - qthread_fork_remote(incr_in_degree, /* action */ - &(edges[j].vid), /* local vertex id */ - &rets[j], /* feb */ - edges[j].lid, /* locale */ - sizeof(vertex_id_t)); - } - } - for (int i = 0; i < num_edges; i++) { qthread_readFF(&rets[i], &rets[i]); } - - /* Print in-degrees */ - for (int i = 0; i < NUM_VERTICES; i++) { - printf("[%03d] in-degree(%lu) = %lu\n", here, i, in_degrees[i]); - } - - /* Free up allocated resources */ - free(rets); - free(edges); - - return 0; -} - -/* vim:set expandtab */ diff --git a/test/multinode/latency.c b/test/multinode/latency.c deleted file mode 100644 index 9aa1ed050..000000000 --- a/test/multinode/latency.c +++ /dev/null @@ -1,125 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static size_t payload_size = 0; -static aligned_t *payload = NULL; -static size_t count = 1; -static qtimer_t timer; - -static int size; -static int rank; -static int next; -static aligned_t done; - -static aligned_t intra_ping(void *arg) { - int shep = (int)qthread_shep(); - int next = (shep + 1 == size) ? 0 : shep + 1; - - iprintf("Ping shep %03d\n", shep); - - if (shep != 0) { - qthread_fork_copyargs_to(intra_ping, payload, payload_size, NULL, next); - } else if (count != 0) { - count -= 1; - qthread_fork_copyargs_to(intra_ping, payload, payload_size, NULL, 1); - } else { - qtimer_stop(timer); - qthread_writeF_const(&done, 1); - } - - return 0; -} - -static aligned_t ping(void *arg) { - iprintf("Ping %03d\n", rank); - - if (rank != 0) { - qthread_fork_remote(ping, payload, NULL, next, payload_size); - } else if (count != 0) { - count -= 1; - qthread_fork_remote(ping, payload, NULL, 1, payload_size); - } else { - qtimer_stop(timer); - qthread_writeF_const(&done, 1); - } - - return 0; -} - -static aligned_t intra_node_test(void *arg) { - qthread_empty(&done); - qtimer_start(timer); - qthread_fork_copyargs_to(intra_ping, payload, payload_size, NULL, 1); - qthread_readFF(NULL, &done); - - return 0; -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - qthread_f funcs[2] = {ping, NULL}; - assert(spr_init(SPR_SPMD, funcs) == SPR_OK); - - size = spr_num_locales(); - rank = spr_locale_id(); - next = (rank + 1 == size) ? 0 : rank + 1; - iprintf("rank %d next %d size %d\n", rank, next, size); - - if (size < 2) { - printf("Need more than one locale. Skipping test.\n"); - return 0; - } - - assert(spr_unify() == 0); - - NUMARG(count, "COUNT"); - size_t total_count = count * size; - count--; - - NUMARG(payload_size, "SIZE"); - if (payload_size > 0) { - payload = calloc(payload_size, sizeof(aligned_t)); - assert(payload); - } - - timer = qtimer_create(); - - qthread_empty(&done); - qtimer_start(timer); - qthread_fork_remote(ping, payload, NULL, 1, payload_size); - qthread_readFF(NULL, &done); - - double total_time = qtimer_secs(timer); - iprintf("tot-time %f\n", total_time); - iprintf("avg-time %f\n", total_time / total_count); - - if (qthread_num_shepherds() > 1) { - // Run intra-node test - count = total_count / size; - int size = (int)qthread_num_shepherds(); - total_count = count * size; - - aligned_t ret; - qthread_fork_to(intra_node_test, NULL, &ret, 0); - qthread_readFF(NULL, &ret); - - total_time = qtimer_secs(timer); - iprintf("intra-tot-time %f\n", total_time); - iprintf("intra-avg-time %f\n", total_time / total_count); - } - - return 0; -} - diff --git a/test/multinode/put.c b/test/multinode/put.c deleted file mode 100644 index 6993cf036..000000000 --- a/test/multinode/put.c +++ /dev/null @@ -1,173 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - void *addr; - size_t size; -} putter_args_t; - -static aligned_t putter(void *args_) { - putter_args_t *args = (putter_args_t *)args_; - void *dest_addr = args->addr; - size_t buf_size = args->size; - - int const here = spr_locale_id(); - int const there = (here == 0) ? spr_num_locales() - 1 : here - 1; - - iprintf("[%03d] remote buffer %p of size %lu on %03d\n", - here, - dest_addr, - (unsigned long)buf_size, - there); - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - spr_put(there, dest_addr, buf, buf_size); - - iprintf("[%03d] done putting\n", here); - - free(buf); - - return 0; -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - size_t small_buf_size = 16; - size_t large_buf_size = 256; - size_t custom_buf_size = 0; - - NUMARG(custom_buf_size, "BUF_SIZE"); - - qthread_f actions[2] = {putter, NULL}; - assert(spr_init(SPR_SPMD, actions) == SPR_OK); - - int const num_locales = spr_num_locales(); - int const here = spr_locale_id(); - int const there = (here + 1 == num_locales) ? 0 : here + 1; - - int success = 1; - - /* Test small buffer size */ - if (0 == custom_buf_size) { - size_t buf_size = small_buf_size; - - char *buf = calloc(buf_size, sizeof(char)); - assert(buf); - - iprintf("[%03d] small local buffer %p\n", here, buf); - putter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(putter, &args, &ret, there, sizeof(putter_args_t)); - qthread_readFF(NULL, &ret); - - for (size_t i = 0; i < small_buf_size; i++) { - if ((char)(there + i) != buf[i]) { - success = 0; - break; - } - - if (i % 10 == 0) - iprintf("[%03d] reading small local buffer (%p)[%d] = %d\n", - here, - buf, - i, - buf[i]); - } - - free(buf); - } - - /* Test large buffer size */ - if (success && (0 == custom_buf_size)) { - size_t buf_size = large_buf_size; - - char *buf = calloc(buf_size, sizeof(char)); - assert(buf); - - iprintf("[%03d] large local buffer %p\n", here, buf); - putter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(putter, &args, &ret, there, sizeof(putter_args_t)); - qthread_readFF(NULL, &ret); - - for (size_t i = 0; i < large_buf_size; i++) { - if ((char)(there + i) != buf[i]) { - success = 0; - break; - } - - if (i % 100 == 0) - iprintf("[%03d] large reading local buffer (%p)[%d] = %d\n", - here, - buf, - i, - buf[i]); - } - - free(buf); - } - - /* Test custom buffer size */ - if (success && (0 < custom_buf_size)) { - size_t buf_size = custom_buf_size; - - char *buf = calloc(buf_size, sizeof(char)); - assert(buf); - - iprintf("[%03d] custom local buffer %p\n", here, buf); - putter_args_t args = {buf, buf_size}; - - aligned_t ret; - qthread_fork_remote(putter, &args, &ret, there, sizeof(putter_args_t)); - qthread_readFF(NULL, &ret); - - for (size_t i = 0; i < custom_buf_size; i++) { - if ((char)(there + i) != buf[i]) { - success = 0; - break; - } - - if (i % 10 == 0) - iprintf("[%03d] custom reading local buffer (%p)[%d] = %d\n", - here, - buf, - i, - buf[i]); - } - - free(buf); - } - - spr_fini(); - - if (success) { - iprintf("[%03d] SUCCESS\n", here); - return 0; - } else { - iprintf("[%03d] FAILURE\n", here); - return 1; - } -} - diff --git a/test/multinode/qthread_fork_remote.c b/test/multinode/qthread_fork_remote.c deleted file mode 100644 index 4c2aaeebd..000000000 --- a/test/multinode/qthread_fork_remote.c +++ /dev/null @@ -1,140 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -static size_t small_buf_size = 16; -static size_t large_buf_size = 256; -static size_t custom_buf_size = 0; -static size_t buf_size = 0; - -static aligned_t spawnee(void *args_) { - char *buf = (char *)args_; - - int const here = spr_locale_id(); - int const there = (here == 0) ? spr_num_locales() - 1 : here - 1; - - int success = 1; - - for (size_t i = 0; i < buf_size; i++) { - if ((char)(there + i) != buf[i]) { - success = 0; - break; - } - - if (i % 10 == 0) - iprintf( - "[%03d] reading local buffer (%p)[%d] = %d\n", here, buf, i, buf[i]); - } - - return (0 == success); -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - NUMARG(custom_buf_size, "BUF_SIZE"); - - qthread_f actions[2] = {spawnee, NULL}; - assert(spr_init(SPR_SPMD, actions) == SPR_OK); - - int const num_locales = spr_num_locales(); - int const here = spr_locale_id(); - int const there = (here + 1 == num_locales) ? 0 : here + 1; - - int success = 1; - - /* Test small buffer size */ - if (0 == custom_buf_size) { - buf_size = small_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] small local buffer %p\n", here, buf); - - aligned_t ret; - qthread_fork_remote(spawnee, buf, &ret, there, buf_size); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - /* Test large buffer size */ - if (success && (0 == custom_buf_size)) { - buf_size = large_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] large local buffer %p\n", here, buf); - - aligned_t ret; - qthread_fork_remote(spawnee, buf, &ret, there, buf_size); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - /* Test custom buffer size */ - if (0 != custom_buf_size) { - buf_size = custom_buf_size; - - char *buf = malloc(buf_size * sizeof(char)); - assert(buf); - - for (size_t i = 0; i < buf_size; i++) { - buf[i] = (char)(here + i); - - if (i % 10 == 0) - iprintf("[%03d] filling local buffer[%d] = %d\n", here, i, buf[i]); - } - - iprintf("[%03d] custom local buffer %p\n", here, buf); - - aligned_t ret; - qthread_fork_remote(spawnee, buf, &ret, there, buf_size); - qthread_readFF(&ret, &ret); - - success = (0 == ret); - - free(buf); - } - - spr_fini(); - - if (success) { - iprintf("[%03d] SUCCESS\n", here); - return 0; - } else { - iprintf("[%03d] FAILURE\n", here); - return 1; - } -} - diff --git a/test/multinode/ring.c b/test/multinode/ring.c deleted file mode 100644 index 90e4a4e9a..000000000 --- a/test/multinode/ring.c +++ /dev/null @@ -1,49 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -static aligned_t done; - -static aligned_t ping(void *arg) { - int const size = spr_num_locales(); - int const rank = spr_locale_id(); - - iprintf("Ping %03d\n", rank); - - if (rank == 0) { - qthread_writeF_const(&done, 1); - } else { - int const next = (rank + 1) % size; - qthread_fork_remote(ping, NULL, NULL, next, 0); - } - - return 0; -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - qthread_f funcs[2] = {ping, NULL}; - assert(spr_init(0, funcs) == SPR_OK); - - int const size = spr_num_locales(); - int const rank = spr_locale_id(); - - int const next = (rank + 1) % size; - - qthread_empty(&done); - qthread_fork_remote(ping, NULL, NULL, next, 0); - qthread_readFF(NULL, &done); - - return 0; -} - diff --git a/test/multinode/spmd.c b/test/multinode/spmd.c deleted file mode 100644 index 247866a03..000000000 --- a/test/multinode/spmd.c +++ /dev/null @@ -1,41 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -static aligned_t say_hello(void *arg) { - int const rank = qthread_multinode_rank(); - - iprintf("Hello from locale %03d!\n", rank); - - return 0; -} - -int main(int argc, char *argv[]) { - CHECK_VERBOSE(); - - qthread_f funcs[2] = {say_hello, NULL}; - assert(spr_init(SPR_SPMD, funcs) == SPR_OK); - - int const here = spr_locale_id(); - int const there = (here + 1 == spr_num_locales()) ? 0 : here + 1; - - iprintf("[%03d] Single Program Multiple Hello!\n", here); - - aligned_t ret; - qthread_fork_remote(say_hello, NULL, &ret, there, 0); - qthread_readFF(NULL, &ret); - - spr_fini(); - - return 0; -} - diff --git a/test/multinode/spr_init.c b/test/multinode/spr_init.c deleted file mode 100644 index 04a79966d..000000000 --- a/test/multinode/spr_init.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "argparsing.h" -#include -#include -#include -#include -#include -#include -#include - -int my_id, world_size; - -static aligned_t returner(void *arg) { - iprintf("(%03d) returner called, returning %ld\n", my_id, *((long *)arg)); - return *((long *)arg); -} - -int main(int argc, char *argv[]) { - aligned_t tmp, ret = 0; - int retval; - long foobar = 1234567890; - qthread_f funcs[2] = {returner, NULL}; - - CHECK_VERBOSE(); - - retval = spr_init(SPR_SPMD, funcs); - if (retval != SPR_OK) { - fprintf(stderr, "(%03d) spr_init returned %d\n", 0, retval); - return -1; - } - - my_id = spr_locale_id(); - world_size = spr_num_locales(); - - iprintf("(%03d) Rank %d of %d is alive\n", my_id, my_id, world_size); - - spr_unify(); - - if (my_id != 0) { return -2; } - - int target = (world_size > 1) ? 1 : 0; - retval = qthread_fork_remote(returner, &foobar, &ret, target, sizeof(long)); - if (retval != 0) { - fprintf(stderr, "(%03d) fork_remote returned %d\n", my_id, retval); - return -3; - } - - retval = qthread_readFE(&tmp, &ret); - iprintf("(%03d) returner returned %ld\n", my_id, (long)tmp); - if (retval != 0) { - fprintf( - stderr, "(%03d) readFE returned %d (%d)\n", my_id, retval, (int)tmp); - return -4; - } - - spr_fini(); - - return (tmp == foobar) ? 0 : 5; -} - -/* vim:set expandtab */ diff --git a/test/multinode/uts.c b/test/multinode/uts.c deleted file mode 100644 index 8630ff48b..000000000 --- a/test/multinode/uts.c +++ /dev/null @@ -1,415 +0,0 @@ -/****************************************************** - * Unbalanced Tree Search v2.1 * - * Based on the implementation available at * - * http://sourceforge.net/projects/uts-benchmark * - ******************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" /* for _GNU_SOURCE */ -#endif - -#include "argparsing.h" -#include -#include /* for INT_MAX */ -#include /* for floor, log, sin */ -#include -#include -#include -#include -#include -#include - -#define BRG_RNG // Select RNG -#include "../utils/rng/rng.h" - -#define COLLECT_STATS 1 - -#define PRINT_STATS 1 - -#define MAXNUMCHILDREN 100 - -static int num_locales; -static int here; -static int talk_to_self = 0; -static double perc_remote = 0.0; - -#ifdef COLLECT_STATS -static aligned_t *comm_bins = NULL; -static aligned_t num_messages = 0; - -static aligned_t pong_comm(void *args_) { - aligned_t *remote_comm_bins = (aligned_t *)args_; - - aligned_t num_out = 0; - - iprintf("%d ", here); - for (int i = 0; i < num_locales; i++) { - num_out += remote_comm_bins[i]; - iprintf("%4lu ", (unsigned long)remote_comm_bins[i]); - } - iprintf("\n"); - - return num_out; -} - -static aligned_t ping_comm(void *args_) { return pong_comm(comm_bins); } - -#endif /* ifdef COLLECT_STATS */ - -typedef enum { BIN = 0, GEO, HYBRID, BALANCED } tree_t; - -static char *type_names[] = {"Binomial", "Geometric", "Hybrid", "Balanced"}; - -typedef enum { LINEAR = 0, EXPDEC, CYCLIC, FIXED } shape_t; - -static char *shape_names[] = {"Linear decrease", - "Exponential decrease", - "Cyclic", - "Fixed branching factor"}; - -typedef struct { - int height; // Depth of node in the tree - struct state_t state; // Local RNG state - int num_children; -} node_t; - -// Default values -static tree_t tree_type = GEO; -static double bf_0 = 4.0; -static int root_seed = 0; -static int num_samples = 1; -static int tree_depth = 6; -static shape_t shape_fn = LINEAR; -static int non_leaf_bf = 4; -static double non_leaf_prob = 15.0 / 64.0; -static double shift_depth = 0.5; - -// Tree metrics -static uint64_t tree_height = 0; -static uint64_t num_leaves = 0; - -static double normalize(int n) { - if (n < 0) { iprintf("*** toProb: rand n = %d out of range\n", n); } - - return ((n < 0) ? 0.0 : ((double)n) / (double)INT_MAX); -} - -static int calc_num_children_bin(node_t *parent) { - int v = rng_rand(parent->state.state); - double d = normalize(v); - - return (d < non_leaf_prob) ? non_leaf_bf : 0; -} - -static int calc_num_children(node_t *parent) { - int num_children = 0; - - if (parent->height == 0) { - num_children = (int)floor(bf_0); - } else { - num_children = calc_num_children_bin(parent); - } - - if (parent->height == 0) { - int root_bf = (int)ceil(bf_0); - if (num_children > root_bf) { - iprintf("*** Number of children truncated from %d to %d\n", - num_children, - root_bf); - num_children = root_bf; - } - } else { - if (num_children > MAXNUMCHILDREN) { - iprintf("*** Number of children truncated from %d to %d\n", - num_children, - MAXNUMCHILDREN); - num_children = MAXNUMCHILDREN; - } - } - - return num_children; -} - -#define BIG_STACKS - -// Notes: -// - Each task receives distinct copy of parent -// - Copy of child is shallow, be careful with `state` member -static aligned_t visit(void *args_) { - node_t *parent = (node_t *)args_; - int parent_height = parent->height; - int num_children = parent->num_children; - uint64_t num_descendants = 1; - node_t child; - -#ifdef BIG_STACKS - aligned_t rets[num_children]; -#else - aligned_t *rets; - - if (num_children > 0) { rets = malloc(sizeof(aligned_t) * num_children); } -#endif - - // Spawn children, if any - for (int i = 0; i < num_children; i++) { rets[i] = 0; } - child.height = parent_height + 1; - for (int i = 0; i < num_children; i++) { - for (int j = 0; j < num_samples; j++) { - rng_spawn(parent->state.state, child.state.state, i); - } - - child.num_children = calc_num_children(&child); - - int const r = rng_rand(child.state.state); - - int target = (r <= 0x7fffffff * perc_remote) ? r % num_locales : here; - - if (talk_to_self || (target != here)) { - // Spawn `visit` task to a random locale - iprintf("%03d : spawning visit on locale %03d\n", here, target); -#ifdef COLLECT_STATS - qthread_incr(&(comm_bins[target]), 1); -#endif - - qthread_fork_remote(visit, &child, &rets[i], target, sizeof(node_t)); - } else { - qthread_fork_copyargs(visit, &child, sizeof(node_t), &rets[i]); - } - } - - // Wait for children to finish up, accumulate descendants counts - for (int i = 0; i < num_children; i++) { - qthread_readFF(NULL, &rets[i]); - num_descendants += rets[i]; - } - -#ifndef BIG_STACKS - if (num_children > 0) { free(rets); } -#endif - return num_descendants; -} - -#ifdef PRINT_STATS -static void print_stats(void) { - iprintf( - "tree-type %d\ntree-type-name %s\n", tree_type, type_names[tree_type]); - iprintf("root-bf %.1f\nroot-seed %d\n", bf_0, root_seed); - - if ((tree_type == GEO) || (tree_type == HYBRID)) { - iprintf("gen_mx %d\nshape-fn %d\nshape-fn-name %s\n", - tree_depth, - shape_fn, - shape_names[shape_fn]); - } - - if ((tree_type == BIN) || (tree_type == HYBRID)) { - double q = non_leaf_prob; - int m = non_leaf_bf; - double es = (1.0 / (1.0 - q * m)); - iprintf("q %f\nm %d\nE(n) %f\nE(s) %.2f\n", q, m, q * m, es); - } - - if (tree_type == HYBRID) { - iprintf("root-to-depth %d\n", (int)ceil(shift_depth * tree_depth)); - } - - if (tree_type == BALANCED) { - iprintf("gen_mx %d\n", tree_depth); - iprintf( - "expected-num-nodes %llu\nexpected-num-leaves %llu\n", - (unsigned long long)((pow(bf_0, tree_depth + 1) - 1.0) / (bf_0 - 1.0)), - (unsigned long long)pow(bf_0, tree_depth)); - } - - iprintf("compute-granularity %d\n", num_samples); - iprintf("num-sheps %d\n", qthread_num_shepherds()); - iprintf("num-workers %d\n", qthread_num_workers()); - - iprintf("\n"); - - fflush(stdout); -} - -#else /* ifdef PRINT_STATS */ -static void print_banner(void) { - iprintf("UTS - Unbalanced Tree Search 2.1 (C/Qthreads)\n"); - iprintf("Tree type:%3d (%s)\n", tree_type, type_names[tree_type]); - iprintf("Tree shape parameters:\n"); - iprintf( - " root branching factor b_0 = %.1f, root seed = %d\n", bf_0, root_seed); - - if ((tree_type == GEO) || (tree_type == HYBRID)) { - iprintf(" GEO parameters: gen_mx = %d, shape function = %d (%s)\n", - tree_depth, - shape_fn, - shape_names[shape_fn]); - } - - if ((tree_type == BIN) || (tree_type == HYBRID)) { - double q = non_leaf_prob; - int m = non_leaf_bf; - double es = (1.0 / (1.0 - q * m)); - iprintf(" BIN parameters: q = %f, m = %d, E(n) = %f, E(s) = %.2f\n", - q, - m, - q * m, - es); - } - - if (tree_type == HYBRID) { - iprintf(" HYBRID: GEO from root to depth %d, then BIN\n", - (int)ceil(shift_depth * tree_depth)); - } - - if (tree_type == BALANCED) { - iprintf(" BALANCED parameters: gen_mx = %d\n", tree_depth); - iprintf( - " Expected size: %llu nodes, %llu leaves\n", - (unsigned long long)((pow(bf_0, tree_depth + 1) - 1.0) / (bf_0 - 1.0)), - (unsigned long long)pow(bf_0, tree_depth)); - } - - iprintf("Random number generator: "); - iprintf("SHA-1 (state size = %ldB)\n", sizeof(struct state_t)); - iprintf("Compute granularity: %d\n", num_samples); - iprintf("Execution strategy:\n"); - iprintf(" Shepherds: %d\n", qthread_num_shepherds()); - iprintf(" Workers: %d\n", qthread_num_workers()); - - iprintf("\n"); - - fflush(stdout); -} - -#endif /* ifdef PRINT_STATS */ - -int main(int argc, char *argv[]) { - uint64_t total_num_nodes = 0; - qtimer_t timer; - double total_time = 0.0; - - CHECK_VERBOSE(); - - { - unsigned int tmp = (unsigned int)tree_type; - NUMARG(tmp, "UTS_TREE_TYPE"); - if (tmp <= BALANCED) { - tree_type = (tree_t)tmp; - } else { - fprintf(stderr, "invalid tree type\n"); - return EXIT_FAILURE; - } - tmp = (unsigned int)shape_fn; - NUMARG(tmp, "UTS_SHAPE_FN"); - if (tmp <= FIXED) { - shape_fn = (shape_t)tmp; - } else { - fprintf(stderr, "invalid shape function\n"); - return EXIT_FAILURE; - } - } - DBLARG(bf_0, "UTS_BF_0"); - NUMARG(root_seed, "UTS_ROOT_SEED"); - NUMARG(tree_depth, "UTS_TREE_DEPTH"); - DBLARG(non_leaf_prob, "UTS_NON_LEAF_PROB"); - NUMARG(non_leaf_bf, "UTS_NON_LEAF_NUM"); - NUMARG(shift_depth, "UTS_SHIFT_DEPTH"); - NUMARG(num_samples, "UTS_NUM_SAMPLES"); - NUMARG(talk_to_self, "ALL_COMM"); - DBLARG(perc_remote, "PERC_REMOTE"); - - // Tell Qthreads to initialize multinode support - setenv("QT_MULTINODE", "yes", 1); - - qthread_f functions[4] = {visit, ping_comm, pong_comm, NULL}; - spr_init(SPR_SPMD, functions); - - // Set `num_locales` on each locale - num_locales = spr_num_locales(); - here = spr_locale_id(); - -#ifdef COLLECT_STATS - comm_bins = calloc(num_locales, sizeof(aligned_t)); -#endif - - // Collapse flow of control down to a single one, Chapel-style - spr_unify(); - - assert(here == 0); - if (here != 0) { - fprintf(stderr, "Unification failed!!!!!!!!!!!!!!!!!!\n"); - abort(); - } - -#ifdef PRINT_STATS - print_stats(); -#else - print_banner(); -#endif - - timer = qtimer_create(); - qtimer_start(timer); - - node_t root; - root.height = 0; - rng_init(root.state.state, root_seed); - root.num_children = calc_num_children(&root); - - aligned_t ret = 0; - qthread_fork(visit, &root, &ret); - qthread_readFF(&total_num_nodes, &ret); - - qtimer_stop(timer); - - total_time = qtimer_secs(timer); - - qtimer_destroy(timer); - -#ifdef COLLECT_STATS - num_messages = pong_comm(comm_bins); - for (int i = 1; i < num_locales; i++) { - aligned_t ret; - qthread_fork_remote(ping_comm, &i, &ret, i, sizeof(int)); - - aligned_t tmp; - qthread_readFF(&tmp, &ret); - num_messages += tmp; - } - - free(comm_bins); -#endif /* ifdef COLLECT_STATS */ - -#ifdef PRINT_STATS - iprintf("num-messages %lu\nperc-remote %f\ntree-size %lu\ntree-depth " - "%d\nnum-leaves %llu\nperc-leaves %.2f\n", - (unsigned long)num_messages, - num_messages / (double)total_num_nodes, - (unsigned long)total_num_nodes, - (int)tree_height, - (unsigned long long)num_leaves, - num_leaves / (float)total_num_nodes * 100.0); - iprintf("exec-time %.3f\ntotal-perf %.0f\npu-perf %.0f\n\n", - total_time, - total_num_nodes / total_time, - total_num_nodes / total_time / qthread_num_workers()); -#else /* ifdef PRINT_STATS */ - iprintf("Num messages = %lu, Tree size = %lu, tree depth = %d, num leaves = " - "%llu (%.2f%%)\n", - (unsigned long)num_messages, - (unsigned long)total_num_nodes, - (int)tree_height, - (unsigned long long)num_leaves, - num_leaves / (float)total_num_nodes * 100.0); - iprintf("Wallclock time = %.3f sec, performance = %.0f " - "nodes/sec (%.0f nodes/sec per PE)\n\n", - total_time, - total_num_nodes / total_time, - total_num_nodes / total_time / qthread_num_workers()); -#endif /* ifdef PRINT_STATS */ - - spr_fini(); - - return 0; -} - -/* vim:set expandtab */ From e5c2b2d9b235fa6d245888400ab135c44c736148 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 13:37:14 -0700 Subject: [PATCH 14/38] Remove some unused configure files. --- config/ompi_check_withdir.m4 | 36 ------------------- config/orte_check_pmi.m4 | 69 ------------------------------------ 2 files changed, 105 deletions(-) delete mode 100644 config/ompi_check_withdir.m4 delete mode 100644 config/orte_check_pmi.m4 diff --git a/config/ompi_check_withdir.m4 b/config/ompi_check_withdir.m4 deleted file mode 100644 index 3e6a805a3..000000000 --- a/config/ompi_check_withdir.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl -*- shell-script -*- -dnl -dnl Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana -dnl University Research and Technology -dnl Corporation. All rights reserved. -dnl Copyright (c) 2006 Los Alamos National Security, LLC. All rights -dnl reserved. -dnl Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. -dnl $COPYRIGHT$ -dnl -dnl Additional copyrights may follow -dnl -dnl $HEADER$ -dnl - -# OMPI_CHECK_WITHDIR(with_option_name, dir_value, file_in_dir) -# ---------------------------------------------------- -AC_DEFUN([OMPI_CHECK_WITHDIR],[ - AC_MSG_CHECKING([--with-$1 value]) - AS_IF([test "$2" = "yes" -o "$2" = "no" -o "x$2" = "x"], - [AC_MSG_RESULT([simple ok (unspecified)])], - [AS_IF([test ! -d "$2"], - [AC_MSG_RESULT([not found]) - AC_MSG_WARN([Directory $2 not found]) - AC_MSG_ERROR([Cannot continue])], - [AS_IF([test "x`ls $2/$3 2> /dev/null`" = "x"], - [AC_MSG_RESULT([not found]) - AC_MSG_WARN([Expected file $2/$3 not found]) - AC_MSG_ERROR([Cannot continue])], - [AC_MSG_RESULT([sanity check ok ($2)])] - ) - ] - ) - ] - ) -])dnl diff --git a/config/orte_check_pmi.m4 b/config/orte_check_pmi.m4 deleted file mode 100644 index 9312d0a22..000000000 --- a/config/orte_check_pmi.m4 +++ /dev/null @@ -1,69 +0,0 @@ -# -*- shell-script -*- -# -# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana -# University Research and Technology -# Corporation. All rights reserved. -# Copyright (c) 2004-2005 The University of Tennessee and The University -# of Tennessee Research Foundation. All rights -# reserved. -# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, -# University of Stuttgart. All rights reserved. -# Copyright (c) 2004-2005 The Regents of the University of California. -# All rights reserved. -# Copyright (c) 2009-2011 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2011 Los Alamos National Security, LLC. All rights -# reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -# ORTE_CHECK_PMI(prefix, [action-if-found], [action-if-not-found]) -# -------------------------------------------------------- -AC_DEFUN([ORTE_CHECK_PMI],[ - AC_ARG_WITH([pmi], - [AC_HELP_STRING([--with-pmi@<:@=DIR@:>@], - [Build PMI support, if found])]) - AC_ARG_WITH([pmi-libdir], - [AC_HELP_STRING([--with-pmi-libdir=DIR], - [Search for PMI libraries in DIR])]) - OMPI_CHECK_WITHDIR([pmi-libdir], [$with_pmi_libdir], [libpmi.*]) - - AS_IF([test "$with_pmi" != "no"], - [AS_IF([test ! -z "$with_pmi" -a "$with_pmi" != "yes"], - [ompi_check_pmi_dir="$with_pmi"]) - AS_IF([test ! -z "$with_pmi_libdir" -a "$with_pmi_libdir" != "yes"], - [ompi_check_pmi_libdir="$with_pmi_libdir"]) - - OMPI_CHECK_PACKAGE([$1], - [pmi.h], - [pmi], - [PMI_Init], - [], - [$ompi_check_pmi_dir], - [$ompi_check_pmi_libdir], - [ompi_check_pmi_happy="yes"], - [ompi_check_pmi_happy="no"]) - AS_IF([test "$ompi_check_pmi_happy" = "no"], - [OMPI_CHECK_PACKAGE([$1], - [slurm/pmi.h], - [pmi], - [PMI_Init], - [], - [$ompi_check_pmi_dir], - [$ompi_check_pmi_libdir], - [AC_DEFINE([PMI_SLURM], [1], - [Defined to 1 if PMI implementation is SLURM.]) - ompi_check_pmi_happy="yes"], - [ompi_check_pmi_happy="no"])])], - [ompi_check_pmi_happy="no"]) - - AS_IF([test "$ompi_check_pmi_happy" = "yes"], - [$2], - [AS_IF([test ! -z "$with_pmi" -a "$with_pmi" != "no"], - [AC_MSG_ERROR([PMI support requested but not found. Abort -ing])]) - $3]) -]) From a76d633c9a3187eef00b64cde06cc9ed6a2ea071 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 14:00:12 -0700 Subject: [PATCH 15/38] Remove unused config file checking whether __builtin_expect is available. --- config/qthread_builtin_expect.m4 | 18 ------------------ configure.ac | 1 - 2 files changed, 19 deletions(-) delete mode 100644 config/qthread_builtin_expect.m4 diff --git a/config/qthread_builtin_expect.m4 b/config/qthread_builtin_expect.m4 deleted file mode 100644 index 18990fda3..000000000 --- a/config/qthread_builtin_expect.m4 +++ /dev/null @@ -1,18 +0,0 @@ -AC_DEFUN([QTHREAD_BUILTIN_EXPECT], -[AC_CACHE_CHECK([for __builtin_expect], - [qthread_cv_builtin_expect], - [SAVE_CFLAGS="$CFLAGS" - CFLAGS="-Werror $CFLAGS" - AC_LINK_IFELSE([AC_LANG_SOURCE([[ -int main(void) -{ - int i=1; - if (__builtin_expect(i==0, 0)) { return 0; } - return 1; -}]])], - [qthread_cv_builtin_expect="yes"], - [qthread_cv_builtin_expect="no"]) - CFLAGS="$SAVE_CFLAGS"]) - AS_IF([test "x$qthread_cv_builtin_expect" = "xyes"], - [AC_DEFINE([QTHREAD_EXPECT_OKAY],[1],[If __builtin_expect can be used])]) -]) diff --git a/configure.ac b/configure.ac index 2326ae7db..272aaaa87 100644 --- a/configure.ac +++ b/configure.ac @@ -613,7 +613,6 @@ esac # Figure out whether the compiler has builtin atomic operations AS_IF([test "x$enable_hardware_atomics" != xno], [QTHREAD_CHECK_ATOMICS($sizeof_aligned_t)]) -QTHREAD_BUILTIN_EXPECT QTHREAD_BUILTIN_TRAP QTHREAD_VAMACROS QTHREAD_CHECK_BITFIELDS From 809b6010609d0abb5c24fbc151366fc4cddb201d Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:11:21 -0600 Subject: [PATCH 16/38] Fix typo. --- src/qthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qthread.c b/src/qthread.c index 5b0f4d0f0..56107be58 100644 --- a/src/qthread.c +++ b/src/qthread.c @@ -538,7 +538,7 @@ static void *qthread_master(void *arg) { QTHREAD_REAL_MCCOY)); assert(t->f != NULL || - atoic_load_explicit(&t->flags, memory_order_relaxed) & + atomic_load_explicit(&t->flags, memory_order_relaxed) & QTHREAD_REAL_MCCOY); if (t->rdata == NULL) { alloc_rdata(me, t); From 133a548e45bac16629638d8afe35032ef7592488 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:14:33 -0600 Subject: [PATCH 17/38] Remove unnecessary config check for __builtin_trap(). We don't use it. --- config/qthread_builtin_trap.m4 | 15 --------------- configure.ac | 1 - 2 files changed, 16 deletions(-) delete mode 100644 config/qthread_builtin_trap.m4 diff --git a/config/qthread_builtin_trap.m4 b/config/qthread_builtin_trap.m4 deleted file mode 100644 index 2f3a158de..000000000 --- a/config/qthread_builtin_trap.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([QTHREAD_BUILTIN_TRAP], -[AC_CACHE_CHECK([for __builtin_trap], - [qthread_cv_builtin_trap], - [AC_LINK_IFELSE([AC_LANG_SOURCE([[ -int main(void) -{ - int i=1; - __builtin_trap(); - return i; -}]])], - [qthread_cv_builtin_trap="yes"], - [qthread_cv_builtin_trap="no"])]) - AS_IF([test "x$qthread_cv_builtin_trap" = "xyes"], - [AC_DEFINE([QTHREAD_TRAP_OKAY],[1],[If __builtin_trap can be used])]) -]) diff --git a/configure.ac b/configure.ac index 272aaaa87..474cc8a2e 100644 --- a/configure.ac +++ b/configure.ac @@ -613,7 +613,6 @@ esac # Figure out whether the compiler has builtin atomic operations AS_IF([test "x$enable_hardware_atomics" != xno], [QTHREAD_CHECK_ATOMICS($sizeof_aligned_t)]) -QTHREAD_BUILTIN_TRAP QTHREAD_VAMACROS QTHREAD_CHECK_BITFIELDS From 284a19b3803d5b457c23f323c5cc09c5392b51c0 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:24:29 -0600 Subject: [PATCH 18/38] Drop support for altix timer and remove corresponding config directory file. --- config/qthread_check_altix_timer.m4 | 64 ----------------- configure.ac | 3 - src/qtimer/Makefile.inc | 4 -- src/qtimer/altix.c | 106 ---------------------------- 4 files changed, 177 deletions(-) delete mode 100644 config/qthread_check_altix_timer.m4 delete mode 100644 src/qtimer/altix.c diff --git a/config/qthread_check_altix_timer.m4 b/config/qthread_check_altix_timer.m4 deleted file mode 100644 index 9522632cb..000000000 --- a/config/qthread_check_altix_timer.m4 +++ /dev/null @@ -1,64 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2008 Sandia Corporation -# - -# QTHREAD_CHECK_ALTIX_TIMER([action-if-found], [action-if-not-found]) -# ------------------------------------------------------------------------------ -AC_DEFUN([QTHREAD_CHECK_ALTIX_TIMER], [ -AC_CHECK_HEADERS([sn/mmtimer.h linux/mmtimer.h], - [timer_altix_happy="yes" - break], - [timer_altix_happy="no"]) - -AS_IF([test "x$timer_altix_happy" = "xyes"], - [AC_CHECK_HEADERS([sys/ioctl.h sys/mman.h])]) - -AS_IF([test "x$timer_altix_happy" = "xyes"], - [AC_CACHE_CHECK([if MM timer can be opened], - [qthread_cv_mm_timer_mmap], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([ -#include -#include -#include -#include -#include -#include -#include -#include -#if HAVE_SN_MMTIMER_H -# include -#elif HAVE_LINUX_MMTIMER_H -# include -#endif -#ifndef MMTIMER_FULLNAME -# define MMTIMER_FULLNAME "/dev/mmtimer" -#endif -], [ - int fd, ret; - unsigned long val; - long offset; - unsigned long *mmdev_map = NULL; - volatile unsigned long *timer_address; - fd = open(MMTIMER_FULLNAME, O_RDONLY); - if (fd < 0) return -1; - ret = ioctl(fd, MMTIMER_GETFREQ, &val); - if (ret == -ENOSYS) return -1; - ret = ioctl(fd, MMTIMER_GETOFFSET, 0); - if (ret == -ENOSYS) return -1; - offset = ret; - mmdev_map = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, fd, 0); - if (NULL == mmdev_map) return -1; - timer_address = mmdev_map + offset; - val = *timer_address; - if (val == 0) return -1; - return 0;])], - [qthread_cv_mm_timer_mmap="yes"], - [qthread_cv_mm_timer_mmap="no"], - [qthread_cv_mm_timer_mmap="no"])]) -AS_IF([test "x$qthread_cv_mm_timer_mmap" = "xyes"], - [timer_altix_happy="yes"], - [timer_altix_happy="no"])]) - -AS_IF([test "x$timer_altix_happy" = "xyes"], [$1], [$2]) -]) diff --git a/configure.ac b/configure.ac index 474cc8a2e..fb5af353d 100644 --- a/configure.ac +++ b/configure.ac @@ -868,8 +868,6 @@ int main() { [AC_CHECK_FUNC([mach_absolute_time], [qthread_timer_type=mach])]) AS_IF([test "x$qthread_timer_type" = "xgettimeofday"], [AC_CHECK_FUNC([gethrtime], [qthread_timer_type=gethrtime])]) - AS_IF([test "x$qthread_timer_type" = "xgettimeofday"], - [QTHREAD_CHECK_ALTIX_TIMER([qthread_timer_type=altix])]) AS_IF([test "x$qthread_timer_type" = "xgettimeofday"], [AC_SEARCH_LIBS([clock_gettime],[rt], [qthread_timer_type=clock_gettime @@ -966,7 +964,6 @@ AM_CONDITIONAL([QTHREAD_NEED_OWN_MAKECONTEXT], [test "x$qthread_makecontext_type AM_CONDITIONAL([QTHREAD_TIMER_TYPE_GETTIME], [test "x$qthread_timer_type" = "xclock_gettime"]) AM_CONDITIONAL([QTHREAD_TIMER_TYPE_MACH], [test "x$qthread_timer_type" = "xmach"]) AM_CONDITIONAL([QTHREAD_TIMER_TYPE_GETHRTIME], [test "x$qthread_timer_type" = "xgethrtime"]) -AM_CONDITIONAL([QTHREAD_TIMER_TYPE_ALTIX], [test "x$qthread_timer_type" = "xaltix"]) AM_CONDITIONAL([QTHREAD_TIMER_TYPE_GETTIMEOFDAY], [test "x$qthread_timer_type" = "xgettimeofday"]) AM_CONDITIONAL([COMPILE_COMPAT_ATOMIC], [test "x$compile_compat_atomic" = "xyes"]) AM_CONDITIONAL([COMPILE_SPAWNCACHE], [test "x$enable_spawn_cache" = "xyes"]) diff --git a/src/qtimer/Makefile.inc b/src/qtimer/Makefile.inc index e1d153721..767ec8b3b 100644 --- a/src/qtimer/Makefile.inc +++ b/src/qtimer/Makefile.inc @@ -16,10 +16,6 @@ if QTHREAD_TIMER_TYPE_GETTIMEOFDAY libqthread_la_SOURCES += qtimer/gettimeofday.c endif -if QTHREAD_TIMER_TYPE_ALTIX -libqthread_la_SOURCES += qtimer/altix.c -endif - if QTHREAD_TIMER_TYPE_GETTIME libqthread_la_SOURCES += qtimer/gettime.c endif diff --git a/src/qtimer/altix.c b/src/qtimer/altix.c deleted file mode 100644 index 289d23296..000000000 --- a/src/qtimer/altix.c +++ /dev/null @@ -1,106 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include /* for calloc() */ -#include -#include -#include -#include -#ifdef HAVE_SN_MMTIMER_H -#include -#elif defined(HAVE_LINUX_MMTIMER_H) -#include -#endif -#include -#include -#ifndef MMTIMER_FULLNAME -#define MMTIMER_FULLNAME "/dev/mmtimer" -#endif - -#include "qt_atomics.h" /* for SPINLOCK_BODY() */ -#include "qt_debug.h" /* for malloc debug wrappers */ -#include "qthread/qthread.h" /* for aligned_t */ -#include "qthread/qtimer.h" - -static aligned_t inited = 0; -static double timer_freq_conv; -static unsigned long volatile *timer_address = NULL; -static unsigned long *mmdev_map = NULL; - -struct qtimer_s { - unsigned long start; - unsigned long stop; -}; - -static int qtimer_init(void) { - int fd, ret; - unsigned long val; - long offset; - - fd = open(MMTIMER_FULLNAME, O_RDONLY); - if (fd < 0) { return -1; } - - /* make sure we can map the timer */ - ret = ioctl(fd, MMTIMER_MMAPAVAIL, 0); - if (1 != ret) { return -1; } - - /* find the frequency of the timer */ - ret = ioctl(fd, MMTIMER_GETFREQ, &val); - if (ret == -ENOSYS) { return -1; } - timer_freq_conv = 1.0 / val; - - /* find the address of the counter */ - ret = ioctl(fd, MMTIMER_GETOFFSET, 0); - if (ret == -ENOSYS) { return -1; } - offset = ret; - - mmdev_map = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, fd, 0); - if (NULL == mmdev_map) { return -1; } - timer_address = mmdev_map + offset; - close(fd); - - return 0; -} - -void qtimer_start(qtimer_t q) { q->start = *timer_address; } - -unsigned long qtimer_fastrand(void) { - if (NULL == timer_address) { - if (0 != qtimer_init()) { return 0; } - } - - return *timer_address; -} - -double qtimer_wtime(void) { - return ((double)(*timer_address)) * timer_freq_conv; -} - -double qtimer_res(void) { return timer_freq_conv; } - -void qtimer_stop(qtimer_t q) { q->stop = *timer_address; } - -double qtimer_secs(qtimer_t q) { - return ((double)(q->stop - q->start)) * timer_freq_conv; -} - -qtimer_t qtimer_create(void) { - if (NULL == timer_address) { - if (qthread_cas_ptr(&timer_address, NULL, (void *)1) == NULL) { - if (0 != qtimer_init()) { - timer_address = NULL; - return NULL; - } - } else { - while (timer_address == (void *)1) SPINLOCK_BODY(); - } - } - - return qt_calloc(1, sizeof(struct qtimer_s)); -} - -void qtimer_destroy(qtimer_t q) { FREE(q, sizeof(struct qtimer_s)); } - -/* vim:set expandtab: */ From 08254209dcf9029b2fe39bb95e9544da239926c4 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:33:07 -0600 Subject: [PATCH 19/38] Drop check for assert. All supported configs have it these days. --- config/qthread_check_assert.m4 | 43 ---------------------------------- configure.ac | 1 - 2 files changed, 44 deletions(-) delete mode 100644 config/qthread_check_assert.m4 diff --git a/config/qthread_check_assert.m4 b/config/qthread_check_assert.m4 deleted file mode 100644 index efc9b4001..000000000 --- a/config/qthread_check_assert.m4 +++ /dev/null @@ -1,43 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2012 Sandia Corporation -# - -# QTHREAD_CHECK_ASSERT([action-if-found-working], [action-if-not-found-working]) -# ------------------------------------------------------------------------------ -AC_DEFUN([QTHREAD_CHECK_ASSERT], [ - qt_allgoodsofar=yes - AC_CHECK_HEADERS([assert.h],[], - [qt_allgoodsofar=no]) - AS_IF([test "x$qt_allgoodsofar" = xyes], - [AC_MSG_CHECKING([for linkable assert()]) - AC_LINK_IFELSE([AC_LANG_SOURCE([[ -#include -int main(int argc, char *argv[]) -{ - assert(argc >= 0); - assert(argv != 0); - return 0; -}]])], - [AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) - qt_allgoodsofar=no])]) - AS_IF([test "x$qt_allgoodsofar" = xyes], - [AC_MSG_CHECKING([for functional assert()]) - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -int main(int argc, char *argv[]) -{ - assert(argc > 0); - assert(argv != 0); - return 0; -}]])], - [], - [qt_allgoodsofar=no], - [dnl assume assert works - qt_allgoodsofar=yes]) - AC_MSG_RESULT([$qt_allgoodsofar])]) - AS_IF([test "x$qt_allgoodsofar" = xyes], - [$1], - [$2]) -]) diff --git a/configure.ac b/configure.ac index fb5af353d..93c8c609b 100644 --- a/configure.ac +++ b/configure.ac @@ -660,7 +660,6 @@ AC_CHECK_FUNCS([strtol memalign posix_memalign memset memmove munmap memcpy fsta QTHREAD_CHECK_QSORT AC_CHECK_DECLS([MADV_ACCESS_LWP],[],[],[[#include #include ]]) -QTHREAD_CHECK_ASSERT([],[AC_MSG_ERROR([assert() does not seem to work])]) AC_CACHE_SAVE From 0bd26fc359157753c3bdfb556eea6723d5be5d0c Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:44:50 -0600 Subject: [PATCH 20/38] Remove unused attribute check. --- config/qthread_check_attributes.m4 | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index 2ea7d76d4..2de329c67 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -77,25 +77,6 @@ __attribute__((noinline)) void * f(int i) AS_IF([test "x$qt_cv_noinline_attr" = xyes], [$1], [$2]) ]) -AC_DEFUN([QTHREAD_DEPRECATED_ATTRIBUTE],[dnl -AC_CACHE_CHECK( - [support for __attribute__((deprecated))], - [qt_cv_deprecated_attr], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#include -void * __attribute__((deprecated)) f (int i); -void * __attribute__((deprecated)) f (int i) -{ return malloc(i); }]])], - [qt_cv_deprecated_attr=yes], - [qt_cv_deprecated_attr=no])]) - AS_IF([test "x$qt_cv_deprecated_attr" = xyes], - [defstr="__attribute__((deprecated))"], - [defstr=""]) - AC_DEFINE_UNQUOTED([Q_DEPRECATED], [$defstr], - [if the compiler supports __attribute__((deprecated))]) - AS_IF([test "x$qt_cv_deprecated_attr" = xyes], [$1], [$2]) -]) - AC_DEFUN([QTHREAD_BUILTIN_PREFETCH],[dnl AC_CACHE_CHECK( [support for __builtin_prefetch], From 0d8d9f7248c0567d6b5ae35d420e6922d39dac1f Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 15:46:36 -0600 Subject: [PATCH 21/38] Get rid of configure check for __builtin_prefetch. All supported gcc-like compilers have it now. --- config/qthread_check_attributes.m4 | 15 --------------- configure.ac | 1 - include/qt_prefetch.h | 2 +- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index 2de329c67..f0a1b19b8 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -77,21 +77,6 @@ __attribute__((noinline)) void * f(int i) AS_IF([test "x$qt_cv_noinline_attr" = xyes], [$1], [$2]) ]) -AC_DEFUN([QTHREAD_BUILTIN_PREFETCH],[dnl -AC_CACHE_CHECK( - [support for __builtin_prefetch], - [qt_cv_builtin_prefetch], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include -int x;]],[[ -__builtin_prefetch(&x, 0, 0); -return malloc(x)?1:0;]])], - [qt_cv_builtin_prefetch=yes], - [qt_cv_builtin_prefetch=no])]) - AS_IF([test "x$qt_cv_builtin_prefetch" = xyes], - [AC_DEFINE([HAS_BUILTIN_PREFETCH], [1], [define if compiler supports __builtin_prefetch]) - $1], [$2]) -]) - AC_DEFUN([QTHREAD_BUILTIN_SYNCHRONIZE],[dnl AC_REQUIRE([QTHREAD_CHECK_ASSEMBLY]) AC_CACHE_CHECK([support for __sync_synchronize], diff --git a/configure.ac b/configure.ac index 93c8c609b..e54703ec6 100644 --- a/configure.ac +++ b/configure.ac @@ -621,7 +621,6 @@ QTHREAD_UNUSED_ATTRIBUTE QTHREAD_ALIGNED_ATTRIBUTE QTHREAD_NOINLINE_ATTRIBUTE QTHREAD_DEPRECATED_ATTRIBUTE -QTHREAD_BUILTIN_PREFETCH QTHREAD_BUILTIN_SYNCHRONIZE AS_IF([test "x$have_assembly" = "x0" -a "x$qthread_cv_atomic_CAS32" = "xno" -a "x$qthread_cv_atomic_CAS64" = "xno" -a "x$qthread_cv_atomic_incr" = "xno"], diff --git a/include/qt_prefetch.h b/include/qt_prefetch.h index f9c9305ad..a21cb5392 100644 --- a/include/qt_prefetch.h +++ b/include/qt_prefetch.h @@ -1,7 +1,7 @@ #ifndef QTHREAD_PREFETCH_H #define QTHREAD_PREFETCH_H -#ifdef HAS_BUILTIN_PREFETCH +#ifdef __GNUC__ #define Q_PREFETCH(x, ...) __builtin_prefetch((x), ##__VA_ARGS__) #else #define Q_PREFETCH(x, ...) From b2936a15008591f551a4a71a53a18c1b11ef9f89 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 16:25:09 -0600 Subject: [PATCH 22/38] Infer bitfied order from architecture instead of checking it at configure time. --- config/qthread_check_bitfield_order.m4 | 58 -------------------------- configure.ac | 1 - include/qthread/common.h.in | 14 ++++--- 3 files changed, 9 insertions(+), 64 deletions(-) delete mode 100644 config/qthread_check_bitfield_order.m4 diff --git a/config/qthread_check_bitfield_order.m4 b/config/qthread_check_bitfield_order.m4 deleted file mode 100644 index dbb5dbe00..000000000 --- a/config/qthread_check_bitfield_order.m4 +++ /dev/null @@ -1,58 +0,0 @@ -dnl -*- Autoconf -*- -dnl -dnl Copyright (c) 2010 Sandia Corporation -dnl -dnl -dnl QTHREAD_CHECK_BITFIELDS -dnl ------------------------------------------------------------------------------ -AC_DEFUN([QTHREAD_CHECK_BITFIELDS], [ -AC_ARG_WITH([forward-bitfields], - [AC_HELP_STRING([--with-forward-bitfields], - [Force bitfields to be declared in forward order - (e.g. for cross-compiles)])]) -AS_IF([test "x$with_forward_bitfields" = x], - [AC_CACHE_CHECK([bitfield ordering], - [qthread_cv_bitfield_order], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -#include - -union foo { - unsigned int w; - struct bar { - unsigned a : 28; - unsigned b : 3; - unsigned c : 1; - } s; -} fb; -static void handler (int sig, siginfo_t* s, void* v) -{ - _exit(1); -}]], -[[ -struct sigaction sa; - -memset (&sa, '\0', sizeof(sa)); -sa.sa_sigaction = &handler; -sa.sa_flags = SA_SIGINFO; -//Catch SIGABORT -sigaction(SIGABRT, &sa, NULL); - -fb.w = 0; -fb.s.c = 1; -assert(fb.w == 1);]])], - [qthread_cv_bitfield_order="forward"], - [qthread_cv_bitfield_order="reverse"], - [qthread_cv_bitfield_order="assuming reverse"])])], - [AS_IF([test "x$with_forward_bitfields" = xno], - [qthread_cv_bitfield_order=forward], - [qthread_cv_bitfield_order=reverse])]) - -AS_IF([test "$qthread_cv_bitfield_order" == forward], - [AC_DEFINE([BITFIELD_ORDER_FORWARD], [1], [Define if bitfields are in forward order])], - [AC_DEFINE([BITFIELD_ORDER_REVERSE], [1], [Define if bitfields are in reverse order])]) -]) -dnl vim:set expandtab diff --git a/configure.ac b/configure.ac index e54703ec6..36f97eb2e 100644 --- a/configure.ac +++ b/configure.ac @@ -614,7 +614,6 @@ esac AS_IF([test "x$enable_hardware_atomics" != xno], [QTHREAD_CHECK_ATOMICS($sizeof_aligned_t)]) QTHREAD_VAMACROS -QTHREAD_CHECK_BITFIELDS QTHREAD_MALLOC_ATTRIBUTE QTHREAD_UNUSED_ATTRIBUTE diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 9e0ac5a07..b9fff0ea3 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -29,11 +29,15 @@ /* Allow functions to be inlined */ #undef QINLINE -/* Define if bitfields are in forward order */ -#undef BITFIELD_ORDER_FORWARD - -/* Define if bitfields are in reverse order */ -#undef BITFIELD_ORDER_REVERSE +#ifndef __powerpc +#define BITFIELD_ORDER_REVERSE +#else +// ARM processors can technically change modes between +// big-endian and little-endian which also reverses the +// bitfield order. The overwhelming majority of the time +// they're run in little-endian mode though. +#define BITFIELD_ORDER_FORWARD +#endif /* The size of `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP From 54020364d9f43e101357df96942f80bc6921d9e7 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 16:38:12 -0600 Subject: [PATCH 23/38] Remove unused config detection code for __FUNCTION__ macro. --- config/qthread_check_FUNCTION.m4 | 37 -------------------------------- include/qthread/common.h.in | 3 --- 2 files changed, 40 deletions(-) delete mode 100644 config/qthread_check_FUNCTION.m4 diff --git a/config/qthread_check_FUNCTION.m4 b/config/qthread_check_FUNCTION.m4 deleted file mode 100644 index c03d2ea42..000000000 --- a/config/qthread_check_FUNCTION.m4 +++ /dev/null @@ -1,37 +0,0 @@ -dnl This file defines a macro to check for compiler support of __FUNCTION__ or -dnl C99's __func__, and defines a safe alternative if it doesn't. -dnl At the end, you CAN use __FUNCTION__, which will be "portable". - -AC_DEFUN([QTHREAD_CHECK_FUNCTION], - [AC_CACHE_CHECK([whether $CC supports __FUNCTION__], - [qt_cv_c99_FUNCTION], - [AC_TRY_COMPILE( -[#include -static void foo(void) { printf("%s\n", __FUNCTION__); }], - [foo(); return 0;], - [qt_cv_c99_FUNCTION=yes], - [qt_cv_c99_FUNCTION=no])]) - - AC_CACHE_CHECK([whether $CC supports __func__], - [qt_cv_c99_func], - [AC_TRY_COMPILE( -[#include -static void foo(void) { printf("%s\n", __func__); }], - [foo(); return 0;], - [qt_cv_c99_func=yes], - [qt_cv_c99_func=no])]) - - found_fname=no - AS_IF([test x$qt_cv_c99_FUNCTION = xyes], - [AC_DEFINE([HAVE_GNU_FUNCTION], [1], - [Define if the compiler supports GNU-style __FUNCTION__.]) - found_fname=yes], - [AS_IF([test x$qt_cv_c99_func = xyes], - [AC_DEFINE([HAVE_C99_FUNC], [1], - [Define if the compiler supports GNU-style __FUNCTION__.]) - AC_DEFINE([__FUNCTION__], [__func__], - [Map __func__ to __FUNCTION__, if available and necessary]) - found_fname=yes])]) - AS_IF([test x$found_fname = xno], - [AC_DEFINE([__FUNCTION__], ["unknown_func"], [Last resort, if no function name macros can be found])]) -]) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index b9fff0ea3..938ba28c0 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -72,9 +72,6 @@ /* if the compiler supports __attribute__((unused)) */ #undef Q_UNUSED -/* Last resort, if no function name macros can be found */ -#undef __FUNCTION__ - #ifdef __cplusplus #ifdef __GNUC__ #define restrict __restrict From df503cbe7acd200eb6565a2f10d82e2343d37c81 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 11:10:41 -0600 Subject: [PATCH 24/38] Detect usability of __attribute__((unused)) with preprocessor exclusively instead of using a configure check. --- config/qthread_check_attributes.m4 | 18 ---------------- configure.ac | 1 - include/qt_macros.h | 6 +++--- include/qthread/common.h.in | 3 --- include/qthread/qloop.h | 24 +++++++++++----------- src/barrier/feb.c | 1 + src/io.c | 2 +- src/patterns/allpairs.c | 5 +++-- src/qloop.c | 2 +- src/qthread.c | 2 +- src/threadqueues/lifo_threadqueues.c | 4 ++-- src/threadqueues/mtsfifo_threadqueues.c | 4 ++-- src/threadqueues/mutexfifo_threadqueues.c | 4 ++-- src/threadqueues/nemesis_threadqueues.c | 4 ++-- src/threadqueues/nottingham_threadqueues.c | 2 +- test/features/qutil.c | 6 ------ 16 files changed, 31 insertions(+), 57 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index f0a1b19b8..903116254 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -40,24 +40,6 @@ __attribute__((malloc)) void * f(int i) AS_IF([test "x$qt_cv_malloc_attr" = xyes], [$1], [$2]) ]) -AC_DEFUN([QTHREAD_UNUSED_ATTRIBUTE],[dnl -AC_CACHE_CHECK( - [support for __attribute__((unused))], - [qt_cv_unused_attr], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -static __attribute__((unused)) -int f(int i) { return i; }]])], - [qt_cv_unused_attr=yes], - [qt_cv_unused_attr=no])]) - AS_IF([test "x$qt_cv_unused_attr" = xyes], - [unusedstr="__attribute__((unused))" - AC_DEFINE([HAVE_UNUSED], [1], [compiler understands __attribute__((unused))])], - [unusedstr=""]) - AC_DEFINE_UNQUOTED([Q_UNUSED], [$unusedstr], - [most gcc compilers know a function __attribute__((unused))]) - AS_IF([test "x$qt_cv_unused_attr" = xyes], [$1], [$2]) -]) - AC_DEFUN([QTHREAD_NOINLINE_ATTRIBUTE],[dnl AC_CACHE_CHECK( [support for __attribute__((noinline))], diff --git a/configure.ac b/configure.ac index 36f97eb2e..dea8e9c80 100644 --- a/configure.ac +++ b/configure.ac @@ -616,7 +616,6 @@ AS_IF([test "x$enable_hardware_atomics" != xno], QTHREAD_VAMACROS QTHREAD_MALLOC_ATTRIBUTE -QTHREAD_UNUSED_ATTRIBUTE QTHREAD_ALIGNED_ATTRIBUTE QTHREAD_NOINLINE_ATTRIBUTE QTHREAD_DEPRECATED_ATTRIBUTE diff --git a/include/qt_macros.h b/include/qt_macros.h index dc3b767c5..f7d31da17 100644 --- a/include/qt_macros.h +++ b/include/qt_macros.h @@ -5,10 +5,10 @@ #include #endif -#ifdef HAVE_UNUSED -#define QUNUSED(x) UNUSED_##x __attribute__((unused)) +#ifdef __GNUC__ +#define Q_UNUSED(x) __attribute__((unused)) x #else -#define QUNUSED(x) UNUSED_##x +#define Q_UNUSED(x) x #endif #ifdef TLS diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 938ba28c0..9ac62bea9 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -69,9 +69,6 @@ /* if the compiler supports __attribute__((malloc)) */ #undef Q_MALLOC -/* if the compiler supports __attribute__((unused)) */ -#undef Q_UNUSED - #ifdef __cplusplus #ifdef __GNUC__ #define restrict __restrict diff --git a/include/qthread/qloop.h b/include/qthread/qloop.h index a25c2ccf7..ed93cef84 100644 --- a/include/qthread/qloop.h +++ b/include/qthread/qloop.h @@ -115,56 +115,56 @@ aligned_t qt_uint_max(aligned_t *array, size_t length, int checkfeb); aligned_t qt_uint_min(aligned_t *array, size_t length, int checkfeb); /* These are some utility accumulator functions */ -static Q_UNUSED void qt_dbl_add_acc(void *restrict a, void const *restrict b) { +static inline void qt_dbl_add_acc(void *restrict a, void const *restrict b) { *(double *)a += *(double *)b; } -static Q_UNUSED void qt_int_add_acc(void *restrict a, void const *restrict b) { +static inline void qt_int_add_acc(void *restrict a, void const *restrict b) { *(saligned_t *)a += *(saligned_t *)b; } -static Q_UNUSED void qt_uint_add_acc(void *restrict a, void const *restrict b) { +static inline void qt_uint_add_acc(void *restrict a, void const *restrict b) { *(aligned_t *)a += *(aligned_t *)b; } -static Q_UNUSED void qt_dbl_prod_acc(void *restrict a, void const *restrict b) { +static inline void qt_dbl_prod_acc(void *restrict a, void const *restrict b) { *(double *)a *= *(double *)b; } -static Q_UNUSED void qt_int_prod_acc(void *restrict a, void const *restrict b) { +static inline void qt_int_prod_acc(void *restrict a, void const *restrict b) { *(saligned_t *)a *= *(saligned_t *)b; } -static Q_UNUSED void qt_uint_prod_acc(void *restrict a, +static inline void qt_uint_prod_acc(void *restrict a, void const *restrict b) { *(aligned_t *)a *= *(aligned_t *)b; } -static Q_UNUSED void qt_dbl_max_acc(void *restrict a, void const *restrict b) { +static inline void qt_dbl_max_acc(void *restrict a, void const *restrict b) { if (*(double *)b > *(double *)a) { *(double *)a = *(double *)b; } } -static Q_UNUSED void qt_int_max_acc(void *restrict a, void const *restrict b) { +static inline void qt_int_max_acc(void *restrict a, void const *restrict b) { if (*(saligned_t *)b > *(saligned_t *)a) { *(saligned_t *)a = *(saligned_t *)b; } } -static Q_UNUSED void qt_uint_max_acc(void *restrict a, void const *restrict b) { +static inline void qt_uint_max_acc(void *restrict a, void const *restrict b) { if (*(aligned_t *)b > *(aligned_t *)a) { *(aligned_t *)a = *(aligned_t *)b; } } -static Q_UNUSED void qt_dbl_min_acc(void *restrict a, void const *restrict b) { +static inline void qt_dbl_min_acc(void *restrict a, void const *restrict b) { if (*(double *)b < *(double *)a) { *(double *)a = *(double *)b; } } -static Q_UNUSED void qt_int_min_acc(void *restrict a, void const *restrict b) { +static inline void qt_int_min_acc(void *restrict a, void const *restrict b) { if (*(saligned_t *)b < *(saligned_t *)a) { *(saligned_t *)a = *(saligned_t *)b; } } -static Q_UNUSED void qt_uint_min_acc(void *restrict a, void const *restrict b) { +static inline void qt_uint_min_acc(void *restrict a, void const *restrict b) { if (*(aligned_t *)b < *(aligned_t *)a) { *(aligned_t *)a = *(aligned_t *)b; } } diff --git a/src/barrier/feb.c b/src/barrier/feb.c index b5ccf8e02..eb012163c 100644 --- a/src/barrier/feb.c +++ b/src/barrier/feb.c @@ -17,6 +17,7 @@ #include "qt_barrier.h" #include "qt_debug.h" #include "qt_initialized.h" // for qthread_library_initialized +#include "qt_macros.h" #include "qt_mpool.h" #include "qt_subsystems.h" #include "qt_visibility.h" diff --git a/src/io.c b/src/io.c index 3a70de8cc..b8ba9fded 100644 --- a/src/io.c +++ b/src/io.c @@ -76,7 +76,7 @@ static void qt_blocking_subsystem_internal_freemem(void) { /*{{{*/ QTHREAD_DESTROYCOND(&theQueue.notempty); } /*}}}*/ -static void *qt_blocking_subsystem_proxy_thread(void *QUNUSED(arg)) { /*{{{*/ +static void *qt_blocking_subsystem_proxy_thread(void *Q_UNUSED(arg)) { /*{{{*/ while (!atomic_load_explicit(&proxy_exit, memory_order_relaxed)) { if (qt_process_blocking_call()) { break; } COMPILER_FENCE; diff --git a/src/patterns/allpairs.c b/src/patterns/allpairs.c index 287588980..bb4163e26 100644 --- a/src/patterns/allpairs.c +++ b/src/patterns/allpairs.c @@ -6,6 +6,7 @@ #include #include "qt_asserts.h" +#include "qt_macros.h" #include /* for printf */ #include /* for malloc() */ @@ -145,7 +146,7 @@ struct qt_ap_gargs2 { static void qt_ap_genwork2(size_t const startat, size_t const stopat, - qarray *Q_UNUSED a, + qarray *Q_UNUSED(a), void *gargs_void) { struct qt_ap_gargs2 *gargs = (struct qt_ap_gargs2 *)gargs_void; struct qt_ap_workunit *workunit = MALLOC(sizeof(struct qt_ap_workunit)); @@ -199,7 +200,7 @@ static void qt_ap_genwork2(size_t const startat, static void qt_ap_genwork(size_t const startat, size_t const stopat, - qarray *restrict const Q_UNUSED a, + qarray *restrict const Q_UNUSED(a), void *restrict gargs_void) { struct qt_ap_gargs *gargs = (struct qt_ap_gargs *)gargs_void; struct qt_ap_gargs2 garg2 = {gargs->wq, startat, stopat, qthread_shep()}; diff --git a/src/qloop.c b/src/qloop.c index 0eddb0e29..4b2b27ef8 100644 --- a/src/qloop.c +++ b/src/qloop.c @@ -750,7 +750,7 @@ void API_FUNC qt_loopaccum_balance_dc(size_t const start, * are disabled. */ -static Q_UNUSED QINLINE int qqloop_get_iterations_guided( +static int qqloop_get_iterations_guided( qqloop_iteration_queue_t *restrict const iq, struct qqloop_static_args *restrict const sa, struct qqloop_wrapper_range *restrict const range) { /*{{{ */ diff --git a/src/qthread.c b/src/qthread.c index 56107be58..819dcacf7 100644 --- a/src/qthread.c +++ b/src/qthread.c @@ -339,7 +339,7 @@ int API_FUNC qthread_debuglevel(int d) { } #else -int API_FUNC qthread_debuglevel(int Q_UNUSED d) { return 0; } +int API_FUNC qthread_debuglevel(int Q_UNUSED(d)) { return 0; } #endif /* ifdef QTHREAD_DEBUG */ diff --git a/src/threadqueues/lifo_threadqueues.c b/src/threadqueues/lifo_threadqueues.c index c92a3e53e..b23e7f59f 100644 --- a/src/threadqueues/lifo_threadqueues.c +++ b/src/threadqueues/lifo_threadqueues.c @@ -230,8 +230,8 @@ ssize_t INTERNAL qt_threadqueue_advisory_queuelen(qt_threadqueue_t *q) { /*{{{*/ qthread_t INTERNAL * qt_scheduler_get_thread(qt_threadqueue_t *q, - qt_threadqueue_private_t *QUNUSED(qc), - uint_fast8_t QUNUSED(active)) { /*{{{*/ + qt_threadqueue_private_t *Q_UNUSED(qc), + uint_fast8_t Q_UNUSED(active)) { /*{{{*/ #ifdef QTHREAD_USE_EUREKAS qt_eureka_disable(); #endif /* QTHREAD_USE_EUREKAS */ diff --git a/src/threadqueues/mtsfifo_threadqueues.c b/src/threadqueues/mtsfifo_threadqueues.c index 1c27af967..7ed8f93fc 100644 --- a/src/threadqueues/mtsfifo_threadqueues.c +++ b/src/threadqueues/mtsfifo_threadqueues.c @@ -286,8 +286,8 @@ void qt_threadqueue_enqueue_yielded(qt_threadqueue_t *restrict q, qthread_t INTERNAL * qt_scheduler_get_thread(qt_threadqueue_t *q, - qt_threadqueue_private_t *QUNUSED(qc), - uint_fast8_t QUNUSED(active)) { /*{{{ */ + qt_threadqueue_private_t *Q_UNUSED(qc), + uint_fast8_t Q_UNUSED(active)) { /*{{{ */ qthread_t *p = NULL; qt_threadqueue_node_t *head; diff --git a/src/threadqueues/mutexfifo_threadqueues.c b/src/threadqueues/mutexfifo_threadqueues.c index f3d544191..950e51bc8 100644 --- a/src/threadqueues/mutexfifo_threadqueues.c +++ b/src/threadqueues/mutexfifo_threadqueues.c @@ -207,8 +207,8 @@ void qt_threadqueue_enqueue_yielded(qt_threadqueue_t *restrict q, * functions as a spinlock, but if it spins too much, it waits for a signal */ qthread_t INTERNAL * qt_scheduler_get_thread(qt_threadqueue_t *q, - qt_threadqueue_private_t *QUNUSED(qc), - uint_fast8_t QUNUSED(active)) { /*{{{ */ + qt_threadqueue_private_t *Q_UNUSED(qc), + uint_fast8_t Q_UNUSED(active)) { /*{{{ */ qthread_t *p = NULL; #ifdef QTHREAD_USE_EUREKAS diff --git a/src/threadqueues/nemesis_threadqueues.c b/src/threadqueues/nemesis_threadqueues.c index 0722ac139..ac2954069 100644 --- a/src/threadqueues/nemesis_threadqueues.c +++ b/src/threadqueues/nemesis_threadqueues.c @@ -353,8 +353,8 @@ qt_threadqueue_advisory_queuelen(qt_threadqueue_t *q) { /*{{{ */ qthread_t INTERNAL * qt_scheduler_get_thread(qt_threadqueue_t *q, - qt_threadqueue_private_t *QUNUSED(qc), - uint_fast8_t QUNUSED(active)) { /*{{{ */ + qt_threadqueue_private_t *Q_UNUSED(qc), + uint_fast8_t Q_UNUSED(active)) { /*{{{ */ #ifdef QTHREAD_CONDWAIT_BLOCKING_QUEUE int i; #endif /* QTHREAD_CONDWAIT_BLOCKING_QUEUE */ diff --git a/src/threadqueues/nottingham_threadqueues.c b/src/threadqueues/nottingham_threadqueues.c index 50068eea2..23dfc62d7 100644 --- a/src/threadqueues/nottingham_threadqueues.c +++ b/src/threadqueues/nottingham_threadqueues.c @@ -458,7 +458,7 @@ qthread_t static QINLINE *qt_threadqueue_dequeue_helper(qt_threadqueue_t *q) { /* dequeue at tail, unlike original qthreads implementation */ qthread_t INTERNAL * qt_scheduler_get_thread(qt_threadqueue_t *q, - qt_threadqueue_private_t *QUNUSED(qc), + qt_threadqueue_private_t *Q_UNUSED(qc), uint_fast8_t active) { /*{{{*/ qthread_t *t = NULL; rwlock_t *rwlock = q->rwlock; diff --git a/test/features/qutil.c b/test/features/qutil.c index 989f04634..e86f813ae 100644 --- a/test/features/qutil.c +++ b/test/features/qutil.c @@ -19,11 +19,6 @@ * This file tests the qutil functions * */ -static Q_UNUSED int dcmp(void const *a, void const *b) { - if ((*(double *)a) < (*(double *)b)) { return -1; } - if ((*(double *)a) > (*(double *)b)) { return 1; } - return 0; -} aligned_t *ui_array; aligned_t ui_out, ui_sum_authoritative = 0, ui_mult_authoritative = 1, @@ -177,7 +172,6 @@ static aligned_t qmain(void *junk) { // printf("[qutil] sorting...\n"); gettimeofday(&start, NULL); qutil_qsort(d_array, d_len); - // qsort(d_array, d_len, sizeof(double), dcmp); gettimeofday(&stop, NULL); iprintf("done sorting, checking correctness...\n"); for (i = 0; i < d_len - 1; i++) { From 988dcb4d5417921221666dd7eb8231aa3946a6d8 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 14:13:58 -0600 Subject: [PATCH 25/38] Use alignas instead of checking for the existence of a compiler extension attribute that provides similar functionality. --- config/qthread_check_attributes.m4 | 18 -------------- configure.ac | 2 -- include/qt_qthread_struct.h | 2 +- include/qt_shepherd_innards.h | 4 +++- include/qthread/common.h.in | 6 ----- include/qthread/qthread.h | 25 ++++++++++---------- include/qthread/sinc.h | 8 +++++-- include/qthread/spr.h | 4 ++-- src/qloop.c | 6 ++--- src/threadqueues/nemesis_threadqueues.c | 4 ++-- test/benchmarks/generic/time_halo_swap_all.c | 8 +++---- 11 files changed, 33 insertions(+), 54 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index 903116254..179fc0304 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -3,24 +3,6 @@ # Copyright (c) 2008 Sandia Corporation # -# QTHREAD_ALIGNED_ATTRIBUTE([action-if-found], [action-if-not-found]) -# ------------------------------------------------------------------------- -AC_DEFUN([QTHREAD_ALIGNED_ATTRIBUTE],[dnl -AC_CACHE_CHECK( - [support for aligned data declarations], - [qt_cv_aligned_attr], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -int foo __attribute__((aligned(64))); -int f(int i); -int f(int i) { foo = 1; return foo; }]])], - [qt_cv_aligned_attr=yes], - [qt_cv_aligned_attr=no])]) - AS_IF([test "x$qt_cv_aligned_attr" = xyes], - [AC_DEFINE([QTHREAD_ALIGNEDDATA_ALLOWED], [1], - [specifying data alignment is allowed])]) - AS_IF([test "x$qt_cv_aligned_attr" = xyes], [$1], [$2]) -]) - AC_DEFUN([QTHREAD_MALLOC_ATTRIBUTE],[dnl AC_CACHE_CHECK( [support for __attribute__((malloc))], diff --git a/configure.ac b/configure.ac index dea8e9c80..d96f2f35a 100644 --- a/configure.ac +++ b/configure.ac @@ -501,7 +501,6 @@ AS_IF([test "x$enable_64bit_aligned_t" = "xno"], [sizeof_aligned_t="$ac_cv_size align_aligned_t="$ac_cv_sizeof_int"]) AC_DEFINE_UNQUOTED([QTHREAD_SIZEOF_ALIGNED_T], [$sizeof_aligned_t], [size of aligned_t]) -AC_DEFINE_UNQUOTED([QTHREAD_ALIGNMENT_ALIGNED_T], [$align_aligned_t], [alignment of aligned_t]) AC_CACHE_SAVE @@ -616,7 +615,6 @@ AS_IF([test "x$enable_hardware_atomics" != xno], QTHREAD_VAMACROS QTHREAD_MALLOC_ATTRIBUTE -QTHREAD_ALIGNED_ATTRIBUTE QTHREAD_NOINLINE_ATTRIBUTE QTHREAD_DEPRECATED_ATTRIBUTE QTHREAD_BUILTIN_SYNCHRONIZE diff --git a/include/qt_qthread_struct.h b/include/qt_qthread_struct.h index a4e12f216..1a2ebf26b 100644 --- a/include/qt_qthread_struct.h +++ b/include/qt_qthread_struct.h @@ -92,7 +92,7 @@ struct qthread_s { _Atomic uint16_t flags; /* may not need all bits */ _Atomic uint8_t thread_state; - Q_ALIGNED(8) + alignas(8) uint8_t data[]; /* this is where we stick argcopy and tasklocal data */ }; diff --git a/include/qt_shepherd_innards.h b/include/qt_shepherd_innards.h index ee62f9d65..2c9b4a1e4 100644 --- a/include/qt_shepherd_innards.h +++ b/include/qt_shepherd_innards.h @@ -1,6 +1,8 @@ #ifndef QT_SHEPHERD_INNARDS_H #define QT_SHEPHERD_INNARDS_H +#include + #ifdef QTHREAD_PERFORMANCE #include #endif @@ -53,7 +55,7 @@ struct qthread_worker_s { #ifdef QTHREAD_PERFORMANCE struct qtperfdata_s *performance_data; #endif - _Atomic Q_ALIGNED(8) uint_fast8_t active; + _Atomic alignas(8) uint_fast8_t active; }; typedef struct qthread_worker_s qthread_worker_t; diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 9ac62bea9..3a38ce7bb 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -42,9 +42,6 @@ /* The size of `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP -/* alignment of aligned_t */ -#undef QTHREAD_ALIGNMENT_ALIGNED_T - /* size of aligned_t */ #undef QTHREAD_SIZEOF_ALIGNED_T @@ -63,9 +60,6 @@ /* builtin incr supported */ #undef QTHREAD_ATOMIC_INCR -/* specifying data alignment is allowed */ -#undef QTHREAD_ALIGNEDDATA_ALLOWED - /* if the compiler supports __attribute__((malloc)) */ #undef Q_MALLOC diff --git a/include/qthread/qthread.h b/include/qthread/qthread.h index 5cdc39a68..37e02938b 100644 --- a/include/qthread/qthread.h +++ b/include/qthread/qthread.h @@ -91,10 +91,6 @@ using std::memory_order_relaxed; #include "macros.h" -#ifdef QTHREAD_ALIGNEDDATA_ALLOWED -#define Q_ALIGNED(x) __attribute__((aligned(x))) -#endif - #if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64 #define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES #endif @@ -103,20 +99,23 @@ Q_STARTCXX /* */ /* NOTE!!!!!!!!!!! * Reads and writes operate on aligned_t-size segments of memory. * - * FEB locking only works on aligned addresses. This is here to try and help a - * little bit. */ + * FEB locking only works on aligned addresses. + * On all supported platforms sizeof(aligned_t) == alignof(aligned_t) + * anyway so we're fine. */ #if QTHREAD_SIZEOF_ALIGNED_T == 4 - typedef uint32_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) aligned_t; -typedef uint16_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T / 2) haligned_t; -typedef int32_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) saligned_t; +typedef uint32_t aligned_t; +typedef uint16_t haligned_t; +typedef int32_t saligned_t; #elif QTHREAD_SIZEOF_ALIGNED_T == 8 - typedef uint64_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) aligned_t; -typedef uint32_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T / 2) haligned_t; -typedef int64_t Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) saligned_t; +typedef uint64_t aligned_t; +typedef uint32_t haligned_t; +typedef int64_t saligned_t; #else #error "Don't know type for sizeof aligned_t" #endif +#define QTHREAD_ALIGNMENT_ALIGNED_T (sizeof(aligned_t)) + #ifndef QTHREAD_NOALIGNCHECK #define QALIGN(d, s) \ do { \ @@ -511,7 +510,7 @@ typedef union qt_spin_trylock_s { haligned_t ticket; haligned_t users; } s; -} Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) qt_spin_trylock_t; +} qt_spin_trylock_t; typedef struct { int64_t s; diff --git a/include/qthread/sinc.h b/include/qthread/sinc.h index c2e2b64d1..e30a26af0 100644 --- a/include/qthread/sinc.h +++ b/include/qthread/sinc.h @@ -1,14 +1,18 @@ #ifndef QT_SINC_H #define QT_SINC_H + +#include + #include "macros.h" +#include "qthread.h" Q_STARTCXX /* */ typedef void (*qt_sinc_op_f)(void *tgt, void const *src); typedef struct qt_opaque_sinc_s { - uint8_t opaque_data[24]; -} Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) qt_sinc_t; + alignas(QTHREAD_ALIGNMENT_ALIGNED_T) uint8_t opaque_data[24]; +} qt_sinc_t; void qt_sinc_init(qt_sinc_t *restrict sinc, size_t sizeof_value, diff --git a/include/qthread/spr.h b/include/qthread/spr.h index 878e6a218..ced5a73fa 100644 --- a/include/qthread/spr.h +++ b/include/qthread/spr.h @@ -29,7 +29,7 @@ int spr_locale_id(void); typedef struct { uint8_t opaque_data[8]; -} Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) spr_get_handle_t; +} alignas(QTHREAD_ALIGNMENT_ALIGNED_T) spr_get_handle_t; int spr_get(void *restrict dest_addr, int src_loc, @@ -44,7 +44,7 @@ int spr_get_wait(spr_get_handle_t *const hand); typedef struct { uint8_t opaque_data[8]; -} Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) spr_put_handle_t; +} alignas(QTHREAD_ALIGNMENT_ALIGNED_T) spr_put_handle_t; int spr_put(int dest_loc, void *restrict dest_addr, diff --git a/src/qloop.c b/src/qloop.c index 4b2b27ef8..fa320501c 100644 --- a/src/qloop.c +++ b/src/qloop.c @@ -178,7 +178,7 @@ qt_loop_spawner(size_t const start, size_t const stop, void *args_) { /*{{{*/ syncvar_t *syncvar; aligned_t *aligned; qt_sinc_t *sinc; - } Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) sync = {NULL}; + } sync = {NULL}; switch (sync_type) { case SYNCVAR_T: @@ -347,7 +347,7 @@ static QINLINE void qt_loop_balance_inner(size_t const start, aligned_t *aligned; qt_sinc_t *sinc; aligned_t dc; - } Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) sync = {NULL}; + } sync = {NULL}; switch (sync_type) { case SYNCVAR_T: @@ -591,7 +591,7 @@ static QINLINE void qt_loopaccum_balance_inner(size_t const start, aligned_t *aligned; qt_sinc_t *sinc; aligned_t dc; - } Q_ALIGNED(QTHREAD_ALIGNMENT_ALIGNED_T) sync = {NULL}; + } sync = {NULL}; switch (sync_type) { case SYNCVAR_T: diff --git a/src/threadqueues/nemesis_threadqueues.c b/src/threadqueues/nemesis_threadqueues.c index ac2954069..66955c07c 100644 --- a/src/threadqueues/nemesis_threadqueues.c +++ b/src/threadqueues/nemesis_threadqueues.c @@ -58,10 +58,10 @@ typedef struct { * guaranteed accurate (that would be a race condition) */ saligned_t nemesis_advisory_queuelen; uint8_t pad2[CACHELINE_WIDTH - sizeof(void *) - sizeof(saligned_t)]; -} NEMESIS_queue Q_ALIGNED(CACHELINE_WIDTH); +} NEMESIS_queue; struct _qt_threadqueue { - NEMESIS_queue q; + alignas(CACHELINE_WIDTH) NEMESIS_queue q; /* the following is for estimating a queue's "busy" level, and is not * guaranteed accurate (that would be a race condition) */ saligned_t advisory_queuelen; diff --git a/test/benchmarks/generic/time_halo_swap_all.c b/test/benchmarks/generic/time_halo_swap_all.c index c1dcd8ecf..74fed5182 100644 --- a/test/benchmarks/generic/time_halo_swap_all.c +++ b/test/benchmarks/generic/time_halo_swap_all.c @@ -75,7 +75,7 @@ static char *pos_strs[16] = {"NW", "NWES"}; typedef struct partition_s { - Q_ALIGNED(8) position_t pos; // Position of this partition in matrix + alignas(8) position_t pos; // Position of this partition in matrix size_t row; // Row index in partition matrix size_t col; // Col index in partition matrix size_t nrows; // Number of rows in this partition @@ -256,8 +256,8 @@ typedef struct upx_args_s { syncvar_t ***stages; size_t now; size_t timestep; - Q_ALIGNED(8) position_t dir; - Q_ALIGNED(8) position_t pos; + alignas(8) position_t dir; + alignas(8) position_t pos; size_t num_rows; size_t num_cols; size_t part_lid; @@ -667,7 +667,7 @@ num_cols, arg->part_lid}; typedef struct sb_args_s { syncvar_t ***target; syncvar_t ***source; - Q_ALIGNED(8) position_t dir; + alignas(8) position_t dir; size_t stage; size_t timestep; size_t lb; From 422cbbc78b1d2e1428d1598f2e8b6a87eba46423 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 14:16:29 -0600 Subject: [PATCH 26/38] Remove two checks that are no longer associated with any config file. --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index d96f2f35a..e23847590 100644 --- a/configure.ac +++ b/configure.ac @@ -549,8 +549,6 @@ AC_HEADER_TIME AC_CHECK_HEADERS([stdlib.h fcntl.h ucontext.h sys/time.h sys/resource.h mach/mach_time.h malloc.h math.h sys/types.h sys/sysctl.h unistd.h sys/syscall.h]) AC_SYS_LARGEFILE -QTHREAD_CHECK_FUNCTION - AC_CACHE_SAVE ## -------------------- ## @@ -616,7 +614,6 @@ QTHREAD_VAMACROS QTHREAD_MALLOC_ATTRIBUTE QTHREAD_NOINLINE_ATTRIBUTE -QTHREAD_DEPRECATED_ATTRIBUTE QTHREAD_BUILTIN_SYNCHRONIZE AS_IF([test "x$have_assembly" = "x0" -a "x$qthread_cv_atomic_CAS32" = "xno" -a "x$qthread_cv_atomic_CAS64" = "xno" -a "x$qthread_cv_atomic_incr" = "xno"], From 80d14d6d08fa731201a1a9671eff7ffd01a2a026 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 14:18:02 -0600 Subject: [PATCH 27/38] Get rid of unused malloc attribute check. --- config/qthread_check_attributes.m4 | 19 ------------------- configure.ac | 1 - include/qthread/common.h.in | 3 --- 3 files changed, 23 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index 179fc0304..9675f1101 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -3,25 +3,6 @@ # Copyright (c) 2008 Sandia Corporation # -AC_DEFUN([QTHREAD_MALLOC_ATTRIBUTE],[dnl -AC_CACHE_CHECK( - [support for __attribute__((malloc))], - [qt_cv_malloc_attr], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#include -__attribute__((malloc)) void * f(int i); -__attribute__((malloc)) void * f(int i) -{ return malloc(i); }]])], - [qt_cv_malloc_attr=yes], - [qt_cv_malloc_attr=no])]) - AS_IF([test "x$qt_cv_malloc_attr" = xyes], - [defstr="__attribute__((malloc))"], - [defstr=""]) - AC_DEFINE_UNQUOTED([Q_MALLOC], [$defstr], - [if the compiler supports __attribute__((malloc))]) - AS_IF([test "x$qt_cv_malloc_attr" = xyes], [$1], [$2]) -]) - AC_DEFUN([QTHREAD_NOINLINE_ATTRIBUTE],[dnl AC_CACHE_CHECK( [support for __attribute__((noinline))], diff --git a/configure.ac b/configure.ac index e23847590..c6fcfa089 100644 --- a/configure.ac +++ b/configure.ac @@ -612,7 +612,6 @@ AS_IF([test "x$enable_hardware_atomics" != xno], [QTHREAD_CHECK_ATOMICS($sizeof_aligned_t)]) QTHREAD_VAMACROS -QTHREAD_MALLOC_ATTRIBUTE QTHREAD_NOINLINE_ATTRIBUTE QTHREAD_BUILTIN_SYNCHRONIZE diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 3a38ce7bb..3480918ca 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -60,9 +60,6 @@ /* builtin incr supported */ #undef QTHREAD_ATOMIC_INCR -/* if the compiler supports __attribute__((malloc)) */ -#undef Q_MALLOC - #ifdef __cplusplus #ifdef __GNUC__ #define restrict __restrict From cacdcc87f6c4a56c5f5e20c717e394a524b8f19a Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 14:34:20 -0600 Subject: [PATCH 28/38] Move architecture bit-ness detection and determination of sizeof(aligned_t) out of configure. --- configure.ac | 26 -------------------------- include/qt_atomics.h | 14 +++++++------- include/qt_task_counter.h | 4 ++-- include/qthread/common.h.in | 3 --- include/qthread/hash.h | 2 +- include/qthread/qthread.h | 13 +++++++++++-- src/ds/dictionary/hash.c | 4 ++-- src/sincs/original.c | 4 ++-- src/sincs/snzi.c | 2 -- test/basics/qthread_incr.c | 4 ++-- 10 files changed, 27 insertions(+), 49 deletions(-) diff --git a/configure.ac b/configure.ac index c6fcfa089..588e430a3 100644 --- a/configure.ac +++ b/configure.ac @@ -476,32 +476,6 @@ AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_TYPE_PID_T -AC_CHECK_SIZEOF([int]) -AC_CHECK_SIZEOF([void*]) - -# Default behavior: -# sizeof(aligned_t) = 8 (unless POWERPC32, then 4) -# alignment(aligned_t) = 8 (unless POWERPC32, then 4) -# If user specified 64bit aligned_t: -# sizeof(aligned_t) = 8 (or should this be sizeof(long)?) -# alignment(aligned_t) = 8 -# else if user forbids 64bit aligned_t: -# sizeof(aligned_t) = sizeof(int) -# alignment(aligned_t) = sizeof(int) -# If user specified 64bit alignment: -# alignment(aligned_t) = 8 -AS_IF([test "x$qthread_cv_asm_arch" = "xPOWERPC32"], - [sizeof_aligned_t=4 - align_aligned_t=4], - [sizeof_aligned_t=8 - align_aligned_t=8]) -AS_IF([test "x$enable_64bit_aligned_t" = "xyes"], [sizeof_aligned_t="8" - align_aligned_t="8"]) -AS_IF([test "x$enable_64bit_aligned_t" = "xno"], [sizeof_aligned_t="$ac_cv_sizeof_int" - align_aligned_t="$ac_cv_sizeof_int"]) - -AC_DEFINE_UNQUOTED([QTHREAD_SIZEOF_ALIGNED_T], [$sizeof_aligned_t], [size of aligned_t]) - AC_CACHE_SAVE ## -------------------- ## diff --git a/include/qt_atomics.h b/include/qt_atomics.h index 79d8c4dfa..ba83161ca 100644 --- a/include/qt_atomics.h +++ b/include/qt_atomics.h @@ -478,7 +478,7 @@ static QINLINE aligned_t qthread_internal_incr_mod_( unsigned int const max QTHREAD_OPTIONAL_LOCKARG) { /*{{{ */ aligned_t retval; -#if QTHREAD_ATOMIC_CAS && (QTHREAD_SIZEOF_ALIGNED_T == 4) +#if QTHREAD_ATOMIC_CAS && (QTHREAD_BITS == 32) uint32_t oldval, newval; newval = *operand; @@ -489,7 +489,7 @@ static QINLINE aligned_t qthread_internal_incr_mod_( newval = __sync_val_compare_and_swap((uint32_t *)operand, oldval, newval); } while (oldval != newval); -#elif QTHREAD_ATOMIC_CAS && (QTHREAD_SIZEOF_ALIGNED_T == 8) +#elif QTHREAD_ATOMIC_CAS && (QTHREAD_BITS == 64) uint64_t oldval, newval; newval = *operand; @@ -503,7 +503,7 @@ static QINLINE aligned_t qthread_internal_incr_mod_( #elif defined(HAVE_GCC_INLINE_ASSEMBLY) #if (QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC32) || \ ((QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC64) && \ - (QTHREAD_SIZEOF_ALIGNED_T == 4)) + (QTHREAD_BITS == 32)) unsigned int incrd = incrd; /* these don't need to be initialized */ unsigned int compd = compd; /* they're just tmp variables */ @@ -547,9 +547,9 @@ static QINLINE aligned_t qthread_internal_incr_mod_( : "cc", "memory"); #elif ((QTHREAD_ASSEMBLY_ARCH == QTHREAD_IA32) && \ - (QTHREAD_SIZEOF_ALIGNED_T == 4)) || \ + (QTHREAD_BITS == 32)) || \ ((QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64) && \ - (QTHREAD_SIZEOF_ALIGNED_T == 4)) + (QTHREAD_BITS == 32)) unsigned int oldval, newval; @@ -622,11 +622,11 @@ static QINLINE aligned_t qthread_internal_incr_mod_( #else /* if (QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC32) || \ ((QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC64) && \ - (QTHREAD_SIZEOF_ALIGNED_T == 4)) */ + (QTHREAD_BITS == 32)) */ #error "Unimplemented assembly architecture" #endif /* if (QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC32) || \ ((QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC64) && \ - (QTHREAD_SIZEOF_ALIGNED_T == 4)) */ + (QTHREAD_BITS == 32)) */ #elif defined(QTHREAD_MUTEX_INCREMENT) QTHREAD_FASTLOCK_LOCK(lock); diff --git a/include/qt_task_counter.h b/include/qt_task_counter.h index 6fa2a5096..2d76bbea4 100644 --- a/include/qt_task_counter.h +++ b/include/qt_task_counter.h @@ -3,12 +3,12 @@ #include -#if QTHREAD_SIZEOF_ALIGNED_T == 4 +#if QTHREAD_BITS == 32 #define QT_TCOUNT_OFFSET (31) #define QT_TCOUNT_BASE (1u) -#elif QTHREAD_SIZEOF_ALIGNED_T == 8 +#elif QTHREAD_BITS == 64 #define QT_TCOUNT_OFFSET (63) #define QT_TCOUNT_BASE (1ul) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 3480918ca..b38477302 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -42,9 +42,6 @@ /* The size of `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP -/* size of aligned_t */ -#undef QTHREAD_SIZEOF_ALIGNED_T - /* builtin cas supported */ #undef QTHREAD_ATOMIC_CAS diff --git a/include/qthread/hash.h b/include/qthread/hash.h index 45aa2d4d6..a39343006 100644 --- a/include/qthread/hash.h +++ b/include/qthread/hash.h @@ -7,7 +7,7 @@ Q_STARTCXX /* */ -#if (QTHREAD_SIZEOF_ALIGNED_T == 4) +#if (QTHREAD_BITS == 32) #define GOLDEN_RATIO 0x9e3779b9 #else #define GOLDEN_RATIO 0x9e3779b97f4a7c13LL diff --git a/include/qthread/qthread.h b/include/qthread/qthread.h index 37e02938b..2e68d8445 100644 --- a/include/qthread/qthread.h +++ b/include/qthread/qthread.h @@ -102,11 +102,20 @@ Q_STARTCXX /* */ * FEB locking only works on aligned addresses. * On all supported platforms sizeof(aligned_t) == alignof(aligned_t) * anyway so we're fine. */ -#if QTHREAD_SIZEOF_ALIGNED_T == 4 + +#if UINTPTR_MAX == UINT32_MAX +#define QTHREAD_BITS 32 +#elif UINTPTR_MAX == UINT64_MAX +#define QTHREAD_BITS 64 +#else +#error Unrecognized bit-ness +#endif + +#if QTHREAD_BITS == 32 typedef uint32_t aligned_t; typedef uint16_t haligned_t; typedef int32_t saligned_t; -#elif QTHREAD_SIZEOF_ALIGNED_T == 8 +#elif QTHREAD_BITS == 64 typedef uint64_t aligned_t; typedef uint32_t haligned_t; typedef int64_t saligned_t; diff --git a/src/ds/dictionary/hash.c b/src/ds/dictionary/hash.c index cbc94c71e..3e2715557 100644 --- a/src/ds/dictionary/hash.c +++ b/src/ds/dictionary/hash.c @@ -105,7 +105,7 @@ uint64_t API_FUNC qt_hash64(uint64_t key) { /*{{{*/ #endif /* if (SIZEOF_VOIDP == 8) */ } /*}}}*/ -#if (QTHREAD_SIZEOF_ALIGNED_T == 4) +#if (QTHREAD_BITS == 32) #define mix(a, b, c) \ do { \ a -= b; \ @@ -136,7 +136,7 @@ uint64_t API_FUNC qt_hash64(uint64_t key) { /*{{{*/ c -= b; \ c ^= (b >> 15); \ } while (0) -#else /* QTHREAD_SIZEOF_ALIGNED_T == 8 */ +#else /* QTHREAD_BITS == 64 */ #define mix(a, b, c) \ do { \ a -= b; \ diff --git a/src/sincs/original.c b/src/sincs/original.c index d59bc048a..3242dd371 100644 --- a/src/sincs/original.c +++ b/src/sincs/original.c @@ -112,11 +112,11 @@ qt_sinc_t *qt_sinc_create(size_t const sizeof_value, (!sinc->result && !sinc->initial_value)); // Allocate counts array - size_t const sizeof_shep_counts = num_wps * QTHREAD_SIZEOF_ALIGNED_T; + size_t const sizeof_shep_counts = num_wps * sizeof(aligned_t); size_t const num_lines_per_shep = QT_CEIL_RATIO(sizeof_shep_counts, cacheline); size_t const sizeof_shep_count_part = - (num_lines_per_shep * cacheline) / QTHREAD_SIZEOF_ALIGNED_T; + (num_lines_per_shep * cacheline) / sizeof(aligned_t); size_t const num_count_array_lines = num_sheps * num_lines_per_shep; sinc->sizeof_shep_count_part = sizeof_shep_count_part; diff --git a/src/sincs/snzi.c b/src/sincs/snzi.c index 78836bd19..25cb3bf9e 100644 --- a/src/sincs/snzi.c +++ b/src/sincs/snzi.c @@ -121,8 +121,6 @@ void qt_sinc_init(qt_sinc_t *restrict sinc_, assert(sizeof(qt_sinc_cache_count_t) <= cacheline); snzi->counts = qt_internal_aligned_alloc(num_sheps * cacheline, cacheline); assert(snzi->counts); - // memset(sinc->counts, 0, num_sheps * cacheline); - // memset(sinc->counts, 0, QTHREAD_SIZEOF_ALIGNED_T * num_sheps); // Initialize counts array if (expect > 0) { diff --git a/test/basics/qthread_incr.c b/test/basics/qthread_incr.c index 643287648..e73b9add3 100644 --- a/test/basics/qthread_incr.c +++ b/test/basics/qthread_incr.c @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) { assert(master == 150); iprintf("30 concurrent threads successfully incremented by 5\n"); -#if (QTHREAD_SIZEOF_ALIGNED_T == 8) +#if (QTHREAD_BITS == 64) master = 0xFFFFFFFF; qthread_incr(&master, 1); if (master != 0x100000000ULL) { @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { assert(master == 0x100000000); } iprintf("64-bit add appears to work\n"); -#endif /* if (QTHREAD_SIZEOF_ALIGNED_T == 8) */ +#endif return 0; } From 5f56d2d6f9d31839800c24dc010c1ebc6c563979 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 14:38:45 -0600 Subject: [PATCH 29/38] Remove unused check for noinline attribute. --- config/qthread_check_attributes.m4 | 19 ------------------- configure.ac | 1 - 2 files changed, 20 deletions(-) diff --git a/config/qthread_check_attributes.m4 b/config/qthread_check_attributes.m4 index 9675f1101..44763fa2e 100644 --- a/config/qthread_check_attributes.m4 +++ b/config/qthread_check_attributes.m4 @@ -3,25 +3,6 @@ # Copyright (c) 2008 Sandia Corporation # -AC_DEFUN([QTHREAD_NOINLINE_ATTRIBUTE],[dnl -AC_CACHE_CHECK( - [support for __attribute__((noinline))], - [qt_cv_noinline_attr], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#include -__attribute__((noinline)) void * f(int i); -__attribute__((noinline)) void * f(int i) -{ return malloc(i); }]])], - [qt_cv_noinline_attr=yes], - [qt_cv_noinline_attr=no])]) - AS_IF([test "x$qt_cv_noinline_attr" = xyes], - [defstr="__attribute__((noinline))"], - [defstr=""]) - AC_DEFINE_UNQUOTED([Q_NOINLINE], [$defstr], - [if the compiler supports __attribute__((NOINLINE))]) - AS_IF([test "x$qt_cv_noinline_attr" = xyes], [$1], [$2]) -]) - AC_DEFUN([QTHREAD_BUILTIN_SYNCHRONIZE],[dnl AC_REQUIRE([QTHREAD_CHECK_ASSEMBLY]) AC_CACHE_CHECK([support for __sync_synchronize], diff --git a/configure.ac b/configure.ac index 588e430a3..3c99ddfc1 100644 --- a/configure.ac +++ b/configure.ac @@ -586,7 +586,6 @@ AS_IF([test "x$enable_hardware_atomics" != xno], [QTHREAD_CHECK_ATOMICS($sizeof_aligned_t)]) QTHREAD_VAMACROS -QTHREAD_NOINLINE_ATTRIBUTE QTHREAD_BUILTIN_SYNCHRONIZE AS_IF([test "x$have_assembly" = "x0" -a "x$qthread_cv_atomic_CAS32" = "xno" -a "x$qthread_cv_atomic_CAS64" = "xno" -a "x$qthread_cv_atomic_incr" = "xno"], From 817e2efad052d987145514f981f4d2fb84f5682f Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 15:07:19 -0600 Subject: [PATCH 30/38] Remove config file for finding portals4. --- config/qthread_check_portals4.m4 | 51 -------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 config/qthread_check_portals4.m4 diff --git a/config/qthread_check_portals4.m4 b/config/qthread_check_portals4.m4 deleted file mode 100644 index a9533b59d..000000000 --- a/config/qthread_check_portals4.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2011 Sandia Corporation -# - -# QTHREAD_CHECK_PORTALS4([action-if-found], [action-if-not-found]) -# -------------------------------------------------------- -AC_DEFUN([QTHREAD_CHECK_PORTALS4],[ - AC_ARG_WITH([portals4], - [AC_HELP_STRING([--with-portals4[[=DIR]]], - [Build Portals4 support, with optional install prefix DIR])]) - - check_portals4_save_CPPFLAGS="$CPPFLAGS" - check_portals4_save_LDFLAGS="$LDFLAGS" - check_portals4_save_LIBS="$LIBS" - - AS_IF([test "$with_portals4" != "no"], - [AS_IF([test ! -z "$with_portals4" -a "$with_portals4" != "yes"], - [check_portals4_dir="$with_portals4"]) - - OMPI_CHECK_PACKAGE([portals4], - [portals4.h], - [portals], - [PtlLEAppend], - [], - [$check_portals4_dir], - [$check_portals4_dir/src/.libs], - [check_portals4_happy="yes"], - [check_portals4_happy="no"]) - OMPI_CHECK_PACKAGE([portals4_runtime], - [pmi.h], - [portals_runtime], - [PMI_Init], - [], - [$check_portals4_dir/src/runtime/portals4], - [$check_portals4_dir/src/runtime/.libs], - [check_portals4_happy="yes"], - [check_portals4_happy="no"])], - [check_portals4_happy="no"]) - -CPPFLAGS="$check_portals4_save_CPPFLAGS" - LDFLAGS="$check_portals4_save_LDFLAGS" - LIBS="$check_portals4_save_LIBS" - - AS_IF([test "$check_portals4_happy" = "yes"], - [$1], - [AS_IF([test ! -z "$with_portals4" -a "$with_portals4" != "no"], - [AC_MSG_ERROR([Portals4 support requested but not found. Aborting])]) - $2]) -]) - From 5d5608fbad415bddacb441f02ad4893a73851865 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 15:35:41 -0600 Subject: [PATCH 31/38] Get rid of configure check for PTHREAD_PROCESS_PRIVATE since it's unused. --- config/qthread_check_pthreads.m4 | 23 ----------------------- configure.ac | 1 - 2 files changed, 24 deletions(-) delete mode 100644 config/qthread_check_pthreads.m4 diff --git a/config/qthread_check_pthreads.m4 b/config/qthread_check_pthreads.m4 deleted file mode 100644 index 141ae3474..000000000 --- a/config/qthread_check_pthreads.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2008 Sandia Corporation -# - -# QTHREAD_PTHREAD_PROCESS_PRIVATE([action-if-found], [action-if-not-found]) -# ------------------------------------------------------------------------- -AC_DEFUN([QTHREAD_PTHREAD_PROCESS_PRIVATE],[dnl -AC_CACHE_CHECK( - [support for PTHREAD_PROCESS_PRIVATE], - [qt_cv_pthread_process_private], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#include -int val = PTHREAD_PROCESS_PRIVATE; -]])], - [qt_cv_pthread_process_private=yes], - [qt_cv_pthread_process_private=no])]) - AS_IF([test "x$qt_cv_pthread_process_private" = xyes], - [AC_DEFINE([HAVE_PTHREAD_PROCESS_PRIVATE], [1], - [have access to the PTHREAD_PROCESS_PRIVATE constant])]) - AS_IF([test "x$qt_cv_pthread_process_private" = xyes], [$1], [$2]) -]) - diff --git a/configure.ac b/configure.ac index 3c99ddfc1..3c12ee225 100644 --- a/configure.ac +++ b/configure.ac @@ -489,7 +489,6 @@ AS_IF([test "x$enable_internal_spinlock" != xno], [AC_CHECK_FUNCS([pthread_spin_init], [have_pthread_spinlocks=yes], [have_pthread_spinlocks=no])]) -QTHREAD_PTHREAD_PROCESS_PRIVATE AC_SEARCH_LIBS([nanosleep],[rt],[], [AC_MSG_ERROR([Cannot find nanosleep])]) From 49fc3e1ff23a5fa922a03bf03ac0ae6207e76574 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 15:57:47 -0600 Subject: [PATCH 32/38] Get rid of unused qsort configure check. --- config/qthread_check_qsort.m4 | 78 ----------------------------------- configure.ac | 1 - 2 files changed, 79 deletions(-) delete mode 100644 config/qthread_check_qsort.m4 diff --git a/config/qthread_check_qsort.m4 b/config/qthread_check_qsort.m4 deleted file mode 100644 index 1f155d147..000000000 --- a/config/qthread_check_qsort.m4 +++ /dev/null @@ -1,78 +0,0 @@ -# -*- Autoconf -*- -# -# Copyright (c) 2009 Sandia Corporation -# - -# QTHREAD_CHECK_QSORT([action-if-found], [action-if-not-found]) -# ------------------------------------------------------------------------------ -AC_DEFUN([QTHREAD_CHECK_QSORT], [ -AC_ARG_WITH([bsd-qsort_r], - [AS_HELP_STRING([--with-bsd-qsort_r], - [Force the assumption of a BSD-style qsort_r implementation (for cross-compiling)])]) -AC_CHECK_FUNCS([qsort_r], - [AC_CACHE_CHECK([for qsort_r argument style], - [qthread_cv_qsort_r_style], - [AS_IF([test "x$with_bsd_qsort_r" = x], - [AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include -#include - -struct sigaction sa; - -static int cmp(void *a, const void *b, const void*c) -{ - assert(a == NULL); - return *(int*)b - *(int*)c; -} - -static void handler(int sig, siginfo_t* s, void* v) -{ - _exit(1); -} - -static void register_handle(void) -{ - memset (&sa, '\0', sizeof(sa)); - sa.sa_sigaction = &handler; - sa.sa_flags = SA_SIGINFO; - // Catch SIGSEGV - sigaction(SIGSEGV, &sa, NULL); -} - -int main(void) -{ - int array[5] = {7,3,5,2,8}; - int i; - register_handle(); - qsort_r(array,5,sizeof(int),NULL,cmp); - for (i=0;i<4;i++) { - assert(array[i] < array[i+1]); - } - return 0; -}]])], - [qthread_cv_qsort_r_style="BSD"], - [qthread_cv_qsort_r_style="glibc"], - [case "$host" in - *-gnu|*-linux) - qthread_cv_qsort_r_style="glibc" - ;; - *bsd) - qthread_cv_qsort_r_style="BSD" - ;; - *) - qthread_cv_qsort_r_style="unknown" - ;; - esac])], - [AS_IF([test "x$with_bsd_qsort_r" = xyes], - [qthread_cv_qsort_r_style=BSD], - [qthread_cv_qsort_r_style=glibc])])]) - AS_IF([test "x$qthread_cv_qsort_r_style" == xBSD], - [AC_DEFINE([QTHREAD_QSORT_BSD],[1],[Define for BSD-style qsort_r])], - [AS_IF([test "x$qthread_cv_qsort_r_style" == xglibc], - [AC_DEFINE([QTHREAD_QSORT_GLIBC],[1],[Define for glibc-style qsort_r])])])]) -AS_IF([test "x$qthread_cv_qsort_r_style" != "xunknown"], [$1], [$2]) -]) -# vim:set expandtab diff --git a/configure.ac b/configure.ac index 3c12ee225..c875aadb0 100644 --- a/configure.ac +++ b/configure.ac @@ -620,7 +620,6 @@ AS_IF([test "x$enable_setrlimit" = "xyes"], [AC_DEFINE([NEED_RLIMIT], [1], [Whether the library should use get/set rlimit functions])], [AC_MSG_ERROR([setrlimit() calls enabled, but function is unavailable])])]) AC_CHECK_FUNCS([strtol memalign posix_memalign memset memmove munmap memcpy fstat64 lseek64 getcontext swapcontext makecontext sched_yield processor_bind madvise sysconf sysctl syscall]) -QTHREAD_CHECK_QSORT AC_CHECK_DECLS([MADV_ACCESS_LWP],[],[],[[#include #include ]]) From eb1a3f91228e42f607ac4bba03c25bff878cba23 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 16:28:50 -0600 Subject: [PATCH 33/38] Remove unneeded configure check for the type of variadic macros. C99 just works at this point. --- config/qthread_vamacros.m4 | 46 -------------------------------------- include/qt_debug.h | 9 -------- 2 files changed, 55 deletions(-) delete mode 100644 config/qthread_vamacros.m4 diff --git a/config/qthread_vamacros.m4 b/config/qthread_vamacros.m4 deleted file mode 100644 index 7be8ff6a4..000000000 --- a/config/qthread_vamacros.m4 +++ /dev/null @@ -1,46 +0,0 @@ -dnl largely based on http://www.openldap.org/lists/openldap-devel/200801/msg00057.html -dnl -dnl This file defines two macros for probing for compiler support for variadic -dnl macros. Provided are QT_C_C99_VAMACROS, which checks for support for the -dnl C99 variadic macro syntax, namely: -dnl -dnl #define macro(...) fprintf(stderr, __VA_ARGS__) -dnl -dnl and QT_C_GNU_VAMACROS, which checks for support for the older GNU -dnl variadic macro syntax, namely: -dnl -dnl #define macro(args...) fprintf(stderr, args) -dnl -dnl They set HAVE_C99_VAMACROS or HAVE_GNU_VAMACROS as appropriate. - -AC_DEFUN([QT_C_C99_VAMACROS], - [AC_CACHE_CHECK([for C99 variadic macros], - [qt_cv_c_c99_vamacros], - [AC_TRY_COMPILE( -[#include -#define error(...) fprintf(stderr, __VA_ARGS__)], - [error("foo"); error("foo %d", 0); return 0;], - [qt_cv_c_c99_vamacros=yes], - [qt_cv_c_c99_vamacros=no])]) - AS_IF([test x$qt_cv_c_c99_vamacros = xyes], - [AC_DEFINE([HAVE_C99_VAMACROS], [1], - [Define if the compiler supports C99 variadic macros.])]) -]) - -AC_DEFUN([QT_C_GNU_VAMACROS], - [AC_CACHE_CHECK([for GNU-style variadic macros], - [qt_cv_c_gnu_vamacros], - [AC_TRY_COMPILE( -[#include -#define error(args...) fprintf(stderr, args)], -[error("foo"); error("foo %d", 0); return 0;], - [qt_cv_c_gnu_vamacros=yes], - [qt_cv_c_gnu_vamacros=no])]) - AS_IF([test x$qt_cv_c_gnu_vamacros = xyes], - [AC_DEFINE([HAVE_GNU_VAMACROS], [1], - [Define if the compiler supports GNU-style variadic macros.])]) -]) - -AC_DEFUN([QTHREAD_VAMACROS], - [QT_C_C99_VAMACROS() - QT_C_GNU_VAMACROS()]) diff --git a/include/qt_debug.h b/include/qt_debug.h index 9924633bb..f72faf935 100644 --- a/include/qt_debug.h +++ b/include/qt_debug.h @@ -251,19 +251,10 @@ extern enum qthread_debug_levels debuglevel; extern QTHREAD_FASTLOCK_TYPE output_lock; -#ifdef HAVE_GNU_VAMACROS -#define qthread_debug(level, format, args...) \ - qthread_debug_(level, "%s(%u): " format, __FUNCTION__, __LINE__, ##args) - -static QINLINE void qthread_debug_(int level, char const *format, ...) -#elif defined(HAVE_C99_VAMACROS) #define qthread_debug(level, format, ...) \ qthread_debug_(level, "%s(%u): " format, __FUNCTION__, __LINE__, __VA_ARGS__) static QINLINE void qthread_debug_(int level, char const *format, ...) -#else -static QINLINE void qthread_debug(int level, char const *format, ...) -#endif // ifdef HAVE_GNU_VAMACROS { /*{{{ */ va_list args; From 855a8a85db8cd25dcc5e845a53bb5cba0175f8d0 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 16:40:56 -0600 Subject: [PATCH 34/38] Fix compile-time configuration of QTHREAD_TRAP. --- include/qthread/common.h.in | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index b38477302..62ca36da6 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -65,13 +65,11 @@ #endif #endif -/* If __builtin_trap can be used */ -#undef QTHREAD_TRAP_OKAY - -#ifdef QTHREAD_TRAP_OKAY -# define QTHREAD_TRAP() __builtin_trap() +#ifdef __GNUC__ +#define QTHREAD_TRAP() __builtin_trap() #else -# define QTHREAD_TRAP() *(volatile int *)0 = 0 +#include "signal.h" +#define QTHREAD_TRAP() raise(SIGABRT) #endif /* Architecture defines */ From 31ee0b944a928ae79ed03a2845b716d9731f1806 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Tue, 17 Sep 2024 16:48:24 -0600 Subject: [PATCH 35/38] Fix compilation for assertions builds. --- src/hashmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hashmap.c b/src/hashmap.c index cb8db990b..0fdf5b6ee 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -199,7 +199,7 @@ void INTERNAL qt_hash_destroy_deallocate(qt_hash h, } } } - assert(visited == atomic_load_explicit(&h->population)); + assert(visited == atomic_load_explicit(&h->population, memory_order_relaxed)); if (h->lock) { QTHREAD_FASTLOCK_UNLOCK(h->lock); } qt_hash_destroy(h); } /*}}}*/ From 0bd6a54d94762caff95cb4d9599ee92625b89b94 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Wed, 18 Sep 2024 11:41:50 -0600 Subject: [PATCH 36/38] Fix segfault on OSX resulting from misuse of aligned_alloc. --- .cirrus.yml | 10 +++++++--- .github/workflows/CI.yml | 7 ++++++- src/alloc/base.c | 11 +++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index d3e9f2f10..1b9989fae 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -34,13 +34,17 @@ osx_m1_task: brew install autoconf automake libtool coreutils # coreutils is to get gtimeout for CI and is not universally required by qthreads. if [ "$QTHREADS_TOPOLOGY" != "no" ]; then brew install hwloc; fi build_script: | - export CFLAGS="-I$(brew --prefix)/include $CFLAGS" - export CXXFLAGS="-I$(brew --prefix)/include $CXXFLAGS" - export LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" + export CFLAGS="-g -I$(brew --prefix)/include $CFLAGS" + export CXXFLAGS="-g -I$(brew --prefix)/include $CXXFLAGS" + export LDFLAGS="-g -L$(brew --prefix)/lib $LDFLAGS" ./autogen.sh ./configure --enable-picky --with-scheduler=$QTHREADS_SCHEDULER --with-topology=$QTHREADS_TOPOLOGY make -j$CIRRUS_CPU test_script: | + make tests -j$CIRRUS_CPU + # commented example for how to get a backtrace from CI usign lldb on OSX: + #echo "settings set target.process.stop-on-exec false" > ~/.lldbinit + #QT_NUM_SHEPHERDS=2 QT_NUM_WORKERS_PER_SHEPHERD=1 lldb bash --batch --one-line 'process launch' --one-line-on-crash 'bt' --one-line-on-crash 'quit' -- test/basics/hello_world gtimeout --foreground 3m make check freebsd_task: diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4631d92f2..0c0534e4f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -226,7 +226,12 @@ jobs: ./configure $QTHREADS_ENABLE_ASSERTS --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j3 - name: make check - run: gtimeout -k 10s --foreground 8m make check + run: | + make tests -j3 + # commented example for how to get a backtrace from CI usign lldb on OSX: + #echo "settings set target.process.stop-on-exec false" > ~/.lldbinit + #QT_NUM_SHEPHERDS=2 QT_NUM_WORKERS_PER_SHEPHERD=1 lldb bash --batch --one-line 'process launch' --one-line-on-crash 'bt' --one-line-on-crash 'quit' -- test/basics/hello_world + gtimeout -k 10s --foreground 8m make check timeout-minutes: 9 sanitizers: diff --git a/src/alloc/base.c b/src/alloc/base.c index f0b8381da..451cfa30e 100644 --- a/src/alloc/base.c +++ b/src/alloc/base.c @@ -33,8 +33,15 @@ void *qt_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void qt_internal_alignment_init(void) { _pagesize = getpagesize(); } -void *qt_internal_aligned_alloc(size_t alloc_size, uint_fast16_t alignment) { - return aligned_alloc((size_t) alignment, alloc_size); +void *qt_internal_aligned_alloc(size_t alloc_size, uint_fast16_t alignment_small) { + size_t alignment = alignment_small; + // round alloc_size up to the nearest multiple of alignment + // since that's required by the standard aligned_alloc + // and the implementation on OSX actually enforces that. + if (alignment) { + alloc_size = ((alloc_size + (alignment - 1ull)) / alignment) * alignment; + } + return aligned_alloc(alignment, alloc_size); } void qt_internal_aligned_free(void *ptr, uint_fast16_t alignment) { From eca8a6042acb91084afeda3f4b501b9f278dd4ab Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Wed, 18 Sep 2024 15:35:26 -0600 Subject: [PATCH 37/38] Compile tests separately before running make check to save time in CI. --- .circleci/config.yml | 5 +++++ .cirrus.yml | 5 ++++- .github/workflows/CI.yml | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00c566557..e0617d648 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=<< parameters.scheduler >> --with-topology=<< parameters.topology >> make -j2 + make tests -j2 - run: command: timeout --foreground -k 10s 2m make check no_output_timeout: 60s @@ -55,6 +56,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=<< parameters.scheduler >> -with-topology=<< parameters.topology >> make -j2 + make tests -j2 - run: command: timeout --foreground -k 10s 2m make check no_output_timeout: 60s @@ -92,6 +94,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=<< parameters.scheduler >> -with-topology=<< parameters.topology >> make -j2 + make tests -j2 - run: command: timeout --foreground -k 10s 4m make check no_output_timeout: 120s @@ -127,6 +130,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=<< parameters.scheduler >> -with-topology=<< parameters.topology >> make -j2 + make tests -j2 - run: command: | export PATH=$PATH:/opt/arm/arm-linux-compiler-24.04_Ubuntu-22.04/bin @@ -152,6 +156,7 @@ jobs: bash autogen.sh bash configure --enable-picky --with-scheduler=<< parameters.scheduler >> -with-topology=<< parameters.topology >> make -j2 + make tests -j2 - run: command: make check no_output_timeout: 60s diff --git a/.cirrus.yml b/.cirrus.yml index 1b9989fae..28f765350 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -40,8 +40,8 @@ osx_m1_task: ./autogen.sh ./configure --enable-picky --with-scheduler=$QTHREADS_SCHEDULER --with-topology=$QTHREADS_TOPOLOGY make -j$CIRRUS_CPU - test_script: | make tests -j$CIRRUS_CPU + test_script: | # commented example for how to get a backtrace from CI usign lldb on OSX: #echo "settings set target.process.stop-on-exec false" > ~/.lldbinit #QT_NUM_SHEPHERDS=2 QT_NUM_WORKERS_PER_SHEPHERD=1 lldb bash --batch --one-line 'process launch' --one-line-on-crash 'bt' --one-line-on-crash 'quit' -- test/basics/hello_world @@ -66,6 +66,7 @@ freebsd_task: bash autogen.sh bash configure --enable-picky --with-scheduler=$QTHREADS_SCHEDULER --with-topology=no make -j$CIRRUS_CPU + make tests -j$CIRRUS_CPU test_script: | gtimeout --foreground -k 10s 2m make check @@ -109,6 +110,7 @@ arm_linux_task: ./autogen.sh ./configure --enable-picky --with-scheduler=$QTHREADS_SCHEDULER --with-topology=$QTHREADS_TOPOLOGY make -j$CIRRUS_CPU + make tests -j$CIRRUS_CPU test_script: | timeout --foreground -k 10s 2m make check @@ -164,6 +166,7 @@ arm_linux_clang_task: ./autogen.sh ./configure --enable-picky --with-scheduler=$QTHREADS_SCHEDULER --with-topology=$QTHREADS_TOPOLOGY make -j$CIRRUS_CPU + make tests -j$CIRRUS_CPU test_script: | timeout --foreground -k 10s 2m make check diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0c0534e4f..1358cd9c9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,6 +29,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j2 + make tests -j2 - name: make check run: timeout -k 10s --foreground 3m make check timeout-minutes: 4 @@ -80,6 +81,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j2 + make tests -j2 - name: make check run: timeout -k 10s --foreground 6m make check timeout-minutes: 7 @@ -117,6 +119,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} || cat config.log make -j2 + make tests -j2 - name: make check run: | source /opt/intel/oneapi/setvars.sh @@ -157,6 +160,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} || cat config.log make -j2 + make tests -j2 - name: make check run: | source /opt/intel/oneapi/setvars.sh @@ -193,6 +197,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} || cat config.log make -j2 + make tests -j2 - name: make check run: | timeout -k 10s --foreground 6m make check @@ -225,9 +230,9 @@ jobs: ./autogen.sh ./configure $QTHREADS_ENABLE_ASSERTS --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j3 + make tests -j3 - name: make check run: | - make tests -j3 # commented example for how to get a backtrace from CI usign lldb on OSX: #echo "settings set target.process.stop-on-exec false" > ~/.lldbinit #QT_NUM_SHEPHERDS=2 QT_NUM_WORKERS_PER_SHEPHERD=1 lldb bash --batch --one-line 'process launch' --one-line-on-crash 'bt' --one-line-on-crash 'quit' -- test/basics/hello_world @@ -273,6 +278,7 @@ jobs: ./autogen.sh ./configure --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j2 + make tests -j2 - name: make check run: timeout -k 10s --foreground 8m make check timeout-minutes: 9 @@ -316,6 +322,7 @@ jobs: ./autogen.sh ./configure $QTHREADS_ENABLE_ASSERTS --enable-picky --with-scheduler=${{ matrix.scheduler }} --with-topology=${{ matrix.topology }} make -j2 + make tests -j2 - name: make check run: timeout -k 10s --foreground 6m make check timeout-minutes: 7 From 4b2d32b020d5b15c64a5e30fc73512c3335e15f9 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Thu, 19 Sep 2024 10:05:13 -0600 Subject: [PATCH 38/38] Fix some additional cases where the old SIZEOF_VOIDP was being used to detect the bitness of a given architecture. --- include/qthread/common.h.in | 3 --- include/qthread/qthread.h | 4 ++-- src/ds/dictionary/hash.c | 32 ++++++++++++++++---------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index 62ca36da6..79f047437 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -39,9 +39,6 @@ #define BITFIELD_ORDER_FORWARD #endif -/* The size of `void*', as computed by sizeof. */ -#undef SIZEOF_VOIDP - /* builtin cas supported */ #undef QTHREAD_ATOMIC_CAS diff --git a/include/qthread/qthread.h b/include/qthread/qthread.h index 2e68d8445..d8971f284 100644 --- a/include/qthread/qthread.h +++ b/include/qthread/qthread.h @@ -1344,11 +1344,11 @@ static QINLINE aligned_t qthread_cas_xx(aligned_t *addr, static QINLINE void * qthread_cas_ptr_(void **addr, void *oldval, void *newval) { /*{{{*/ -#if (SIZEOF_VOIDP == 4) +#if (QTHREAD_BITS == 32) return (void *)(uintptr_t)qthread_cas32( (uint32_t *)addr, (uint32_t)(uintptr_t)oldval, (uint32_t)(uintptr_t)newval); -#elif (SIZEOF_VOIDP == 8) +#elif (QTHREAD_BITS == 64) return (void *)(uintptr_t)qthread_cas64( (uint64_t *)addr, (uint64_t)(uintptr_t)oldval, (uint64_t)(uintptr_t)newval); diff --git a/src/ds/dictionary/hash.c b/src/ds/dictionary/hash.c index 3e2715557..4fb24551f 100644 --- a/src/ds/dictionary/hash.c +++ b/src/ds/dictionary/hash.c @@ -19,7 +19,7 @@ uint64_t API_FUNC qt_hash64(uint64_t key) { /*{{{*/ uint8_t b[sizeof(uint64_t)]; } k = {key}; -#if (SIZEOF_VOIDP == 8) /* i.e. a 64-bit machine */ +#if (QTHREAD_BITS == 64) uint64_t a, b, c; a = b = 0x9e3779b97f4a7c13LL; // the golden ratio @@ -72,37 +72,37 @@ uint64_t API_FUNC qt_hash64(uint64_t key) { /*{{{*/ c = c ^ (b >> 22u); return c; -#else /* i.e. a 32-bit machine */ +#else uint32_t a, b, c; a = b = 0x9e3779b9; // golden ratio c = 0xdeadbeef + sizeof(uint64_t); - b += k.b[7] << 24; - b += k.b[6] << 16; - b += k.b[5] << 8; + b += k.b[7] << 24u; + b += k.b[6] << 16u; + b += k.b[5] << 8u; b += k.b[4]; - a += k.b[3] << 24; - a += k.b[2] << 16; - a += k.b[1] << 8; + a += k.b[3] << 24u; + a += k.b[2] << 16u; + a += k.b[1] << 8u; a += k.b[0]; c ^= b; - c -= rot(b, 14); + c -= rot(b, 14u); a ^= c; - a -= rot(c, 11); + a -= rot(c, 11u); b ^= a; - b -= rot(a, 25); + b -= rot(a, 25u); c ^= b; - c -= rot(b, 16); + c -= rot(b, 16u); a ^= c; - a -= rot(c, 4); + a -= rot(c, 4u); b ^= a; - b -= rot(a, 14); + b -= rot(a, 14u); c ^= b; - c -= rot(b, 24); + c -= rot(b, 24u); return ((uint64_t)c + (((uint64_t)b) << 32)); -#endif /* if (SIZEOF_VOIDP == 8) */ +#endif /* if (QTHREAD_BITS == 64) */ } /*}}}*/ #if (QTHREAD_BITS == 32)